Search in sources :

Example 11 with Policy

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

Example 12 with Policy

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

the class PMDefaultTimeConditionEditViewBean method getDefaultValues.

protected Map getDefaultValues() {
    Map values = null;
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        String conditionName = (String) getPageSessionAttribute(ConditionOpViewBeanBase.PG_SESSION_CONDITION_NAME);
        Condition condition = policy.getCondition(conditionName);
        Map map = condition.getProperties();
        for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
            String propName = (String) iter.next();
            Set val = (Set) map.get(propName);
            if (propName.equals(SimpleTimeCondition.START_DATE)) {
                String strDate = (String) val.iterator().next();
                helper.setDate(this, true, strDate, getModel());
            } else if (propName.equals(SimpleTimeCondition.END_DATE)) {
                String strDate = (String) val.iterator().next();
                helper.setDate(this, false, strDate, getModel());
            } else if (propName.equals(SimpleTimeCondition.START_TIME)) {
                String strTime = (String) val.iterator().next();
                helper.setTime(this, true, strTime);
            } else if (propName.equals(SimpleTimeCondition.END_TIME)) {
                String strTime = (String) val.iterator().next();
                helper.setTime(this, false, strTime);
            } else if (propName.equals(SimpleTimeCondition.START_DAY)) {
                String strDay = (String) val.iterator().next();
                helper.setDay(this, true, strDay);
            } else if (propName.equals(SimpleTimeCondition.END_DAY)) {
                String strDay = (String) val.iterator().next();
                helper.setDay(this, false, strDay);
            } else if (propName.equals(SimpleTimeCondition.ENFORCEMENT_TIME_ZONE)) {
                String strTz = (String) val.iterator().next();
                helper.setTimeZone(this, canModify, strTz);
            }
        }
    } catch (NameNotFoundException e) {
        debug.warning("ConditionEditViewBean.getDefaultValues", e);
    } catch (AMConsoleException e) {
        debug.warning("ConditionEditViewBean.getDefaultValues", e);
    }
    //Yes, we are returning null;
    return values;
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) SimpleTimeCondition(com.sun.identity.policy.plugins.SimpleTimeCondition) Condition(com.sun.identity.policy.interfaces.Condition) Set(java.util.Set) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Iterator(java.util.Iterator) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 13 with Policy

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

the class PolicyOpViewBeanBase method handleTblReferralsEditLinkRequest.

public void handleTblReferralsEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String name = hexToString((String) getDisplayFieldValue(TBL_REFERRALS_ACTION_HREF));
    setPageSessionAttribute(ReferralEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
    setPageSessionAttribute(ReferralEditViewBean.EDIT_REFERRAL_NAME, name);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Referral referral = policy.getReferral(name);
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String referralType = referral.getReferralTypeName();
        String viewBeanURL = model.getReferralViewBeanURL(realmName, referralType);
        unlockPageTrail();
        if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
            forwardToReferralURL(viewBeanURL, name, referralType, realmName, "edit");
        } else {
            forwardToReferralEditViewBean(model, realmName, name, referralType);
        }
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblReferralsEditLinkRequest", e);
        redirectToStartURL();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 14 with Policy

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

the class PolicyOpViewBeanBase method handleTblResponseProvidersButtonDeleteRequest.

/**
     * Handles delete response attribute request.
     *
     * @param event Request Invocation Event.
     */
public void handleTblResponseProvidersButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_RESPONSE_ATTRIBUTES);
    table.restoreStateData();
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Integer[] selected = tblResponseProvidersModel.getSelectedRows();
        for (int i = 0; i < selected.length; i++) {
            tblResponseProvidersModel.setRowIndex(selected[i].intValue());
            String responseProviderName = (String) tblResponseProvidersModel.getValue(TBL_RESPONSE_ATTRIBUTES_DATA_NAME);
            policy.removeResponseProvider(responseProviderName);
        }
        cachedPolicy.setPolicyModified(true);
        populateResponseProvidersTable();
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblResponseProvidersButtonDeleteRequest", e);
        redirectToStartURL();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 15 with Policy

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

the class PolicyOpViewBeanBase method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    try {
        populateRulesTable();
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        PolicyModel model = (PolicyModel) getModel();
        CCButton btn = (CCButton) getChild("tblRulesButtonAdd");
        if (!model.canCreateRule(policy, realmName)) {
            btn.setDisabled(true);
        }
        btn = (CCButton) getChild("tblRulesButtonDelete");
        btn.setDisabled(true);
        Map serviceTypes = model.getServiceTypeNames();
        if ((serviceTypes == null) || serviceTypes.isEmpty()) {
            ((CCButton) getChild("tblRulesButtonDelete")).setDisabled(true);
            setDisplayFieldValue("tblRulesNote", model.getLocalizedString("policy.no.service.types"));
        } else {
            setDisplayFieldValue("tblRulesNote", "");
        }
        if (!isInlineAlertMessageSet() && cachedPolicy.isPolicyModified() && isProfilePage()) {
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.unsaved.message");
        }
    } catch (AMConsoleException e) {
        CCButton btn = (CCButton) getChild("tblRulesButtonAdd");
        btn.setDisabled(true);
        btn = (CCButton) getChild("tblRulesButtonDelete");
        btn.setDisabled(true);
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CCButton(com.sun.web.ui.view.html.CCButton) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Policy (com.sun.identity.policy.Policy)68 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)37 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)32 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)24 Set (java.util.Set)22 PolicyException (com.sun.identity.policy.PolicyException)17 PolicyManager (com.sun.identity.policy.PolicyManager)16 HashSet (java.util.HashSet)16 Map (java.util.Map)16 SSOException (com.iplanet.sso.SSOException)15 Rule (com.sun.identity.policy.Rule)15 Subject (com.sun.identity.policy.interfaces.Subject)14 HashMap (java.util.HashMap)14 Iterator (java.util.Iterator)13 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)12 InvalidNameException (com.sun.identity.policy.InvalidNameException)11 NameAlreadyExistsException (com.sun.identity.policy.NameAlreadyExistsException)10 Condition (com.sun.identity.policy.interfaces.Condition)10 SMSException (com.sun.identity.sm.SMSException)7 Referral (com.sun.identity.policy.interfaces.Referral)6