if (upCreds != null) {
user.setDistinguishedName(userProps.returnNewUserDN(upCreds.getUsername()));
}
if (upCreds == null) {
throw new CredentialPolicyException("The credentials were not supplied.");
} else if (user.getDistinguishedName().length() == 0) {
throw new CredentialPolicyException("The supplied username is invalid.");
} else if ((upCreds.getPassword() == null) || (upCreds.getPassword().length() == 0)) {
throw new CredentialPolicyException("The supplied password is invalid.");
}
// prepare attributes and add the new user to LDAP
Attributes attributes = prepareRegistrationAttributes(upCreds,user.getProfile());
addEntry(dirContext,user.getDistinguishedName(),attributes);