use of com.sun.identity.policy.ReferralTypeManager in project OpenAM by OpenRock.
the class PolicyModelImpl method getReferralSyntax.
/**
* Returns syntax for a referral.
*
* @param realmName Name of Realm.
* @param referralType Name of referral type.
* @return syntax for a referral.
*/
public Syntax getReferralSyntax(String realmName, String referralType) {
Syntax syntax = Syntax.NONE;
try {
PolicyManager policyMgr = getPolicyManager(realmName);
if (policyMgr != null) {
ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
Referral referral = referralTypeMgr.getReferral(referralType);
syntax = referral.getValueSyntax(getUserSSOToken());
}
} catch (SSOException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (NameNotFoundException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (PolicyException e) {
debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
} catch (AMConsoleException e) {
debug.warning("PolicyModelImpl.getReferralActionSchema", e);
}
return syntax;
}
use of com.sun.identity.policy.ReferralTypeManager in project OpenAM by OpenRock.
the class PrivilegeUtils method referralPrivilegeToPolicy.
public static Policy referralPrivilegeToPolicy(String realm, ReferralPrivilege referralPrivilege) throws PolicyException, SSOException, EntitlementException {
Policy policy = new Policy(referralPrivilege.getName(), referralPrivilege.getDescription(), true);
SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
javax.security.auth.Subject adminSubject = SubjectUtils.createSubject(adminToken);
PolicyManager pm = new PolicyManager(adminToken, realm);
ReferralTypeManager rm = pm.getReferralTypeManager();
policy.setCreatedBy(referralPrivilege.getCreatedBy());
policy.setCreationDate(referralPrivilege.getCreationDate());
policy.setLastModifiedBy(referralPrivilege.getLastModifiedBy());
policy.setLastModifiedDate(referralPrivilege.getLastModifiedDate());
int count = 1;
for (String r : referralPrivilege.getRealms()) {
Referral referral = rm.getReferral("SubOrgReferral");
Set<String> tmp = new HashSet<String>();
tmp.add(r);
referral.setValues(tmp);
policy.addReferral("referral" + count++, referral);
}
Map<String, Set<String>> map = referralPrivilege.getOriginalMapApplNameToResources();
count = 1;
String realmName = LDAPUtils.isDN(realm) ? DNMapper.orgNameToRealmName(realm) : realm;
for (String appName : map.keySet()) {
Set<String> res = map.get(appName);
Application application = ApplicationManager.getApplication(PolicyConstants.SUPER_ADMIN_SUBJECT, realmName, appName);
if (application == null) {
Object[] params = { appName, realm };
throw new EntitlementException(105, params);
}
String serviceName = application.getApplicationType().getName();
for (String r : res) {
Rule rule = new Rule("rule" + count++, serviceName, r, Collections.EMPTY_MAP);
rule.setApplicationName(appName);
policy.addRule(rule);
}
}
return policy;
}
Aggregations