Search in sources :

Example 16 with CachedPolicy

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

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

the class PolicyReferralEditViewBean method getBreadCrumbDisplayName.

protected String getBreadCrumbDisplayName() {
    PolicyModel model = (PolicyModel) getModel();
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        String[] arg = { cachedPolicy.getTrackPolicyName() };
        return MessageFormat.format(model.getLocalizedString("breadcrumbs.editPolicy"), (Object[]) arg);
    } catch (AMConsoleException e) {
        debug.warning("PolicyReferralEditViewBean.getBreadCrumbDisplayName", e);
        // Bread Crumb will not be set if cached policy cannot be located.
        return "";
    }
}
Also used : 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 18 with CachedPolicy

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

the class PolicyReferralEditViewBean method handleButton1Request.

/**
     * Handles create policy request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    try {
        if (reconstructPolicy()) {
        // error message set in PolicyOpViewBeanBase
        } else {
            CachedPolicy cachedPolicy = getCachedPolicy();
            PolicyModel model = (PolicyModel) getModel();
            try {
                model.replacePolicy(currentRealm, cachedPolicy.getPolicy());
                setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.modified.message");
                cachedPolicy.setPolicyModified(false);
            } catch (AMConsoleException e) {
                setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
            }
        }
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyReferralEditViewBean.handleButton1Request", e);
        redirectToStartURL();
    }
}
Also used : 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 19 with CachedPolicy

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

the class PolicyReferralEditViewBean method handleButton2Request.

/**
     * Handles reset request.
     *
     * @param event Request invocation event
     */
public void handleButton2Request(RequestInvocationEvent event) {
    PolicyModel model = (PolicyModel) getModel();
    String cacheID = (String) getPageSessionAttribute(ProfileViewBeanBase.PG_SESSION_POLICY_CACHE_ID);
    try {
        CachedPolicy cachedPolicy = model.getCachedPolicy(cacheID);
        String policyName = cachedPolicy.getTrackPolicyName();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        try {
            cacheID = model.cachePolicy(curRealm, policyName);
            setPageSessionAttribute(PolicyOpViewBeanBase.PG_SESSION_POLICY_CACHE_ID, cacheID);
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
        forwardTo();
    } catch (AMConsoleException e) {
        debug.warning("PolicyReferralEditViewBean.handleButton2Request", e);
        redirectToStartURL();
    }
}
Also used : 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 20 with CachedPolicy

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

the class PolicyNormalAddViewBean method handleButton1Request.

/**
     * Handles create policy request.
     *
     * @param event Request invocation event
     */
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
    String currentRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
    try {
        reconstructPolicy();
        CachedPolicy cachedPolicy = getCachedPolicy();
        PolicyModel model = (PolicyModel) getModel();
        String name = cachedPolicy.getPolicy().getName();
        if (name.equals(model.getLocalizedString("policy.create.name"))) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", model.getLocalizedString("policy.name.change"));
            forwardTo();
        } else {
            try {
                model.createPolicy(currentRealm, cachedPolicy.getPolicy());
                backTrail();
                forwardToPolicyViewBean();
            } catch (AMConsoleException e) {
                setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
                forwardTo();
            }
        }
    } catch (AMConsoleException e) {
        redirectToStartURL();
    }
}
Also used : CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) 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