Search in sources :

Example 51 with Policy

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

the class PolicyOpViewBeanBase method handleTblResponseProvidersEditLinkRequest.

public void handleTblResponseProvidersEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String name = hexToString((String) getDisplayFieldValue(TBL_RESPONSE_ATTRIBUTES_ACTION_HREF));
    setPageSessionAttribute(ResponseProviderEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
    setPageSessionAttribute(ResponseProviderEditViewBean.EDIT_RESPONSEPROVIDER_NAME, name);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        ResponseProvider provider = policy.getResponseProvider(name);
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String responseProviderType = model.getResponseProviderTypeName(realmName, provider);
        String viewBeanURL = model.getResponseProviderViewBeanURL(realmName, responseProviderType);
        unlockPageTrail();
        if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
            forwardToResponseProviderURL(viewBeanURL, name, responseProviderType, realmName, "edit");
        } else {
            forwardToResponseProviderEditViewBean(model, realmName, name, responseProviderType);
        }
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblResponseProvidersEditLinkRequest", 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) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 52 with Policy

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

the class PolicyOpViewBeanBase method handleTblReferralsButtonDeleteRequest.

public void handleTblReferralsButtonDeleteRequest(RequestInvocationEvent event) throws ModelControlException {
    CCActionTable table = (CCActionTable) getChild(TBL_REFERRALS);
    table.restoreStateData();
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Integer[] selected = tblReferralsModel.getSelectedRows();
        for (int i = 0; i < selected.length; i++) {
            tblReferralsModel.setRowIndex(selected[i].intValue());
            String name = (String) tblReferralsModel.getValue(TBL_REFERRALS_DATA_NAME);
            policy.removeReferral(name);
        }
        cachedPolicy.setPolicyModified(true);
        populateReferralsTable();
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblReferralsButtonDeleteRequest", 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 53 with Policy

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

the class PolicyOpViewBeanBase method populateAttributes.

protected void populateAttributes() throws AMConsoleException {
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    propertySheetModel.setValue(PolicyModel.TF_NAME, policy.getName());
    propertySheetModel.setValue(ATTR_DESCRIPTION, policy.getDescription());
    propertySheetModel.setValue(ATTR_ISACTIVE, policy.isActive() ? "true" : "false");
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy)

Example 54 with Policy

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

the class PolicyOpViewBeanBase method handleTblConditionsEditLinkRequest.

public void handleTblConditionsEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String name = hexToString((String) getDisplayFieldValue(TBL_CONDITIONS_ACTION_HREF));
    setPageSessionAttribute(ConditionEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
    setPageSessionAttribute(ConditionEditViewBean.EDIT_CONDITION_NAME, name);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Condition condition = policy.getCondition(name);
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        String conditionType = model.getConditionTypeName(realmName, condition);
        String viewBeanURL = model.getConditionViewBeanURL(realmName, conditionType);
        unlockPageTrail();
        if ((viewBeanURL != null) && (viewBeanURL.trim().length() > 0)) {
            forwardToConditionURL(viewBeanURL, name, conditionType, realmName, "edit");
        } else {
            forwardToConditionEditViewBean(model, realmName, name, conditionType);
        }
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getErrorString(e));
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblConditionsButtonDeleteRequest", e);
        redirectToStartURL();
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) Condition(com.sun.identity.policy.interfaces.Condition) 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 55 with Policy

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

the class PolicyOpViewBeanBase method populateRulesTable.

protected void populateRulesTable() throws AMConsoleException {
    tblRulesModel.clearAll();
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    Set ruleNames = policy.getRuleNames();
    if ((ruleNames != null) && !ruleNames.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        Map localizedSvcTypeNames = model.getServiceTypeNames();
        boolean firstEntry = true;
        for (Iterator iter = ruleNames.iterator(); iter.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblRulesModel.appendRow();
            }
            try {
                String name = (String) iter.next();
                Rule rule = policy.getRule(name);
                tblRulesModel.setValue(TBL_RULES_DATA_NAME, name);
                tblRulesModel.setValue(TBL_RULES_DATA_TYPE, localizedSvcTypeNames.get(rule.getServiceTypeName()));
                tblRulesModel.setValue(TBL_RULES_ACTION_HREF, stringToHex(name));
            } catch (NameNotFoundException e) {
                debug.warning("PolicyOpViewBeanBase.populateRulesTable", 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) Rule(com.sun.identity.policy.Rule) 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