* @return the entry for the principal
* @throws Exception if there are any access problems
*/
private PrincipalStoreEntry getEntry( Entry entry ) throws Exception
{
PrincipalStoreEntryModifier modifier = new PrincipalStoreEntryModifier();
modifier.setDistinguishedName( entry.getDn().getName() );
String principal = entry.get( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ).getString();
modifier.setPrincipal( new KerberosPrincipal( principal, PrincipalNameType.KRB_NT_PRINCIPAL.getValue() ) );
String keyVersionNumber = entry.get( KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT ).getString();
modifier.setKeyVersionNumber( Integer.parseInt( keyVersionNumber ) );
if ( entry.get( KerberosAttribute.KRB5_ACCOUNT_DISABLED_AT ) != null )
{
String val = entry.get( KerberosAttribute.KRB5_ACCOUNT_DISABLED_AT ).getString();
modifier.setDisabled( "true".equalsIgnoreCase( val ) );
}
if ( entry.get( KerberosAttribute.KRB5_ACCOUNT_LOCKEDOUT_AT ) != null )
{
String val = entry.get( KerberosAttribute.KRB5_ACCOUNT_LOCKEDOUT_AT ).getString();
modifier.setLockedOut( "true".equalsIgnoreCase( val ) );
}
if ( entry.get( KerberosAttribute.KRB5_ACCOUNT_EXPIRATION_TIME_AT ) != null )
{
String val = entry.get( KerberosAttribute.KRB5_ACCOUNT_EXPIRATION_TIME_AT ).getString();
try
{
modifier.setExpiration( KerberosTime.getTime( val ) );
}
catch ( ParseException e )
{
throw new Exception( "Account expiration attribute "
+ KerberosAttribute.KRB5_ACCOUNT_EXPIRATION_TIME_AT
+ " contained an invalid value for generalizedTime: "
+ val );
}
}
if ( entry.get( KerberosAttribute.APACHE_SAM_TYPE_AT ) != null )
{
String samType = entry.get( KerberosAttribute.APACHE_SAM_TYPE_AT ).getString();
modifier.setSamType( SamType.getTypeByOrdinal( Integer.parseInt( samType ) ) );
}
if ( entry.get( KerberosAttribute.KRB5_KEY_AT ) != null )
{
Attribute krb5key = entry.get( KerberosAttribute.KRB5_KEY_AT );
try
{
Map<EncryptionType, EncryptionKey> keyMap = modifier.reconstituteKeyMap( krb5key );
modifier.setKeyMap( keyMap );
}
catch ( KerberosException ioe )
{
throw new Exception( I18n.err( I18n.ERR_623, KerberosAttribute.KRB5_KEY_AT ) );
}
}
return modifier.getEntry();
}