Search in sources :

Example 21 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class SubjectEditViewBean method getBreadCrumbDisplayName.

protected String getBreadCrumbDisplayName() {
    PolicyModel model = (PolicyModel) getModel();
    String origName = (String) getPageSessionAttribute(EDIT_SUBJECT_NAME);
    String[] arg = { origName };
    return MessageFormat.format(model.getLocalizedString("breadcrumbs.editSubject"), (Object[]) arg);
}
Also used : PolicyModel(com.sun.identity.console.policy.model.PolicyModel)

Example 22 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class SelectSubjectTypeViewBean method getTypeOptions.

protected OptionList getTypeOptions() {
    PolicyModel model = (PolicyModel) getModel();
    String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    QueryResults qr = model.getActiveSubjectTypes(curRealm);
    String strError = qr.getStrError();
    if ((strError != null) && (strError.length() > 0)) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", strError);
    }
    return createOptionList((Map) qr.getResults(), model.getUserLocale());
}
Also used : PolicyModel(com.sun.identity.console.policy.model.PolicyModel) QueryResults(com.sun.identity.console.base.model.QueryResults)

Example 23 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyOpViewBeanBase method subjectHasValueSyntax.

private boolean subjectHasValueSyntax(String realmName, String subjectType) {
    PolicyModel model = (PolicyModel) getModel();
    Syntax syntax = model.getSubjectSyntax(realmName, subjectType);
    int displaySyntax = AMDisplayType.getDisplaySyntax(syntax);
    return (displaySyntax == AMDisplayType.SYNTAX_TEXT) || (displaySyntax == AMDisplayType.SYNTAX_SINGLE_CHOICE) || (displaySyntax == AMDisplayType.SYNTAX_MULTIPLE_CHOICE);
}
Also used : PolicyModel(com.sun.identity.console.policy.model.PolicyModel) Syntax(com.sun.identity.policy.Syntax)

Example 24 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyNormalViewBeanBase method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    try {
        populateAttributes();
    } catch (AMConsoleException e) {
    //NO-OP
    /* attribute values will not be populated if cached policy
             * cannot be located.
             */
    }
    CCButton btn = (CCButton) getChild("tblSubjectsButtonDelete");
    btn.setDisabled(true);
    btn = (CCButton) getChild("tblResponseProvidersButtonDelete");
    btn.setDisabled(true);
    btn = (CCButton) getChild("tblConditionsButtonDelete");
    btn.setDisabled(true);
    PolicyModel model = (PolicyModel) getModel();
    String realm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    QueryResults subjectsQuery = model.getActiveSubjectTypes(realm);
    Map subjects = (Map) subjectsQuery.getResults();
    if ((subjects == null) || subjects.isEmpty()) {
        ((CCButton) getChild("tblSubjectsButtonAdd")).setDisabled(true);
        setDisplayFieldValue("tblSubjectsNote", model.getLocalizedString("policy.no.subject.types"));
    } else {
        setDisplayFieldValue("tblSubjectsNote", "");
    }
    Map conditions = model.getActiveConditionTypes(realm);
    if ((conditions == null) || conditions.isEmpty()) {
        ((CCButton) getChild("tblConditionsButtonAdd")).setDisabled(true);
        setDisplayFieldValue("tblConditionsNote", model.getLocalizedString("policy.no.condition.types"));
    } else {
        setDisplayFieldValue("tblConditionsNote", "");
    }
    Map responseProviders = model.getActiveResponseProviderTypes(realm);
    if ((responseProviders == null) || responseProviders.isEmpty()) {
        ((CCButton) getChild("tblResponseProvidersButtonAdd")).setDisabled(true);
        setDisplayFieldValue("tblResponseProvidersNote", model.getLocalizedString("policy.no.response.providers.types"));
    } else {
        setDisplayFieldValue("tblResponseProvidersNote", "");
    }
}
Also used : CCButton(com.sun.web.ui.view.html.CCButton) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) QueryResults(com.sun.identity.console.base.model.QueryResults)

Example 25 with PolicyModel

use of com.sun.identity.console.policy.model.PolicyModel in project OpenAM by OpenRock.

the class PolicyOpViewBeanBase method populateSubjectsTable.

protected void populateSubjectsTable() throws AMConsoleException {
    tblSubjectsModel.clearAll();
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    Set subjectsNames = policy.getSubjectNames();
    if ((subjectsNames != null) && !subjectsNames.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        QueryResults queryResults = model.getActiveSubjectTypes(realmName);
        Map localizedSbjTypeNames = (Map) queryResults.getResults();
        boolean firstEntry = true;
        for (Iterator iter = subjectsNames.iterator(); iter.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblSubjectsModel.appendRow();
            }
            try {
                String name = (String) iter.next();
                Subject subject = policy.getSubject(name);
                tblSubjectsModel.setValue(TBL_SUBJECTS_DATA_NAME, name);
                String sbjTypeName = model.getSubjectTypeName(realmName, subject);
                String displayName = (String) localizedSbjTypeNames.get(sbjTypeName);
                if (displayName == null) {
                    displayName = sbjTypeName;
                }
                tblSubjectsModel.setValue(TBL_SUBJECTS_DATA_TYPE, displayName);
                tblSubjectsModel.setValue(TBL_SUBJECTS_ACTION_HREF, stringToHex(name));
            } catch (NameNotFoundException e) {
                debug.warning("PolicyOpViewBeanBase.populateSubjectsTable", e);
            }
        }
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Set(java.util.Set) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) HashMap(java.util.HashMap) Map(java.util.Map) QueryResults(com.sun.identity.console.base.model.QueryResults) Subject(com.sun.identity.policy.interfaces.Subject)

Aggregations

PolicyModel (com.sun.identity.console.policy.model.PolicyModel)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)28 Map (java.util.Map)27 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)26 HashMap (java.util.HashMap)14 Policy (com.sun.identity.policy.Policy)12 Set (java.util.Set)12 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)11 Iterator (java.util.Iterator)8 OptionList (com.iplanet.jato.view.html.OptionList)7 PolicyCache (com.sun.identity.console.policy.model.PolicyCache)6 QueryResults (com.sun.identity.console.base.model.QueryResults)5 Syntax (com.sun.identity.policy.Syntax)5 Rule (com.sun.identity.policy.Rule)3 Referral (com.sun.identity.policy.interfaces.Referral)3 CCButton (com.sun.web.ui.view.html.CCButton)3 List (java.util.List)3 IdentitySubjectModel (com.sun.identity.console.policy.model.IdentitySubjectModel)2 ActionSchema (com.sun.identity.policy.ActionSchema)2 ValidValues (com.sun.identity.policy.ValidValues)2