public ClaimConfigurationDTO[] getProfileConfiguration(String dialect, String profileConfig)
throws ProfileManagementException {
UserRealm realm = null;
ProfileConfigurationManager profileManager = null;
ClaimManager claimManager = null;
ProfileConfiguration profileConfiguration = null;
ClaimConfigurationDTO claim = null;
List<ClaimConfigurationDTO> claimList = null;
List<String> hiddenClaims = null;
List<String> overriddenClaims = null;
List<String> inheritedClaims = null;
Claim[] definedClaims = null;
List<String> definedClaimsList = null;
validateInputParameters(new String[] { dialect, profileConfig });
try {
realm = getRealm();
profileManager = realm.getProfileConfigurationManager();
if (profileManager == null) {
String message = "No profile configurations defined";
if (log.isDebugEnabled()) {
log.debug(message);
}
return null;
}
claimManager = realm.getClaimManager();
if (claimManager == null) {
String message = "No claim configurations defined";
if (log.isDebugEnabled()) {
log.debug(message);
}
throw new ProfileManagementException(message);
}
definedClaimsList = new ArrayList<String>();
definedClaims = (Claim[]) claimManager.getAllClaims(dialect);
for (int i = 0; i < definedClaims.length; i++) {
definedClaimsList.add(definedClaims[i].getClaimUri());
}
profileConfiguration = (ProfileConfiguration) profileManager.getProfileConfig(profileConfig);
// A container for all the claims applicable to the current profile
// configuration.
claimList = new ArrayList<ClaimConfigurationDTO>();
hiddenClaims = profileConfiguration.getHiddenClaims();
if (hiddenClaims != null) {
for (Iterator<String> iter = hiddenClaims.iterator(); iter.hasNext();) {
String string = iter.next();
claim = new ClaimConfigurationDTO();
claim.setClaimUri(string);
claim.setBehavior(UserCoreConstants.CLAIM_HIDDEN);
if (definedClaimsList.contains(string)) {
// If this claim being removed, then we are not going
// add this.
claimList.add(claim);
definedClaimsList.remove(string);
}
}
}
overriddenClaims = profileConfiguration.getOverriddenClaims();
if (overriddenClaims != null) {
for (Iterator<String> iter = overriddenClaims.iterator(); iter.hasNext();) {
String string = iter.next();
claim = new ClaimConfigurationDTO();
claim.setClaimUri(string);
claim.setBehavior(UserCoreConstants.CLAIM_OVERRIDEN);
if (definedClaimsList.contains(string)) {
// If this claim being removed, then we are not going
// add this.
claimList.add(claim);
definedClaimsList.remove(string);
}
}
}
inheritedClaims = profileConfiguration.getInheritedClaims();
if (inheritedClaims != null) {
for (Iterator<String> iter = inheritedClaims.iterator(); iter.hasNext();) {
String string = iter.next();
claim = new ClaimConfigurationDTO();