Tabnine Logo
InvalidKeyException.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
java.security.InvalidKeyException
constructor

Best Java code snippets using java.security.InvalidKeyException.<init> (Showing top 20 results out of 963)

origin: wildfly/wildfly

@Override
boolean verify(char[] guess) throws InvalidKeyException {
  // The OTP SASL mechanism handles this (this involves updating the stored password)
  throw new InvalidKeyException();
}
origin: robovm/robovm

private InvalidKeyException invalidKey() throws InvalidKeyException {
  throw new InvalidKeyException("Decrypted data does not represent valid PKCS#8 PrivateKeyInfo");
}
origin: wildfly/wildfly

boolean verify(final char[] guess) throws InvalidKeyException {
  try {
    return Arrays.equals(guess, unmask(algorithm, initialKeyMaterial, iterationCount, salt, maskedPasswordBytes));
  } catch (InvalidKeySpecException e) {
    throw new InvalidKeyException(e);
  }
}
origin: kaaproject/kaa

/**
 * Gets the private key from bytes.
 *
 * @param keyBytes the key bytes
 * @return the private
 * @throws InvalidKeyException invalid key exception
 */
public static PrivateKey getPrivate(byte[] keyBytes) throws InvalidKeyException {
 try {
  PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes);
  KeyFactory kf = KeyFactory.getInstance(RSA);
  return kf.generatePrivate(spec);
 } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) {
  throw new InvalidKeyException(ex);
 }
}
origin: kaaproject/kaa

/**
 * Gets the public key from bytes.
 *
 * @param keyBytes the key bytes
 * @return the public
 * @throws InvalidKeyException invalid key exception
 */
public static PublicKey getPublic(byte[] keyBytes) throws InvalidKeyException {
 try {
  X509EncodedKeySpec spec = new X509EncodedKeySpec(keyBytes);
  KeyFactory kf = KeyFactory.getInstance(RSA);
  return kf.generatePublic(spec);
 } catch (NoSuchAlgorithmException | InvalidKeySpecException ex) {
  throw new InvalidKeyException(ex);
 }
}
origin: cSploit/android

public synchronized void setBranch(String branch) throws InvalidKeyException, JSONException, IOException {
 if(mBranches==null)
  fetchBranches();
 for (int i = 0; i < mBranches.length(); i++) {
  if((mBranches.getJSONObject(i)).getString("name").equals(branch)) {
   mBranch = (mBranches.getJSONObject(i));
   mLastCommit = mBranch.getJSONObject("commit");
   return;
  }
 }
 throw new InvalidKeyException("branch '" + branch + "' not found");
}
origin: Meituan-Dianping/walle

  private static String getJcaSignatureAlgorithm(
      PublicKey publicKey, DigestAlgorithm digestAlgorithm) throws InvalidKeyException {
    String keyAlgorithm = publicKey.getAlgorithm();
    String digestPrefixForSigAlg;
    switch (digestAlgorithm) {
      case SHA1:
        digestPrefixForSigAlg = "SHA1";
        break;
      case SHA256:
        digestPrefixForSigAlg = "SHA256";
        break;
      default:
        throw new IllegalArgumentException(
            "Unexpected digest algorithm: " + digestAlgorithm);
    }
    if ("RSA".equalsIgnoreCase(keyAlgorithm)) {
      return digestPrefixForSigAlg + "withRSA";
    } else if ("DSA".equalsIgnoreCase(keyAlgorithm)) {
      return digestPrefixForSigAlg + "withDSA";
    } else if ("EC".equalsIgnoreCase(keyAlgorithm)) {
      return digestPrefixForSigAlg + "withECDSA";
    } else {
      throw new InvalidKeyException("Unsupported key algorithm: " + keyAlgorithm);
    }
  }
}
origin: Meituan-Dianping/walle

private static byte[] encodePublicKey(PublicKey publicKey) throws InvalidKeyException {
  byte[] encodedPublicKey = null;
  if ("X.509".equals(publicKey.getFormat())) {
    encodedPublicKey = publicKey.getEncoded();
  }
  if (encodedPublicKey == null) {
    try {
      encodedPublicKey =
          KeyFactory.getInstance(publicKey.getAlgorithm())
              .getKeySpec(publicKey, X509EncodedKeySpec.class)
              .getEncoded();
    } catch (NoSuchAlgorithmException e) {
      throw new InvalidKeyException(
          "Failed to obtain X.509 encoded form of public key " + publicKey
              + " of class " + publicKey.getClass().getName(),
          e);
    } catch (InvalidKeySpecException e) {
      throw new InvalidKeyException(
          "Failed to obtain X.509 encoded form of public key " + publicKey
              + " of class " + publicKey.getClass().getName(),
          e);
    }
  }
  if ((encodedPublicKey == null) || (encodedPublicKey.length == 0)) {
    throw new InvalidKeyException(
        "Failed to obtain X.509 encoded form of public key " + publicKey
            + " of class " + publicKey.getClass().getName());
  }
  return encodedPublicKey;
}
origin: wildfly/wildfly

  @Override
  protected Password engineTransform(final String algorithm, final Password password, final AlgorithmParameterSpec parameterSpec) throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (password instanceof AbstractPasswordImpl) {
      final AbstractPasswordImpl abstractPassword = (AbstractPasswordImpl) password;
      if (algorithm.equals(abstractPassword.getAlgorithm())) {
        return abstractPassword.translate(parameterSpec);
      }
    }
    throw new InvalidKeyException();
  }
}
origin: wildfly/wildfly

@Override
protected boolean engineVerify(final String algorithm, final Password password, final char[] guess) throws InvalidKeyException {
  if (password instanceof AbstractPasswordImpl) {
    final AbstractPasswordImpl abstractPassword = (AbstractPasswordImpl) password;
    if (algorithm.equals(abstractPassword.getAlgorithm())) {
      return abstractPassword.verify(guess);
    }
  }
  throw new InvalidKeyException();
}
origin: Graylog2/graylog2-server

private SSLEngineConfigurator buildSslEngineConfigurator(Path certFile, Path keyFile, String keyPassword)
    throws GeneralSecurityException, IOException {
  if (keyFile == null || !Files.isRegularFile(keyFile) || !Files.isReadable(keyFile)) {
    throw new InvalidKeyException("Unreadable or missing private key: " + keyFile);
  }
  if (certFile == null || !Files.isRegularFile(certFile) || !Files.isReadable(certFile)) {
    throw new CertificateException("Unreadable or missing X.509 certificate: " + certFile);
  }
  final SSLContextConfigurator sslContextConfigurator = new SSLContextConfigurator();
  final char[] password = firstNonNull(keyPassword, "").toCharArray();
  final KeyStore keyStore = PemKeyStore.buildKeyStore(certFile, keyFile, password);
  sslContextConfigurator.setKeyStorePass(password);
  sslContextConfigurator.setKeyStoreBytes(KeyStoreUtils.getBytes(keyStore, password));
  final SSLContext sslContext = sslContextConfigurator.createSSLContext(true);
  return new SSLEngineConfigurator(sslContext, false, false, false);
}
origin: wildfly/wildfly

@Override
public final InvalidKeyException invalidKeyNoSuchMessageDigestAlgorithm(final String algorithm) {
  final InvalidKeyException result = new InvalidKeyException(String.format(getLoggingLocale(), invalidKeyNoSuchMessageDigestAlgorithm$str(), algorithm));
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String invalidKeyCannotVerifyPassword = "ELY08015: Cannot verify password";
origin: wildfly/wildfly

@Override
public final InvalidKeyException invalidKeyCannotVerifyPassword(final Throwable cause) {
  final InvalidKeyException result = new InvalidKeyException(String.format(getLoggingLocale(), invalidKeyCannotVerifyPassword$str()), cause);
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String invalidKeyDesCryptPasswordHashMustBeBytes = "ELY08017: DES crypt password hash must be %d bytes";
origin: wildfly/wildfly

@Override
public final InvalidKeyException invalidKeyBsdDesCryptPasswordHashMustBeBytes(final int bytes) {
  final InvalidKeyException result = new InvalidKeyException(String.format(getLoggingLocale(), invalidKeyBsdDesCryptPasswordHashMustBeBytes$str(), bytes));
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String invalidKeySpecExpectedSpecGotSpec = "ELY08025: Expected to get a \"%s\" as spec, got \"%s\"";
origin: wildfly/wildfly

@Override
public final InvalidKeyException invalidKeyUnknownUnknownPasswordTypeOrAlgorithm() {
  final InvalidKeyException result = new InvalidKeyException(String.format(getLoggingLocale(), invalidKeyUnknownUnknownPasswordTypeOrAlgorithm$str()));
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String noSuchAlgorithmInvalidAlgorithm = "ELY08028: Invalid algorithm \"%s\"";
origin: wildfly/wildfly

@Override
public final InvalidKeyException invalidKeyDesCryptPasswordHashMustBeBytes(final int bytes) {
  final InvalidKeyException result = new InvalidKeyException(String.format(getLoggingLocale(), invalidKeyDesCryptPasswordHashMustBeBytes$str(), bytes));
  final StackTraceElement[] st = result.getStackTrace();
  result.setStackTrace(Arrays.copyOfRange(st, 1, st.length));
  return result;
}
private static final String invalidParameterSpecSaltMustBeBytesBits = "ELY08018: Salt must be %d bytes (%d bits)";
origin: signalapp/Signal-Server

public static byte[] calculateSignature(ECPrivateKey signingKey, byte[] message)
  throws InvalidKeyException
{
 if (signingKey == null || message == null) {
  throw new InvalidKeyException("Values must not be null");
 }
 if (signingKey.getType() == DJB_TYPE) {
  return Curve25519.getInstance(BEST)
           .calculateSignature(((DjbECPrivateKey) signingKey).getPrivateKey(), message);
 } else {
  throw new InvalidKeyException("Unknown type: " + signingKey.getType());
 }
}
origin: Meituan-Dianping/walle

private static byte[] generateApkSignatureSchemeV2Block(
    List<SignerConfig> signerConfigs,
    Map<ContentDigestAlgorithm, byte[]> contentDigests)
        throws InvalidKeyException, SignatureException {
  // FORMAT:
  // * length-prefixed sequence of length-prefixed signer blocks.
  List<byte[]> signerBlocks = new ArrayList<>(signerConfigs.size());
  int signerNumber = 0;
  for (SignerConfig signerConfig : signerConfigs) {
    signerNumber++;
    byte[] signerBlock;
    try {
      signerBlock = generateSignerBlock(signerConfig, contentDigests);
    } catch (InvalidKeyException e) {
      throw new InvalidKeyException("Signer #" + signerNumber + " failed", e);
    } catch (SignatureException e) {
      throw new SignatureException("Signer #" + signerNumber + " failed", e);
    }
    signerBlocks.add(signerBlock);
  }
  return encodeAsSequenceOfLengthPrefixedElements(
      new byte[][] {
        encodeAsSequenceOfLengthPrefixedElements(signerBlocks),
      });
}
origin: wildfly/wildfly

@Override
boolean verify(char[] guess) throws InvalidKeyException {
  if (guess.length == 0) return false;
  try {
    byte[] output = scramDigest(this.getAlgorithm(), getNormalizedPasswordBytes(guess), this.getSalt(), this.getIterationCount());
    return Arrays.equals(this.digest, output);
  } catch (NoSuchAlgorithmException nsae) {
    throw new InvalidKeyException(nsae);
  }
}
origin: signalapp/Signal-Server

public static boolean verifySignature(ECPublicKey signingKey, byte[] message, byte[] signature)
  throws InvalidKeyException
{
 if (signingKey.getType() == DJB_TYPE) {
  return Curve25519.getInstance(BEST)
           .verifySignature(((DjbECPublicKey) signingKey).getPublicKey(), message, signature);
 } else {
  throw new InvalidKeyException("Unknown type: " + signingKey.getType());
 }
}
java.securityInvalidKeyException<init>

Javadoc

Constructs a new instance of InvalidKeyException.

Popular methods of InvalidKeyException

  • getMessage
  • printStackTrace
  • toString
  • getLocalizedMessage
  • initCause
  • getStackTrace
  • setStackTrace
  • getCause
  • addSuppressed
  • fillInStackTrace

Popular in Java

  • Start an intent from android
  • putExtra (Intent)
  • compareTo (BigDecimal)
  • runOnUiThread (Activity)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now