Search in sources :

Example 56 with Policy

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

the class PolicyOpViewBeanBase method populateReferralsTable.

protected void populateReferralsTable() throws AMConsoleException {
    tblReferralsModel.clearAll();
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    Set referralsNames = policy.getReferralNames();
    if ((referralsNames != null) && !referralsNames.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        Map localizedRflTypeNames = model.getActiveReferralTypes(realmName);
        boolean firstEntry = true;
        for (Iterator iter = referralsNames.iterator(); iter.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblReferralsModel.appendRow();
            }
            try {
                String name = (String) iter.next();
                Referral referral = policy.getReferral(name);
                tblReferralsModel.setValue(TBL_REFERRALS_DATA_NAME, name);
                String rflTypeName = referral.getReferralTypeName();
                String displayName = (String) localizedRflTypeNames.get(rflTypeName);
                if (displayName == null) {
                    displayName = rflTypeName;
                }
                tblReferralsModel.setValue(TBL_REFERRALS_DATA_TYPE, displayName);
                tblReferralsModel.setValue(TBL_REFERRALS_ACTION_HREF, stringToHex(name));
            } catch (NameNotFoundException e) {
                debug.warning("PolicyOpViewBeanBase.populateReferralsTable", e);
            }
        }
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Set(java.util.Set) Referral(com.sun.identity.policy.interfaces.Referral) 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)

Example 57 with Policy

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

the class PolicyOpViewBeanBase method populateConditionsTable.

protected void populateConditionsTable() throws AMConsoleException {
    tblConditionsModel.clearAll();
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    Set conditionNames = policy.getConditionNames();
    if ((conditionNames != null) && !conditionNames.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        Map localizedCndTypeNames = model.getActiveConditionTypes(realmName);
        boolean firstEntry = true;
        for (Iterator iter = conditionNames.iterator(); iter.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblConditionsModel.appendRow();
            }
            try {
                String name = (String) iter.next();
                Condition condition = policy.getCondition(name);
                tblConditionsModel.setValue(TBL_CONDITIONS_DATA_NAME, name);
                String cndTypeName = model.getConditionTypeName(realmName, condition);
                String displayName = (String) localizedCndTypeNames.get(cndTypeName);
                if (displayName == null) {
                    displayName = cndTypeName;
                }
                tblConditionsModel.setValue(TBL_CONDITIONS_DATA_TYPE, displayName);
                tblConditionsModel.setValue(TBL_CONDITIONS_ACTION_HREF, stringToHex(name));
            } catch (NameNotFoundException e) {
                debug.warning("PolicyOpViewBeanBase.populateConditionsTable", e);
            }
        }
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) 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) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) HashMap(java.util.HashMap) Map(java.util.Map)

Example 58 with Policy

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

the class ReferralEditViewBean method handleButton1Request.

private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
    Referral deleted = null;
    String origName = (String) getPageSessionAttribute(EDIT_REFERRAL_NAME);
    Policy policy = cachedPolicy.getPolicy();
    try {
        Referral referral = createReferral();
        if (referral != null) {
            String name = (String) propertySheetModel.getValue(REFERRAL_NAME);
            if (origName.equals(name)) {
                policy.replaceReferral(name, referral);
            } else {
                deleted = policy.removeReferral(origName);
                policy.addReferral(name, referral);
            }
            deleted = null;
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.referral.updated");
            cachedPolicy.setPolicyModified(true);
        }
    } catch (NameAlreadyExistsException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
    } catch (InvalidNameException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
    } catch (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    } finally {
        if (deleted != null) {
            try {
                policy.addReferral(origName, deleted);
            } catch (NameAlreadyExistsException e) {
                debug.warning("ReferralEditViewBean.handleButton1Request", e);
            } catch (InvalidNameException e) {
                debug.warning("ReferralEditViewBean.handleButton1Request", e);
            }
        }
    }
    forwardTo();
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) InvalidNameException(com.sun.identity.policy.InvalidNameException) Referral(com.sun.identity.policy.interfaces.Referral) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 59 with Policy

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

the class PolicyOpViewBeanBase method handleTblRulesButtonDeleteRequest.

/**
     * Handles delete rule request.
     *
     * @param event Request Invocation Event.
     */
public void handleTblRulesButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_RULES);
    table.restoreStateData();
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Integer[] selected = tblRulesModel.getSelectedRows();
        for (int i = 0; i < selected.length; i++) {
            tblRulesModel.setRowIndex(selected[i].intValue());
            String ruleName = (String) tblRulesModel.getValue(TBL_RULES_DATA_NAME);
            policy.removeRule(ruleName);
        }
        cachedPolicy.setPolicyModified(true);
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblRulesButtonDeleteRequest", 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 60 with Policy

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

the class PolicyOpViewBeanBase method handleTblSubjectsEditLinkRequest.

public void handleTblSubjectsEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String name = hexToString((String) getDisplayFieldValue(TBL_SUBJECTS_ACTION_HREF));
    setPageSessionAttribute(SubjectEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
    setPageSessionAttribute(SubjectEditViewBean.EDIT_SUBJECT_NAME, name);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Subject subject = policy.getSubject(name);
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String subjectType = model.getSubjectTypeName(realmName, subject);
        String viewBeanURL = model.getSubjectViewBeanURL(realmName, subjectType);
        unlockPageTrail();
        if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
            forwardToSubjectURL(viewBeanURL, name, subjectType, realmName, "edit");
        } else {
            forwardToSubjectEditViewBean(model, realmName, name, subjectType);
        }
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblSubjectsEditLinkRequest", e);
        redirectToStartURL();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) 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) Subject(com.sun.identity.policy.interfaces.Subject)

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