Search in sources :

Example 6 with ReferralTypeManager

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;
}
Also used : ReferralTypeManager(com.sun.identity.policy.ReferralTypeManager) PolicyManager(com.sun.identity.policy.PolicyManager) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) Syntax(com.sun.identity.policy.Syntax) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 7 with ReferralTypeManager

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;
}
Also used : Policy(com.sun.identity.policy.Policy) ReferralTypeManager(com.sun.identity.policy.ReferralTypeManager) PolicyManager(com.sun.identity.policy.PolicyManager) SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) Set(java.util.Set) EntitlementException(com.sun.identity.entitlement.EntitlementException) Referral(com.sun.identity.policy.interfaces.Referral) Rule(com.sun.identity.policy.Rule) Application(com.sun.identity.entitlement.Application) HashSet(java.util.HashSet)

Aggregations

PolicyManager (com.sun.identity.policy.PolicyManager)7 ReferralTypeManager (com.sun.identity.policy.ReferralTypeManager)7 Referral (com.sun.identity.policy.interfaces.Referral)7 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)6 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)6 PolicyException (com.sun.identity.policy.PolicyException)6 SSOException (com.iplanet.sso.SSOException)3 Syntax (com.sun.identity.policy.Syntax)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 Set (java.util.Set)2 SSOToken (com.iplanet.sso.SSOToken)1 Application (com.sun.identity.entitlement.Application)1 EntitlementException (com.sun.identity.entitlement.EntitlementException)1 Policy (com.sun.identity.policy.Policy)1 Rule (com.sun.identity.policy.Rule)1 ValidValues (com.sun.identity.policy.ValidValues)1 Locale (java.util.Locale)1