public static EncryptionType getBestEncryptionType(List<EncryptionType> requestedTypes, List<EncryptionType> configuredTypes) { for (EncryptionType configuredType : configuredTypes) { if (requestedTypes.contains(configuredType)) { return configuredType; } } // Maybe we have a different encryption name configured for the same type for (EncryptionType configuredType : configuredTypes) { int configuredTypeValue = configuredType.getValue(); for (EncryptionType requestedType : requestedTypes) { if (configuredTypeValue == requestedType.getValue()) { return requestedType; } } } return null; }
public static String getAlgoNameFromEncType(EncryptionType encType) { String cipherName = encType.getName().toLowerCase(); for (Map.Entry<String, String> entry : CIPHER_ALGO_MAP.entrySet()) { if (cipherName.startsWith(entry.getKey())) { return entry.getValue(); } } throw new IllegalArgumentException("Unknown algorithm name for the encryption type " + encType); }
/** * Get the encryption type. * @param eType The encryption type string. * @return The EncryptionType * @throws KrbException e */ public static EncryptionType getEncryptionType(String eType) throws KrbException { return EncryptionType.fromName(eType); }
protected void testGet(IdentityBackend backend) throws KrbException { KrbIdentity kid = BackendTestUtil.createOneIdentity(TEST_PRINCIPAL); backend.addIdentity(kid); // clear the identity cache. backend.release(); KrbIdentity identity = backend.getIdentity(TEST_PRINCIPAL); assertThat(identity).isNotNull(); assertThat(identity.getExpireTime()).isEqualTo(kid.getExpireTime()); assertThat(identity.isDisabled()).isEqualTo(kid.isDisabled()); assertThat(identity.getKeyVersion()).isEqualTo(kid.getKeyVersion()); for (EncryptionKey expectedKey : kid.getKeys().values()) { EncryptionType actualType = EncryptionType.fromValue(expectedKey.getKeyType().getValue()); EncryptionKey actualKey = identity.getKey(actualType); assertThat(actualKey.getKeyType().getValue()).isEqualTo(expectedKey.getKeyType().getValue()); assertThat(actualKey.getKeyData()).isEqualTo(expectedKey.getKeyData()); assertThat(actualKey.getKvno()).isEqualTo(expectedKey.getKvno()); } //tearDown backend.deleteIdentity(TEST_PRINCIPAL); }
public EncryptionKey(int keyType, byte[] keyData, int kvno) { this(EncryptionType.fromValue(keyType), keyData, kvno); }
@Override public String displayName() { return eType().getDisplayName(); }
protected void testGet(IdentityBackend backend) throws KrbException { KrbIdentity kid = BackendTestUtil.createOneIdentity(TEST_PRINCIPAL); backend.addIdentity(kid); // clear the identity cache. backend.release(); KrbIdentity identity = backend.getIdentity(TEST_PRINCIPAL); assertThat(identity).isNotNull(); assertThat(identity.getExpireTime()).isEqualTo(kid.getExpireTime()); assertThat(identity.isDisabled()).isEqualTo(kid.isDisabled()); assertThat(identity.getKeyVersion()).isEqualTo(kid.getKeyVersion()); for (EncryptionKey expectedKey : kid.getKeys().values()) { EncryptionType actualType = EncryptionType.fromValue(expectedKey.getKeyType().getValue()); EncryptionKey actualKey = identity.getKey(actualType); assertThat(actualKey.getKeyType().getValue()).isEqualTo(expectedKey.getKeyType().getValue()); assertThat(actualKey.getKeyData()).isEqualTo(expectedKey.getKeyData()); assertThat(actualKey.getKvno()).isEqualTo(expectedKey.getKvno()); } //tearDown backend.deleteIdentity(TEST_PRINCIPAL); }
public EncryptionKey(int keyType, byte[] keyData, int kvno) { this(EncryptionType.fromValue(keyType), keyData, kvno); }
@Override public String displayName() { return eType().getDisplayName(); }
public static EncryptionType getBestEncryptionType(List<EncryptionType> requestedTypes, List<EncryptionType> configuredTypes) { for (EncryptionType configuredType : configuredTypes) { if (requestedTypes.contains(configuredType)) { return configuredType; } } // Maybe we have a different encryption name configured for the same type for (EncryptionType configuredType : configuredTypes) { int configuredTypeValue = configuredType.getValue(); for (EncryptionType requestedType : requestedTypes) { if (configuredTypeValue == requestedType.getValue()) { return requestedType; } } } return null; }
public static String getAlgoNameFromEncType(EncryptionType encType) { String cipherName = encType.getName().toLowerCase(); for (Map.Entry<String, String> entry : CIPHER_ALGO_MAP.entrySet()) { if (cipherName.startsWith(entry.getKey())) { return entry.getValue(); } } throw new IllegalArgumentException("Unknown algorithm name for the encryption type " + encType); }
/** * Get the encryption handler. * * @param eType The encryption type int * @return The EncTypeHandler * @throws KrbException e */ public static EncTypeHandler getEncHandler(int eType) throws KrbException { EncryptionType eTypeEnum = EncryptionType.fromValue(eType); return getEncHandler(eTypeEnum); }
/** * Get the encryption type. * @param eType The encryption type string. * @return The EncryptionType * @throws KrbException e */ public static EncryptionType getEncryptionType(String eType) throws KrbException { return EncryptionType.fromName(eType); }
public GssEncryptor(EncryptionKey key) throws GSSException { encKey = key; encKeyBytes = encKey.getKeyData(); encKeyType = key.getKeyType(); if (encKeyType == EncryptionType.AES128_CTS_HMAC_SHA1_96) { checkSumSize = 12; checkSumTypeDef = CheckSumType.HMAC_SHA1_96_AES128; isV2 = true; } else if (encKeyType == EncryptionType.AES256_CTS_HMAC_SHA1_96) { checkSumSize = 12; checkSumTypeDef = CheckSumType.HMAC_SHA1_96_AES256; isV2 = true; } else if (encKeyType == EncryptionType.DES_CBC_CRC || encKeyType == EncryptionType.DES_CBC_MD5) { sgnAlg = GssTokenV1.SGN_ALG_DES_MAC_MD5; sealAlg = GssTokenV1.SEAL_ALG_DES; checkSumSize = 8; } else if (encKeyType == EncryptionType.DES3_CBC_SHA1) { sgnAlg = GssTokenV1.SGN_ALG_HMAC_SHA1_DES3_KD; sealAlg = GssTokenV1.SEAL_ALG_DES3_KD; checkSumSize = 20; } else if (encKeyType == EncryptionType.ARCFOUR_HMAC) { sgnAlg = GssTokenV1.SGN_ALG_RC4_HMAC; sealAlg = GssTokenV1.SEAL_ALG_RC4_HMAC; checkSumSize = 16; isArcFourHmac = true; } else { throw new GSSException(GSSException.FAILURE, -1, "Invalid encryption type: " + encKeyType.getDisplayName()); } }
/** * Sets the {@link EncryptionType} value * * @param eType the {@link EncryptionType} value to store */ public void setEType(EncryptionType eType) { setFieldAsInt(EncryptedDataField.ETYPE, eType.getValue()); }
@Override public String name() { return eType().getName(); }
/** * @return The {@link EncryptionType} of this instance */ public EncryptionType getEType() { Integer value = getFieldAsInteger(EncryptedDataField.ETYPE); return EncryptionType.fromValue(value); }
protected List<EncryptionType> getEncryptionTypes(List<String> encTypeNames) { List<EncryptionType> results = new ArrayList<>(encTypeNames.size()); for (String eTypeName : encTypeNames) { EncryptionType eType = EncryptionType.fromName(eTypeName); if (eType != EncryptionType.NONE) { results.add(eType); } } return results; }