Search in sources :

Example 1 with LogicalSubject

use of com.sun.identity.entitlement.LogicalSubject 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);
}
Also used : EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) NoSubject(com.sun.identity.entitlement.NoSubject) LogicalSubject(com.sun.identity.entitlement.LogicalSubject)

Example 2 with LogicalSubject

use of com.sun.identity.entitlement.LogicalSubject 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!");
    }
}
Also used : EntitlementSubject(com.sun.identity.entitlement.EntitlementSubject) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) PolicySubject(com.sun.identity.entitlement.opensso.PolicySubject) NoSubject(com.sun.identity.entitlement.NoSubject) LogicalSubject(com.sun.identity.entitlement.LogicalSubject) HashSet(java.util.HashSet)

Aggregations

EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)2 LogicalSubject (com.sun.identity.entitlement.LogicalSubject)2 NoSubject (com.sun.identity.entitlement.NoSubject)2 PolicySubject (com.sun.identity.entitlement.opensso.PolicySubject)1 HashSet (java.util.HashSet)1 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)1