use of com.sun.identity.entitlement.NoSubject in project OpenAM by OpenRock.
the class PolicyConditionUpgrader method isSubjectConditionUpgradable.
private boolean isSubjectConditionUpgradable(EntitlementSubject subject) {
if (subject == null) {
return true;
}
if (subject instanceof NoSubject) {
return true;
}
if (subject instanceof LogicalSubject) {
LogicalSubject logicalSubject = (LogicalSubject) subject;
boolean upgradable = true;
for (EntitlementSubject sub : logicalSubject.getESubjects()) {
upgradable &= isUpgradablePolicySubject(sub);
}
return upgradable;
}
return isUpgradablePolicySubject(subject);
}
use of com.sun.identity.entitlement.NoSubject in project OpenAM by OpenRock.
the class PolicyConditionUpgrader method migrateSubjectConditions.
private void migrateSubjectConditions(Privilege privilege, MigrationReport migrationReport) throws UpgradeException, EntitlementException {
if (privilege.getSubject() == null) {
return;
}
if (privilege.getSubject() instanceof NoSubject) {
return;
}
if (privilege.getSubject() instanceof LogicalSubject) {
LogicalSubject logicalSubject = (LogicalSubject) privilege.getSubject();
Set<EntitlementSubject> subjects = logicalSubject.getESubjects();
Set<EntitlementSubject> migratedSubjects = new HashSet<EntitlementSubject>();
for (EntitlementSubject subject : subjects) {
if (subject instanceof NoSubject) {
//pass this through directly
migratedSubjects.add(subject);
} else if (!(subject instanceof PolicySubject)) {
//This should never happen due to check in initialise
throw new UpgradeException("Cannot upgrade a subject condition that is not of PolicySubject type!");
} else {
migratedSubjects.add(migrateSubjectCondition((PolicySubject) subject, migrationReport));
}
}
logicalSubject.setESubjects(migratedSubjects);
} else if (privilege.getSubject() instanceof PolicySubject) {
privilege.setSubject(migrateSubjectCondition((PolicySubject) privilege.getSubject(), migrationReport));
} else {
//This should never happen due to check in initialise
throw new UpgradeException("Cannot upgrade a subject condition that is not of PolicySubject type!");
}
}
Aggregations