Search in sources :

Example 26 with NameNotFoundException

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

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

Example 28 with NameNotFoundException

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

the class PolicyOpViewBeanBase method populateResponseProvidersTable.

protected void populateResponseProvidersTable() throws AMConsoleException {
    tblResponseProvidersModel.clearAll();
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    Set responseProviderNames = policy.getResponseProviderNames();
    if ((responseProviderNames != null) && !responseProviderNames.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        Map localizedRespAttrTypeNames = model.getActiveResponseProviderTypes(realmName);
        boolean firstEntry = true;
        for (Iterator i = responseProviderNames.iterator(); i.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblResponseProvidersModel.appendRow();
            }
            try {
                String name = (String) i.next();
                ResponseProvider provider = policy.getResponseProvider(name);
                tblResponseProvidersModel.setValue(TBL_RESPONSE_ATTRIBUTES_DATA_NAME, name);
                String respAttrTypeName = model.getResponseProviderTypeName(realmName, provider);
                String displayName = (String) localizedRespAttrTypeNames.get(respAttrTypeName);
                if (displayName == null) {
                    displayName = respAttrTypeName;
                }
                tblResponseProvidersModel.setValue(TBL_RESPONSE_ATTRIBUTES_DATA_TYPE, displayName);
                tblResponseProvidersModel.setValue(TBL_RESPONSE_ATTRIBUTES_ACTION_HREF, stringToHex(name));
            } catch (NameNotFoundException e) {
                debug.warning("PolicyOpViewBeanBase.populateResponseProvidersTable", 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) ResponseProvider(com.sun.identity.policy.interfaces.ResponseProvider) Iterator(java.util.Iterator) PolicyModel(com.sun.identity.console.policy.model.PolicyModel) HashMap(java.util.HashMap) Map(java.util.Map)

Example 29 with NameNotFoundException

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

the class PolicyOpViewBeanBase method handleTblRulesEditLinkRequest.

/**
     * Handles edit rule request.
     *
     * @param event Request Invocation Event.
     */
public void handleTblRulesEditLinkRequest(RequestInvocationEvent event) throws ModelControlException {
    PolicyModel model = (PolicyModel) getModel();
    String name = hexToString((String) getDisplayFieldValue(TBL_RULES_ACTION_HREF));
    setPageSessionAttribute(RuleEditViewBean.CALLING_VIEW_BEAN, getClass().getName());
    setPageSessionAttribute(RuleEditViewBean.EDIT_RULE_NAME, name);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Rule rule = policy.getRule(name);
        RuleEditViewBean vb = null;
        String resName = rule.getResourceName();
        if ((resName == null) || (resName.length() == 0)) {
            vb = (RuleNoResourceEditViewBean) getViewBean(RuleNoResourceEditViewBean.class);
            setPageSessionAttribute(RuleOpViewBeanBase.WITH_RESOURCE, Boolean.FALSE);
        } else {
            String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
            String serviceType = rule.getServiceTypeName();
            if (model.canCreateNewResource(realmName, serviceType)) {
                vb = (RuleEditViewBean) getViewBean(RuleEditViewBean.class);
            } else {
                vb = (RuleEditViewBean) getViewBean(RuleWithPrefixEditViewBean.class);
            }
            setPageSessionAttribute(RuleOpViewBeanBase.WITH_RESOURCE, Boolean.TRUE);
        }
        unlockPageTrail();
        passPgSessionMap(vb);
        vb.forwardTo(getRequestContext());
    } catch (NameNotFoundException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", getModel().getErrorString(e));
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyOpViewBeanBase.handleTblRulesEditLinkRequest", 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) Rule(com.sun.identity.policy.Rule) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 30 with NameNotFoundException

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

the class RuleEditViewBean method isActionSelected.

public boolean isActionSelected(ActionSchema as) {
    boolean selected = false;
    if (actionValues != null) {
        Set values = (Set) actionValues.get(as.getName());
        selected = (values != null) && !values.isEmpty();
    } else {
        try {
            Rule rule = getRule();
            Set actionNames = rule.getActionNames();
            selected = (actionNames != null) && actionNames.contains(as.getName());
        } catch (NameNotFoundException e) {
            selected = false;
        } catch (AMConsoleException e) {
            debug.warning("RuleEditViewBean.isActionSelected", e);
            selected = false;
        }
    }
    return selected;
}
Also used : Set(java.util.Set) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) Rule(com.sun.identity.policy.Rule) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

NameNotFoundException (com.sun.identity.policy.NameNotFoundException)52 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)41 Policy (com.sun.identity.policy.Policy)24 PolicyManager (com.sun.identity.policy.PolicyManager)23 PolicyException (com.sun.identity.policy.PolicyException)22 CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)21 Set (java.util.Set)21 Map (java.util.Map)17 Iterator (java.util.Iterator)15 HashMap (java.util.HashMap)14 SSOException (com.iplanet.sso.SSOException)11 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)11 Subject (com.sun.identity.policy.interfaces.Subject)11 Referral (com.sun.identity.policy.interfaces.Referral)10 HashSet (java.util.HashSet)10 Condition (com.sun.identity.policy.interfaces.Condition)8 ResponseProvider (com.sun.identity.policy.interfaces.ResponseProvider)7 InvalidNameException (com.sun.identity.policy.InvalidNameException)6 ReferralTypeManager (com.sun.identity.policy.ReferralTypeManager)6 Rule (com.sun.identity.policy.Rule)6