Search in sources :

Example 6 with Syntax

use of com.sun.identity.policy.Syntax 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 Syntax

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

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

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

the class PolicyPropertyXMLBuilderBase method buildXML.

private void buildXML(String name, StringBuffer xml) {
    Syntax syntax = getPropertySyntax(name);
    String tagClassName = getTagClassName(syntax);
    if (tagClassName != null) {
        xml.append(PROPERTY_START_TAG);
        Object[] params = new String[3];
        params[0] = name;
        params[2] = name;
        try {
            params[1] = getDisplayName(name, model.getUserLocale());
        } catch (PolicyException e) {
            debug.warning("PropertyXMLBuilderBase.buildXML", e);
            params[1] = name;
        }
        xml.append(MessageFormat.format(LABEL_TAG, params));
        if (allAttributesReadonly) {
            Object[] param = { name, STATIC_TEXT_TAG_NAME };
            xml.append(MessageFormat.format(COMPONENT_START_TAG, param));
        } else {
            Object[] param = { name, tagClassName };
            xml.append(MessageFormat.format(COMPONENT_START_TAG, param));
            // localize the data unless this attribute is set to false
            if (tagClassName.equals(TAGNAME_TEXTAREA)) {
                xml.append(NON_LOCALIZED_FIELD);
            } else if (tagClassName.equals(TAGNAME_TEXTFIELD)) {
                // set the size of the text field based on its syntax
                Object[] pSize = { getStringFieldSize(syntax) };
                xml.append(MessageFormat.format(TEXTBOX_SIZE_TAG, pSize));
                xml.append(NON_LOCALIZED_FIELD);
            } else if (tagClassName.equals(TAGNAME_MULTIPLE_CHOICE)) {
                xml.append(MULTIPLE_ATTRIBUTE_TAG).append(LIST_SIZE_TAG);
            }
            appendChoiceValues(name, syntax, xml);
        }
        xml.append(COMPONENT_END_TAG);
        xml.append(PROPERTY_END_TAG);
    }
}
Also used : PolicyException(com.sun.identity.policy.PolicyException) Syntax(com.sun.identity.policy.Syntax)

Example 10 with Syntax

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

the class SelectSubjectTypeViewBean method forwardToViewBean.

private void forwardToViewBean(PolicyModel model, String subjectType, String realmName) {
    Syntax syntax = model.getSubjectSyntax(realmName, subjectType);
    int displaySyntax = AMDisplayType.getDisplaySyntax(syntax);
    SubjectAddViewBean vb = null;
    switch(displaySyntax) {
        case AMDisplayType.SYNTAX_TEXT:
        case AMDisplayType.SYNTAX_SINGLE_CHOICE:
        case AMDisplayType.SYNTAX_MULTIPLE_CHOICE:
            vb = (SubjectAddViewBean) getViewBean(SubjectAddViewBean.class);
            break;
        default:
            vb = (SubjectNoneAddViewBean) getViewBean(SubjectNoneAddViewBean.class);
            break;
    }
    setPageSessionAttribute(SubjectOpViewBeanBase.PG_SESSION_SUBJECT_TYPE, subjectType);
    passPgSessionMap(vb);
    vb.forwardTo(getRequestContext());
}
Also used : Syntax(com.sun.identity.policy.Syntax)

Aggregations

Syntax (com.sun.identity.policy.Syntax)11 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)5 PolicyException (com.sun.identity.policy.PolicyException)5 SSOException (com.iplanet.sso.SSOException)4 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)4 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)4 PolicyManager (com.sun.identity.policy.PolicyManager)4 Map (java.util.Map)4 Set (java.util.Set)4 QueryResults (com.sun.identity.console.base.model.QueryResults)2 ReferralTypeManager (com.sun.identity.policy.ReferralTypeManager)2 SubjectTypeManager (com.sun.identity.policy.SubjectTypeManager)2 Referral (com.sun.identity.policy.interfaces.Referral)2 Subject (com.sun.identity.policy.interfaces.Subject)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2