Tabnine Logo
Key.getAlgorithm
Code IndexAdd Tabnine to your IDE (free)

How to use
getAlgorithm
method
in
java.security.Key

Best Java code snippets using java.security.Key.getAlgorithm (Showing top 20 results out of 1,701)

origin: google/guava

private static String hmacToString(String methodName, Key key) {
 return String.format(
   "Hashing.%s(Key[algorithm=%s, format=%s])",
   methodName, key.getAlgorithm(), key.getFormat());
}
origin: hierynomus/sshj

  @Override
  protected boolean isMyType(Key key) {
    return "EdDSA".equals(key.getAlgorithm());
  }
},
origin: JZ-Darkal/AndroidHttpCapture

/**
 * Returns true if the key is an elliptic curve public or private key.
 */
public static boolean isEcKey(Key key) {
  return "EC".equals(key.getAlgorithm());
}
origin: JZ-Darkal/AndroidHttpCapture

/**
 * Returns true if the key is an RSA public or private key.
 */
public static boolean isRsaKey(Key key) {
  return "RSA".equals(key.getAlgorithm());
}
origin: prestodb/presto

private static String hmacToString(String methodName, Key key) {
 return String.format(
   "Hashing.%s(Key[algorithm=%s, format=%s])",
   methodName, key.getAlgorithm(), key.getFormat());
}
origin: google/j2objc

private static String hmacToString(String methodName, Key key) {
 return String.format(
   "Hashing.%s(Key[algorithm=%s, format=%s])",
   methodName, key.getAlgorithm(), key.getFormat());
}
origin: Tencent/tinker

private String getSignatureAlgorithm() throws Exception {
  InputStream is = null;
  try {
    is = new BufferedInputStream(new FileInputStream(config.mSignatureFile));
    KeyStore keyStore = KeyStore.getInstance("JKS");
    keyStore.load(is, config.mStorePass.toCharArray());
    Key key = keyStore.getKey(config.mStoreAlias, config.mKeyPass.toCharArray());
    String keyAlgorithm = key.getAlgorithm();
    String signatureAlgorithm;
    if (keyAlgorithm.equalsIgnoreCase("DSA")) {
      signatureAlgorithm = "SHA1withDSA";
    } else if (keyAlgorithm.equalsIgnoreCase("RSA")) {
      signatureAlgorithm = "SHA1withRSA";
    } else if (keyAlgorithm.equalsIgnoreCase("EC")) {
      signatureAlgorithm = "SHA1withECDSA";
    } else {
      throw new RuntimeException("private key is not a DSA or "
          + "RSA key");
    }
    return signatureAlgorithm;
  } finally {
    StreamUtil.closeQuietly(is);
  }
}
origin: wildfly/wildfly

public Key engineGetKey(final String alias, final char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException {
  try {
    final Key key = delegate.getKey(alias, password);
    return key instanceof SecretKey && "password".equals(key.getAlgorithm()) ? decoded((SecretKey) key) : key;
  } catch (KeyStoreException e) {
    throw new IllegalStateException(e);
  }
}
origin: wildfly/wildfly

private static String hmacToString(String methodName, Key key) {
 return String.format(
   "Hashing.%s(Key[algorithm=%s, format=%s])",
   methodName, key.getAlgorithm(), key.getFormat());
}
origin: wildfly/wildfly

  boolean isEqual(Key key) {
    return Objects.equals(key.getAlgorithm(), algorithm) && Objects.equals(key.getFormat(), format);
  }
}
origin: hierynomus/sshj

static boolean isECKeyWithFieldSize(Key key, int fieldSize) {
  return "ECDSA".equals(key.getAlgorithm())
      && fieldSizeFromKey((ECKey) key) == fieldSize;
}
origin: aws/aws-sdk-java

/**
 * @param kek
 *            the key encrypting key, which is either an AES key or a public
 *            key
 */
String getKeyWrapAlgorithm(Key kek) {
  String algorithm = kek.getAlgorithm();
  if (S3CryptoScheme.AES.equals(algorithm)) {
    return AESWrap;
  }
  if (S3CryptoScheme.RSA.equals(algorithm)) {
    if (CryptoRuntime.isRsaKeyWrapAvailable())
      return RSA_ECB_OAEPWithSHA256AndMGF1Padding;
  }
  return null;
}
origin: wildfly/wildfly

RawKey(Key original) {
  algorithm = original.getAlgorithm();
  format = original.getFormat();
  final byte[] encoded = original.getEncoded();
  this.encoded = encoded == null ? null : encoded.clone();
}
origin: apache/ignite

/**
 * @param key Cipher Key.
 * @param encMode Enc mode see {@link Cipher#ENCRYPT_MODE}, {@link Cipher#DECRYPT_MODE}, etc.
 */
public static Cipher createCipher(Key key, int encMode) {
  if (key == null)
    throw new IgniteException("Cipher Key cannot be null");
  try {
    Cipher cipher = Cipher.getInstance(key.getAlgorithm());
    cipher.init(encMode, key);
    return cipher;
  }
  catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
    throw new IgniteException(e);
  }
}
origin: jphp-group/jphp

  @Signature
  public String getAlgorithm() {
    return getWrappedObject().getAlgorithm();
  }
}
origin: SonarSource/sonarqube

@Test
public void loadSecretKeyFromFile_trim_content() throws Exception {
 URL resource = getClass().getResource("/org/sonar/api/config/AesCipherTest/non_trimmed_secret_key.txt");
 String path = new File(resource.toURI()).getCanonicalPath();
 AesCipher cipher = new AesCipher(null);
 Key secretKey = cipher.loadSecretFileFromFile(path);
 assertThat(secretKey.getAlgorithm()).isEqualTo("AES");
 assertThat(secretKey.getEncoded().length).isGreaterThan(10);
}
origin: SonarSource/sonarqube

@Test
public void loadSecretKeyFromFile() throws Exception {
 AesCipher cipher = new AesCipher(null);
 Key secretKey = cipher.loadSecretFileFromFile(pathToSecretKey());
 assertThat(secretKey.getAlgorithm()).isEqualTo("AES");
 assertThat(secretKey.getEncoded().length).isGreaterThan(10);
}
origin: SonarSource/sonarqube

@Test
public void loadSecretKeyFromFile_trim_content() throws Exception {
 String path = getPath("non_trimmed_secret_key.txt");
 AesCipher cipher = new AesCipher(null);
 Key secretKey = cipher.loadSecretFileFromFile(path);
 assertThat(secretKey.getAlgorithm()).isEqualTo("AES");
 assertThat(secretKey.getEncoded().length).isGreaterThan(10);
}
origin: SonarSource/sonarqube

@Test
public void loadSecretKeyFromFile() throws Exception {
 AesCipher cipher = new AesCipher(null);
 Key secretKey = cipher.loadSecretFileFromFile(pathToSecretKey());
 assertThat(secretKey.getAlgorithm()).isEqualTo("AES");
 assertThat(secretKey.getEncoded().length).isGreaterThan(10);
}
origin: apache/hbase

@Test
public void testTestProvider() {
 Configuration conf = HBaseConfiguration.create();
 conf.set(HConstants.CRYPTO_KEYPROVIDER_CONF_KEY, KeyProviderForTesting.class.getName());
 KeyProvider provider = Encryption.getKeyProvider(conf);
 assertNotNull("Null returned for provider", provider);
 assertTrue("Provider is not the expected type", provider instanceof KeyProviderForTesting);
 Key key = provider.getKey("foo");
 assertNotNull("Test provider did not return a key as expected", key);
 assertEquals("Test provider did not create a key for AES", "AES", key.getAlgorithm());
 assertEquals("Test provider did not create a key of adequate length", AES.KEY_LENGTH,
  key.getEncoded().length);
}
java.securityKeygetAlgorithm

Javadoc

Returns the name of the algorithm of this key. If the algorithm is unknown, null is returned.

Popular methods of Key

  • getEncoded
    Returns the key in its primary encoding format, or null if this key does not support encoding.
  • getFormat
    Returns the name of the primary encoding format of this key, or null if this key does not support en
  • <init>

Popular in Java

  • Reading from database using SQL prepared statement
  • putExtra (Intent)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • Path (java.nio.file)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Permission (java.security)
    Legacy security code; do not use.
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • CodeWhisperer alternatives
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