Search in sources :

Example 11 with SubjectTypeManager

use of com.sun.identity.policy.SubjectTypeManager 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 12 with SubjectTypeManager

use of com.sun.identity.policy.SubjectTypeManager 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 13 with SubjectTypeManager

use of com.sun.identity.policy.SubjectTypeManager 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 14 with SubjectTypeManager

use of com.sun.identity.policy.SubjectTypeManager 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 15 with SubjectTypeManager

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

the class PolicyModelImpl method getSubjectTypeName.

/**
     * Returns subject type name of a subject.
     *
     * @param realmName Name of realm.
     * @param subject Subject instance.
     * @return subject type name of a subject.
     */
public String getSubjectTypeName(String realmName, Subject subject) {
    String typeName = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            SubjectTypeManager subjectTypeMgr = policyMgr.getSubjectTypeManager();
            typeName = subjectTypeMgr.getSubjectTypeName(subject);
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getSubjectTypeName", e);
    }
    return typeName;
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) SubjectTypeManager(com.sun.identity.policy.SubjectTypeManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

SubjectTypeManager (com.sun.identity.policy.SubjectTypeManager)15 Subject (com.sun.identity.policy.interfaces.Subject)11 PolicyManager (com.sun.identity.policy.PolicyManager)10 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)8 PolicyException (com.sun.identity.policy.PolicyException)7 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)6 HashSet (java.util.HashSet)6 SSOException (com.iplanet.sso.SSOException)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Set (java.util.Set)3 Policy (com.sun.identity.policy.Policy)2 Syntax (com.sun.identity.policy.Syntax)2 Iterator (java.util.Iterator)2 AMException (com.iplanet.am.sdk.AMException)1 InvalidAuthContextException (com.sun.identity.authentication.internal.InvalidAuthContextException)1 ConfigurationException (com.sun.identity.common.configuration.ConfigurationException)1 UnknownPropertyNameException (com.sun.identity.common.configuration.UnknownPropertyNameException)1 QueryResults (com.sun.identity.console.base.model.QueryResults)1 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)1