}
//used from app client builder
public DefaultPrincipal buildDefaultPrincipal(XmlObject xmlObject) {
GerDefaultPrincipalType defaultPrincipalType = (GerDefaultPrincipalType) xmlObject;
DefaultPrincipal defaultPrincipal = new DefaultPrincipal();
if(defaultPrincipalType.isSetPrincipal()) {
defaultPrincipal.setPrincipal(buildPrincipal(defaultPrincipalType.getPrincipal()));
} else if(defaultPrincipalType.isSetLoginDomainPrincipal()) {
defaultPrincipal.setPrincipal(buildDomainPrincipal(defaultPrincipalType.getLoginDomainPrincipal()));
} else if(defaultPrincipalType.isSetRealmPrincipal()) {
defaultPrincipal.setPrincipal(buildRealmPrincipal(defaultPrincipalType.getRealmPrincipal()));
} else {
throw new IllegalStateException("default-principal does not contain a principal, login-domain-principal, or realm-principal");
}
GerNamedUsernamePasswordCredentialType[] namedCredentials = defaultPrincipalType.getNamedUsernamePasswordCredentialArray();
if (namedCredentials.length > 0) {
Set defaultCredentialSet = new HashSet();
for (int i = 0; i < namedCredentials.length; i++) {
GerNamedUsernamePasswordCredentialType namedCredentialType = namedCredentials[i];
NamedUsernamePasswordCredential namedCredential = new NamedUsernamePasswordCredential(namedCredentialType.getUsername().trim(), namedCredentialType.getPassword().trim().toCharArray(), namedCredentialType.getName().trim());
defaultCredentialSet.add(namedCredential);
}
defaultPrincipal.setNamedUserPasswordCredentials(defaultCredentialSet);
}
return defaultPrincipal;
}