Search in sources :

Example 36 with Subject

use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.

the class PolicyModelImpl method getSubjectSyntax.

/**
     * Returns syntax for a subject.
     *
     * @param realmName Name of Realm.
     * @param subjectType Name of Subject type.
     * @return syntax for a subject.
     */
public Syntax getSubjectSyntax(String realmName, String subjectType) {
    Syntax syntax = Syntax.NONE;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            Subject subject = subjectTypeMgr.getSubject(subjectType);
            syntax = subject.getValueSyntax(getUserSSOToken());
        }
    } catch (SSOException e) {
        debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getActiveSubjectTypes", e);
    }
    return syntax;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) 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) Subject(com.sun.identity.policy.interfaces.Subject)

Example 37 with Subject

use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.

the class PolicyModelImpl method createSubject.

/**
     * Returns a subject object.
     *
     * @param realmName Name of Realm.
     * @param subjectType Name of subject type.
     * @param values Values of the subject.
     * @return subject object.
     * @throws AMConsoleException if subject cannot be created.
     */
public Subject createSubject(String realmName, String subjectType, Set values) throws AMConsoleException {
    Subject subject = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            subject = subjectTypeMgr.getSubject(subjectType);
            subject.setValues(values);
        }
    } catch (NameNotFoundException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (PolicyException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return subject;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Example 38 with Subject

use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.

the class PolicyModelImpl method getActiveSubjectTypes.

/**
     * Returns a map of active subject types for a realm to its display name.
     *
     * @param realmName Name of Realm.
     * @return a map of active subject types for a realm to its display name.
     */
public QueryResults getActiveSubjectTypes(String realmName) {
    Map subjectTypes = Collections.EMPTY_MAP;
    String strError = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            if (subjectTypeMgr != null) {
                Set types = subjectTypeMgr.getSelectedSubjectTypeNames();
                subjectTypes = new HashMap(types.size() * 2);
                for (Iterator iter = types.iterator(); iter.hasNext(); ) {
                    String rName = (String) iter.next();
                    try {
                        Subject subject = subjectTypeMgr.getSubject(rName);
                        if (subject != null) {
                            Syntax syntax = subject.getValueSyntax(getUserSSOToken());
                            if (!syntax.equals(Syntax.NONE)) {
                                subjectTypes.put(rName, subjectTypeMgr.getDisplayName(rName));
                            }
                        }
                    } catch (SSOException e) {
                        strError = getErrorString(e);
                    } catch (NameNotFoundException e) {
                        strError = getErrorString(e);
                    } catch (PolicyException e) {
                        strError = getErrorString(e);
                    }
                }
            }
        }
    } catch (AMConsoleException e) {
        debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (SSOException e) {
        debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (NameNotFoundException e) {
        debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
    } catch (PolicyException e) {
        debug.error("PolicyModelImpl.getActiveSubjectTypes", e);
    }
    return new QueryResults(subjectTypes, strError);
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) SSOException(com.iplanet.sso.SSOException) Subject(com.sun.identity.policy.interfaces.Subject) QueryResults(com.sun.identity.console.base.model.QueryResults) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) PolicyException(com.sun.identity.policy.PolicyException) Iterator(java.util.Iterator) Syntax(com.sun.identity.policy.Syntax) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 39 with Subject

use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.

the class PolicyModelImpl method getSubjectViewBeanURL.

/**
     * Returns properties view bean URL of a subject.
     *
     * @param realmName Name of realm.
     * @param subjectTypeName Name of Subject Type.
     * @return properties view bean URL of a subject.
     */
public String getSubjectViewBeanURL(String realmName, String subjectTypeName) {
    String url = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            Subject subject = subjectTypeMgr.getSubject(subjectTypeName);
            url = subjectTypeMgr.getViewBeanURL(subject);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getSubjectViewBeanURL", e);
    }
    return url;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Example 40 with Subject

use of com.sun.identity.policy.interfaces.Subject in project OpenAM by OpenRock.

the class PolicyManager method getPolicyUsingRealmSubject.

Policy getPolicyUsingRealmSubject(String subjectName) throws PolicyException, SSOException {
    Policy policy = null;
    Set policyNames = getPolicyNames();
    for (Iterator policyIter = policyNames.iterator(); policyIter.hasNext(); ) {
        String policyName = (String) policyIter.next();
        Policy p = getPolicy(policyName);
        Set subjectNames = p.getSubjectNames();
        if (subjectNames.contains(subjectName)) {
            Subject subject = p.getSubject(subjectName);
            if (subject instanceof SharedSubject) {
                policy = p;
                break;
            }
        }
    }
    return policy;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) Subject(com.sun.identity.policy.interfaces.Subject)

Aggregations

Subject (com.sun.identity.policy.interfaces.Subject)47 HashSet (java.util.HashSet)18 PolicyException (com.sun.identity.policy.PolicyException)17 SSOException (com.iplanet.sso.SSOException)14 Policy (com.sun.identity.policy.Policy)14 Set (java.util.Set)12 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)11 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)11 SubjectTypeManager (com.sun.identity.policy.SubjectTypeManager)11 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)8 Rule (com.sun.identity.policy.Rule)8 Iterator (java.util.Iterator)8 PolicyManager (com.sun.identity.policy.PolicyManager)7 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)6 AMException (com.iplanet.am.sdk.AMException)5 InvalidAuthContextException (com.sun.identity.authentication.internal.InvalidAuthContextException)5 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)5 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)5 SMSException (com.sun.identity.sm.SMSException)5 FileNotFoundException (java.io.FileNotFoundException)5