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);
}
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);
}
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;
}
Aggregations