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 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; }
/** * Sets the {@link EncryptionType} value * * @param eType the {@link EncryptionType} value to store */ public void setEType(EncryptionType eType) { setFieldAsInt(EncryptedDataField.ETYPE, eType.getValue()); }
/** * Sets the {@link EncryptionType} value * * @param eType the {@link EncryptionType} value to store */ public void setEType(EncryptionType eType) { setFieldAsInt(EncryptedDataField.ETYPE, eType.getValue()); }
public int getEType() { return key.getKeyType().getValue(); }
public int getEType() { return key.getKeyType().getValue(); }
public void setKeyType(EncryptionType keyType) { setFieldAsInt(EncryptionKeyField.KEY_TYPE, keyType.getValue()); }
public void setKeyType(EncryptionType keyType) { setFieldAsInt(EncryptionKeyField.KEY_TYPE, keyType.getValue()); }
public void setEtypes(List<EncryptionType> etypes) { List<Integer> values = new ArrayList<>(); for (EncryptionType etype: etypes) { values.add(etype.getValue()); } KrbIntegers value = new KrbIntegers(values); setFieldAs(KdcReqBodyField.ETYPE, value); }
public void setEtypes(List<EncryptionType> etypes) { List<Integer> values = new ArrayList<>(); for (EncryptionType etype: etypes) { values.add(etype.getValue()); } KrbIntegers value = new KrbIntegers(values); setFieldAs(KdcReqBodyField.ETYPE, value); }
KeysInfo(KrbIdentity identity) throws KrbException { Map<EncryptionType, EncryptionKey> keymap = identity.getKeys(); this.etypes = new String[keymap.size()]; this.keys = new byte[keymap.size()][]; this.kvnos = new String[keymap.size()]; int i = 0; for (Map.Entry<EncryptionType, EncryptionKey> entryKey : keymap.entrySet()) { etypes[i] = entryKey.getKey().getValue() + ""; try { keys[i] = entryKey.getValue().encode(); } catch (IOException e) { throw new KrbException("encode key failed", e); } kvnos[i] = entryKey.getValue().getKvno() + ""; i++; } }
KeysInfo(KrbIdentity identity) throws KrbException { Map<EncryptionType, EncryptionKey> keymap = identity.getKeys(); this.etypes = new String[keymap.size()]; this.keys = new byte[keymap.size()][]; this.kvnos = new String[keymap.size()]; int i = 0; for (Map.Entry<EncryptionType, EncryptionKey> entryKey : keymap.entrySet()) { etypes[i] = entryKey.getKey().getValue() + ""; try { keys[i] = entryKey.getValue().encode(); } catch (IOException e) { throw new KrbException("encode key failed", e); } kvnos[i] = entryKey.getValue().getKvno() + ""; i++; } }
@Override public void writeKey(EncryptionKey key, int version) throws IOException { writeShort(key.getKeyType().getValue()); writeCountedOctets(key.getKeyData()); }
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); }
@Override public void writeKey(EncryptionKey key, int version) throws IOException { writeShort(key.getKeyType().getValue()); writeCountedOctets(key.getKeyData()); }
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); }
@Override public EncryptionKey getKey(PrincipalName principal, EncryptionType keyType) { List<KeytabEntry> entries = getKeytabEntries(principal); for (KeytabEntry ke : entries) { if (ke.getKey().getKeyType() == keyType) { return ke.getKey(); } } // Maybe we have a key stored under a different name for the same type int keyTypeValue = keyType.getValue(); for (KeytabEntry ke : entries) { if (keyTypeValue == ke.getKey().getKeyType().getValue()) { return ke.getKey(); } } return null; }
@Override public EncryptionKey getKey(PrincipalName principal, EncryptionType keyType) { List<KeytabEntry> entries = getKeytabEntries(principal); for (KeytabEntry ke : entries) { if (ke.getKey().getKeyType() == keyType) { return ke.getKey(); } } // Maybe we have a key stored under a different name for the same type int keyTypeValue = keyType.getValue(); for (KeytabEntry ke : entries) { if (keyTypeValue == ke.getKey().getKeyType().getValue()) { return ke.getKey(); } } return null; }