/** * Set the NameType field of this PrincipalName * * @param nameType The NameType to store */ public void setNameType(NameType nameType) { setFieldAsInt(PrincipalNameField.NAME_TYPE, nameType.getValue()); }
/** * Set the NameType field of this PrincipalName * * @param nameType The NameType to store */ public void setNameType(NameType nameType) { setFieldAsInt(PrincipalNameField.NAME_TYPE, nameType.getValue()); }
/** * Get the NameType associated with a value. * * @param value The integer value of the NameType we are looking for * @return The associated NameType, or NT_UNKNOWN if not found or if value is null */ public static NameType fromValue(Integer value) { if (value != null) { for (NameType nameType : values()) { if (nameType.getValue() == value) { return nameType; } } } return NT_UNKNOWN; } }
/** * Get the NameType associated with a value. * * @param value The integer value of the NameType we are looking for * @return The associated NameType, or NT_UNKNOWN if not found or if value is null */ public static NameType fromValue(Integer value) { if (value != null) { for (NameType nameType : values()) { if (nameType.getValue() == value) { return nameType; } } } return NT_UNKNOWN; } }
public EncryptionKey getEncryptionKey(int encryptType, int kvno) { if (kerberosKeySet != null) { KerberosKey[] keys = kerberosKeySet.toArray(new KerberosKey[kerberosKeySet.size()]); // We don't check the kvno here - see DIRKRB-638 return GssUtil.getEncryptionKey(keys, encryptType); } // Otherwise get it from the keytab KerberosPrincipal princ = new KerberosPrincipal(name.getPrincipalName().getName(), name.getPrincipalName().getNameType().getValue()); KerberosKey[] keys = keyTab.getKeys(princ); return GssUtil.getEncryptionKey(keys, encryptType, kvno); } }
public void writePrincipal(PrincipalName principal, int version) throws IOException { List<String> nameStrings = principal.getNameStrings(); int numComponents = principal.getNameStrings().size(); String realm = principal.getRealm(); writeShort(numComponents); writeCountedString(realm); for (String nameCom : nameStrings) { writeCountedString(nameCom); } writeInt(principal.getNameType().getValue()); // todo: consider the version }
public void writePrincipal(PrincipalName principal, int version) throws IOException { List<String> nameStrings = principal.getNameStrings(); int numComponents = principal.getNameStrings().size(); String realm = principal.getRealm(); writeShort(numComponents); writeCountedString(realm); for (String nameCom : nameStrings) { writeCountedString(nameCom); } writeInt(principal.getNameType().getValue()); // todo: consider the version }
@Override public void writePrincipal(PrincipalName principal, int version) throws IOException { List<String> nameComponents = principal.getNameStrings(); if (version != CredentialCache.FCC_FVNO_1) { writeInt(principal.getNameType().getValue()); } int numComponents = nameComponents.size(); if (version == CredentialCache.FCC_FVNO_1) { numComponents++; } writeInt(numComponents); writeRealm(principal.getRealm()); for (String nameCom : nameComponents) { writeCountedString(nameCom); } }
@Override public void writePrincipal(PrincipalName principal, int version) throws IOException { List<String> nameComponents = principal.getNameStrings(); if (version != CredentialCache.FCC_FVNO_1) { writeInt(principal.getNameType().getValue()); } int numComponents = nameComponents.size(); if (version == CredentialCache.FCC_FVNO_1) { numComponents++; } writeInt(numComponents); writeRealm(principal.getRealm()); for (String nameCom : nameComponents) { writeCountedString(nameCom); } }
private static KeyTab getKeyTab(GssNameElement name) throws GSSException { if (name == null) { return CredUtils.getKeyTabFromContext(null); } else { KerberosPrincipal princ = new KerberosPrincipal(name.getPrincipalName().getName(), name.getPrincipalName().getNameType().getValue()); return CredUtils.getKeyTabFromContext(princ); } }
KerberosPrincipal server = new KerberosPrincipal(serverName, serverPrinc.getNameType().getValue());