Search in sources :

Example 26 with CachedPolicy

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

Example 27 with CachedPolicy

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

the class SubjectEditViewBean method getDefaultValues.

protected Set getDefaultValues() {
    Set values = null;
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        String subjectName = (String) getPageSessionAttribute(SubjectOpViewBeanBase.PG_SESSION_SUBJECT_NAME);
        Subject subject = policy.getSubject(subjectName);
        values = subject.getValues();
    } catch (NameNotFoundException e) {
        debug.warning("SubjectEditViewBean.getDefaultValues", e);
    } catch (AMConsoleException e) {
        debug.warning("SubjectEditViewBean.getDefaultValues", e);
    }
    return values;
}
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) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Example 28 with CachedPolicy

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

the class SubjectAddViewBean method handleButton2Request.

/**
     * Handles create policy's subject request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
    boolean forwarded = false;
    submitCycle = true;
    bFilter = true;
    try {
        Subject subject = createSubject();
        if (subject != null) {
            CachedPolicy cachedPolicy = getCachedPolicy();
            Policy policy = cachedPolicy.getPolicy();
            String name = (String) propertySheetModel.getValue(SUBJECT_NAME);
            policy.addSubject(name, subject, isExclusive());
            backTrail();
            forwardToPolicyViewBean();
            forwarded = 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 (AMConsoleException e) {
        setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
    } finally {
        if (!forwarded) {
            forwardTo();
        }
    }
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) InvalidNameException(com.sun.identity.policy.InvalidNameException) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Example 29 with CachedPolicy

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

the class SubjectEditViewBean method isSubjectExclusive.

protected boolean isSubjectExclusive() {
    boolean isExclusive = false;
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        String subjectName = (String) getPageSessionAttribute(SubjectOpViewBeanBase.PG_SESSION_SUBJECT_NAME);
        isExclusive = policy.isSubjectExclusive(subjectName);
    } catch (NameNotFoundException e) {
        debug.warning("SubjectEditViewBean.isSubjectExclusive", e);
    } catch (AMConsoleException e) {
        debug.warning("SubjectEditViewBean.isSubjectExclusive", e);
    }
    return isExclusive;
}
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) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 30 with CachedPolicy

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

Aggregations

CachedPolicy (com.sun.identity.console.policy.model.CachedPolicy)53 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)38 Policy (com.sun.identity.policy.Policy)37 PolicyModel (com.sun.identity.console.policy.model.PolicyModel)26 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)21 NameAlreadyExistsException (com.sun.identity.policy.NameAlreadyExistsException)10 InvalidNameException (com.sun.identity.policy.InvalidNameException)9 Map (java.util.Map)9 Set (java.util.Set)9 PolicyCache (com.sun.identity.console.policy.model.PolicyCache)6 Condition (com.sun.identity.policy.interfaces.Condition)6 Subject (com.sun.identity.policy.interfaces.Subject)6 HashMap (java.util.HashMap)6 Iterator (java.util.Iterator)6 Referral (com.sun.identity.policy.interfaces.Referral)5 ResponseProvider (com.sun.identity.policy.interfaces.ResponseProvider)5 CCActionTable (com.sun.web.ui.view.table.CCActionTable)5 Rule (com.sun.identity.policy.Rule)4 QueryResults (com.sun.identity.console.base.model.QueryResults)1 SimpleTimeCondition (com.sun.identity.policy.plugins.SimpleTimeCondition)1