core/src/main/java/com/orientechnologies/orient/core/security/symmetrickey/OSymmetricKey.java
public static OSymmetricKey fromKeystore(final InputStream is, final String password, final String keyAlias,
      final String keyPassword) {
    OSymmetricKey sk = null;

    try {
      KeyStore ks = KeyStore.getInstance("JCEKS"); // JCEKS is required to hold SecretKey entries.

      char[] ksPasswdChars = null;

      if (password != null)
        ksPasswdChars = password.toCharArray();

      ks.load(is, ksPasswdChars); // ksPasswdChars may be null.

      char[] ksKeyPasswdChars = null;

      if (keyPassword != null)
        ksKeyPasswdChars = keyPassword.toCharArray();

      KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(ksKeyPasswdChars); // ksKeyPasswdChars may be null.

      KeyStore.SecretKeyEntry skEntry = (KeyStore.SecretKeyEntry) ks.getEntry(keyAlias, protParam);

      if (skEntry == null)
        throw new OSecurityException("SecretKeyEntry is null for key alias: " + keyAlias);

      SecretKey secretKey = skEntry.getSecretKey();

      sk = new OSymmetricKey(secretKey);
    } catch (Exception ex) {
      throw OException.wrapException(new OSecurityException("OSymmetricKey.fromKeystore() Exception: " + ex.getMessage()), ex);
    }

    return sk;
  }
public static OSymmetricKey fromKeystore(final InputStream is, final String password, final String keyAlias,
      final String keyPassword) {
    OSymmetricKey sk = null;

    try {
      KeyStore ks = KeyStore.getInstance("JCEKS"); // JCEKS is required to hold SecretKey entries.

      char[] ksPasswdChars = null;

      if (password != null)
        ksPasswdChars = password.toCharArray();

      ks.load(is, ksPasswdChars); // ksPasswdChars may be null.

      char[] ksKeyPasswdChars = null;

      if (keyPassword != null)
        ksKeyPasswdChars = keyPassword.toCharArray();

      KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(ksKeyPasswdChars); // ksKeyPasswdChars may be null.

      KeyStore.SecretKeyEntry skEntry = (KeyStore.SecretKeyEntry) ks.getEntry(keyAlias, protParam);

      if (skEntry == null)
        throw new OSecurityException("SecretKeyEntry is null for key alias: " + keyAlias);

      SecretKey secretKey = skEntry.getSecretKey();

      sk = new OSymmetricKey(secretKey);
    } catch (Exception ex) {
      throw OException.wrapException(new OSecurityException("OSymmetricKey.fromKeystore() Exception: " + ex.getMessage()), ex);
    }

    return sk;
  }
Creates an OSymmetricKey from a Java "JCEKS" KeyStore.

@param is          The InputStream used to load the KeyStore.
@param password    The password for the KeyStore.  May be null.
@param keyAlias    The alias name of the key to be used from the KeyStore.  Required.
@param keyPassword The password of the key represented by keyAlias.  May be null.