Search in sources :

Example 1 with NameNotFoundException

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

the class ResponseProviderEditViewBean method getDefaultValues.

protected Map getDefaultValues() {
    Map values = null;
    String providerName = (String) getPageSessionAttribute(ResponseProviderOpViewBeanBase.PG_SESSION_PROVIDER_NAME);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        ResponseProvider provider = policy.getResponseProvider(providerName);
        values = provider.getProperties();
    } catch (NameNotFoundException e) {
        debug.warning("ResponseProviderEditViewBean.getDefaultValues", e);
    } catch (AMConsoleException e) {
        debug.warning("ResponseProviderEditViewBean.getDefaultValues", e);
    }
    return values;
}
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) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map)

Example 2 with NameNotFoundException

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

the class ReferralEditViewBean method getDefaultValues.

protected Set getDefaultValues() {
    Set values = null;
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        String referralName = (String) getPageSessionAttribute(PG_SESSION_REFERRAL_NAME);
        Referral referral = policy.getReferral(referralName);
        values = referral.getValues();
    } catch (NameNotFoundException e) {
        debug.warning("ReferralEditViewBean.getDefaultValues", e);
    } catch (AMConsoleException e) {
        debug.warning("ReferralEditViewBean.getDefaultValues", e);
    }
    return values;
}
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) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 3 with NameNotFoundException

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

the class SubjectEditViewBean method handleButton1Request.

private void handleButton1Request(CachedPolicy cachedPolicy) throws ModelControlException {
    submitCycle = true;
    Subject deleted = null;
    String origName = (String) getPageSessionAttribute(EDIT_SUBJECT_NAME);
    Policy policy = cachedPolicy.getPolicy();
    try {
        Subject subject = createSubject();
        if (subject != null) {
            String name = (String) propertySheetModel.getValue(SUBJECT_NAME);
            if (origName.equals(name)) {
                policy.replaceSubject(name, subject, isExclusive());
            } else {
                deleted = policy.removeSubject(origName);
                policy.addSubject(name, subject, isExclusive());
            }
            deleted = null;
            setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "policy.subject.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.addSubject(origName, deleted);
            } catch (NameAlreadyExistsException e) {
                debug.warning("SubjectEditViewBean.handleButton1Request", e);
            } catch (InvalidNameException e) {
                debug.warning("SubjectEditViewBean.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) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) NameAlreadyExistsException(com.sun.identity.policy.NameAlreadyExistsException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Subject(com.sun.identity.policy.interfaces.Subject)

Example 4 with NameNotFoundException

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

the class PolicyOpViewBeanBase method populateSubjectsTable.

protected void populateSubjectsTable() throws AMConsoleException {
    tblSubjectsModel.clearAll();
    CachedPolicy cachedPolicy = getCachedPolicy();
    Policy policy = cachedPolicy.getPolicy();
    Set subjectsNames = policy.getSubjectNames();
    if ((subjectsNames != null) && !subjectsNames.isEmpty()) {
        PolicyModel model = (PolicyModel) getModel();
        String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        QueryResults queryResults = model.getActiveSubjectTypes(realmName);
        Map localizedSbjTypeNames = (Map) queryResults.getResults();
        boolean firstEntry = true;
        for (Iterator iter = subjectsNames.iterator(); iter.hasNext(); ) {
            if (firstEntry) {
                firstEntry = false;
            } else {
                tblSubjectsModel.appendRow();
            }
            try {
                String name = (String) iter.next();
                Subject subject = policy.getSubject(name);
                tblSubjectsModel.setValue(TBL_SUBJECTS_DATA_NAME, name);
                String sbjTypeName = model.getSubjectTypeName(realmName, subject);
                String displayName = (String) localizedSbjTypeNames.get(sbjTypeName);
                if (displayName == null) {
                    displayName = sbjTypeName;
                }
                tblSubjectsModel.setValue(TBL_SUBJECTS_DATA_TYPE, displayName);
                tblSubjectsModel.setValue(TBL_SUBJECTS_ACTION_HREF, stringToHex(name));
            } catch (NameNotFoundException e) {
                debug.warning("PolicyOpViewBeanBase.populateSubjectsTable", 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) HashMap(java.util.HashMap) Map(java.util.Map) QueryResults(com.sun.identity.console.base.model.QueryResults) Subject(com.sun.identity.policy.interfaces.Subject)

Example 5 with NameNotFoundException

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

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