Search in sources :

Example 16 with ReferralPrivilege

use of com.sun.identity.entitlement.ReferralPrivilege in project OpenAM by OpenRock.

the class XACMLPrivilegeUtilsTest method shouldReturnXACMLPolicyWhenGivenValidReferralPrivilegeSet.

@Test
public void shouldReturnXACMLPolicyWhenGivenValidReferralPrivilegeSet() throws JSONException, EntitlementException {
    //Given
    ReferralPrivilege referralPrivilege = createArbitraryReferralPrivilege("ReferralPrivilege1", now);
    //When
    Policy policy = XACMLPrivilegeUtils.referralToPolicy(referralPrivilege);
    //Then
    assertPolicyContentMatchesReferralPrivilegeContent(policy, referralPrivilege);
}
Also used : Policy(com.sun.identity.entitlement.xacml3.core.Policy) ReferralPrivilege(com.sun.identity.entitlement.ReferralPrivilege) Test(org.testng.annotations.Test)

Example 17 with ReferralPrivilege

use of com.sun.identity.entitlement.ReferralPrivilege in project OpenAM by OpenRock.

the class XACMLPrivilegeUtilsTest method shouldResultInEquivalentReferralPrivilegeWhenValidReferralPrivilegeSerializedToXACMLThenDeserialized.

@Test
public void shouldResultInEquivalentReferralPrivilegeWhenValidReferralPrivilegeSerializedToXACMLThenDeserialized() throws JSONException, EntitlementException {
    //Given
    ReferralPrivilege referralPrivilege = createArbitraryReferralPrivilege("ReferralPrivilege1", now);
    Policy policy = XACMLPrivilegeUtils.referralToPolicy(referralPrivilege);
    ReferralPrivilege deserializedReferralPrivilege = null;
    //When
    deserializedReferralPrivilege = XACMLPrivilegeUtils.policyToReferral(policy);
    //Then
    assertReferralPrivilegesEquivalent(deserializedReferralPrivilege, referralPrivilege);
}
Also used : Policy(com.sun.identity.entitlement.xacml3.core.Policy) ReferralPrivilege(com.sun.identity.entitlement.ReferralPrivilege) Test(org.testng.annotations.Test)

Example 18 with ReferralPrivilege

use of com.sun.identity.entitlement.ReferralPrivilege in project OpenAM by OpenRock.

the class DataStore method searchReferrals.

public Set<ReferralPrivilege> searchReferrals(SSOToken adminToken, String realm, String filter) throws EntitlementException {
    Set<ReferralPrivilege> results = new HashSet<ReferralPrivilege>();
    String baseDN = getSearchBaseDN(realm, REFERRAL_STORE);
    if (SMSEntry.checkIfEntryExists(baseDN, adminToken)) {
        try {
            Iterator i = SMSEntry.search(adminToken, baseDN, filter, NO_LIMIT, NO_LIMIT, NOT_SORTED, NOT_SORTED, NO_EXCLUSIONS);
            while (i.hasNext()) {
                SMSDataEntry e = (SMSDataEntry) i.next();
                ReferralPrivilege referral = ReferralPrivilege.getInstance(new JSONObject(e.getAttributeValue(SERIALIZABLE_INDEX_KEY)));
                results.add(referral);
            }
        } catch (JSONException e) {
            Object[] arg = { baseDN };
            throw new EntitlementException(52, arg, e);
        } catch (SMSException e) {
            Object[] arg = { baseDN };
            throw new EntitlementException(52, arg, e);
        }
    }
    return results;
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) ReferralPrivilege(com.sun.identity.entitlement.ReferralPrivilege) JSONObject(org.json.JSONObject) SMSDataEntry(com.sun.identity.sm.SMSDataEntry) SMSException(com.sun.identity.sm.SMSException) BufferedIterator(com.sun.identity.shared.BufferedIterator) Iterator(java.util.Iterator) JSONException(org.json.JSONException) HashSet(java.util.HashSet)

Aggregations

ReferralPrivilege (com.sun.identity.entitlement.ReferralPrivilege)18 HashSet (java.util.HashSet)9 Set (java.util.Set)7 Test (org.testng.annotations.Test)6 EntitlementException (com.sun.identity.entitlement.EntitlementException)5 SMSException (com.sun.identity.sm.SMSException)5 SSOToken (com.iplanet.sso.SSOToken)4 Policy (com.sun.identity.entitlement.xacml3.core.Policy)4 PolicySet (com.sun.identity.entitlement.xacml3.core.PolicySet)4 IPrivilege (com.sun.identity.entitlement.IPrivilege)3 Privilege (com.sun.identity.entitlement.Privilege)3 BufferedIterator (com.sun.identity.shared.BufferedIterator)3 HashMap (java.util.HashMap)3 JSONException (org.json.JSONException)3 JSONObject (org.json.JSONObject)3 SSOException (com.iplanet.sso.SSOException)2 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)2 FactoryMethods.createArbitraryPrivilege (com.sun.identity.entitlement.xacml3.FactoryMethods.createArbitraryPrivilege)2 FactoryMethods.createArbitraryReferralPrivilege (com.sun.identity.entitlement.xacml3.FactoryMethods.createArbitraryReferralPrivilege)2 ImportStep (com.sun.identity.entitlement.xacml3.XACMLExportImport.ImportStep)2