Search in sources :

Example 16 with NameNotFoundException

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

the class PolicyModelImpl method getActiveReferralTypes.

/**
     * Returns a map of active referral types for a realm to its display name.
     *
     * @param realmName Name of Realm.
     * @return a map of active referral types for a realm to its display name.
     */
public Map getActiveReferralTypes(String realmName) {
    Map referralTypes = null;
    try {
        PolicyManager policyMgr = getPolicyManager(realmName);
        if (policyMgr != null) {
            ReferralTypeManager referralTypeMgr = policyMgr.getReferralTypeManager();
            if (referralTypeMgr != null) {
                Set types = referralTypeMgr.getSelectedReferralTypeNames();
                referralTypes = new HashMap(types.size() * 2);
                for (Iterator iter = types.iterator(); iter.hasNext(); ) {
                    String rName = (String) iter.next();
                    Referral referral = referralTypeMgr.getReferral(rName);
                    if (referral != null) {
                        Syntax syntax = referral.getValueSyntax(getUserSSOToken());
                        if (!syntax.equals(Syntax.NONE)) {
                            referralTypes.put(rName, referralTypeMgr.getDisplayName(rName));
                        }
                    }
                }
            }
        }
    } catch (AMConsoleException e) {
        debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
    } catch (SSOException e) {
        debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
    } catch (NameNotFoundException e) {
        debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
    } catch (PolicyException e) {
        debug.warning("PolicyModelImpl.getActiveReferralTypes", e);
    }
    return (referralTypes == null) ? Collections.EMPTY_MAP : referralTypes;
}
Also used : ReferralTypeManager(com.sun.identity.policy.ReferralTypeManager) PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) SSOException(com.iplanet.sso.SSOException) Referral(com.sun.identity.policy.interfaces.Referral) PolicyException(com.sun.identity.policy.PolicyException) Iterator(java.util.Iterator) Syntax(com.sun.identity.policy.Syntax) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 17 with NameNotFoundException

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

the class PrivilegeUtils method pavToPrav.

static Map<String, Boolean> pavToPrav(Map actionValues, String serviceName) throws PolicyException, SSOException {
    if (actionValues == null) {
        return null;
    }
    ServiceType serviceType = null;
    if (serviceName != null) {
        try {
            serviceType = svcTypeManager.getServiceType(serviceName);
        } catch (NameNotFoundException e) {
        //ignore
        }
    }
    Map av = new HashMap();
    Set keySet = (Set) actionValues.keySet();
    for (Object actionObj : keySet) {
        String action = (String) actionObj;
        Set values = (Set) actionValues.get(action);
        if ((values == null) || values.isEmpty()) {
            av.put(action, Boolean.FALSE);
        } else {
            if (serviceType != null) {
                try {
                    ActionSchema as = serviceType.getActionSchema(action);
                    if (as.getSyntax().equals(AttributeSchema.Syntax.BOOLEAN)) {
                        String trueValue = as.getTrueValue();
                        if (values.contains(trueValue)) {
                            av.put(action, Boolean.TRUE);
                        } else {
                            av.put(action, Boolean.FALSE);
                        }
                    } else {
                        // Append action value to action name
                        String value = values.iterator().next().toString();
                        av.put(action + "_" + value, Boolean.TRUE);
                    }
                } catch (InvalidNameException e) {
                    av.put(action, Boolean.parseBoolean((String) values.iterator().next()));
                }
            } else {
                av.put(action, Boolean.parseBoolean((String) values.iterator().next()));
            }
        }
    }
    return av;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) InvalidNameException(com.sun.identity.policy.InvalidNameException) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) HashMap(java.util.HashMap) ServiceType(com.sun.identity.policy.ServiceType) HashMap(java.util.HashMap) Map(java.util.Map) ActionSchema(com.sun.identity.policy.ActionSchema)

Example 18 with NameNotFoundException

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

the class MigrateValidGotoSetting method initialize.

@Override
public void initialize() throws UpgradeException {
    try {
        final PolicyManager pm = new PolicyManager(getAdminToken(), HIDDEN_REALM);
        if (pm.getPolicyNames(DELEGATION_POLICY_NAME).isEmpty()) {
            if (DEBUG.messageEnabled()) {
                DEBUG.message("Unable to find the delegation policy in the hidden realm, looking for existing goto" + " domain values.");
            }
            //The delegation policy is not defined yet in the configuration, we need to migrate the goto domains.
            final ServiceConfigManager scm = new ServiceConfigManager(ISAuthConstants.AUTH_SERVICE_NAME, getAdminToken());
            for (final String realm : getRealmNames()) {
                if (DEBUG.messageEnabled()) {
                    DEBUG.message("Looking for valid goto URLs in realm " + realm);
                }
                final ServiceConfig organizationConfig = scm.getOrganizationConfig(realm, null);
                final Map<String, Set<String>> attrs = organizationConfig.getAttributesWithoutDefaults();
                final Set<String> validDomains = attrs.get(LEGACY_GOTO_DOMAINS_SETTING);
                if (validDomains != null && !validDomains.isEmpty()) {
                    changes.put(realm, validDomains);
                }
            }
            if (DEBUG.messageEnabled()) {
                DEBUG.message("Found the following existing goto URL domains in realms: " + changes);
            }
        } else {
            delegationPolicyFound = true;
        }
    } catch (final NameNotFoundException nnfe) {
        throw new UpgradeException("Unable to find hidden realm", nnfe);
    } catch (final PolicyException pe) {
        throw new UpgradeException("Unexpected error occurred while retrieving policies from the hidden realm", pe);
    } catch (final SMSException smse) {
        throw new UpgradeException("An error occurred while checking for old valid goto domains", smse);
    } catch (final SSOException ssoe) {
        throw new UpgradeException("An error occurred while checking for old valid goto domains", ssoe);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 19 with NameNotFoundException

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

the class IdentitySubjectEditViewBean method getDefaultValues.

protected Set getDefaultValues(IdentitySubjectModel model) {
    Set values = null;
    String subjectName = (String) getPageSessionAttribute(SubjectOpViewBeanBase.PG_SESSION_SUBJECT_NAME);
    try {
        CachedPolicy cachedPolicy = getCachedPolicy();
        Policy policy = cachedPolicy.getPolicy();
        Subject subject = policy.getSubject(subjectName);
        values = subject.getValues();
    } catch (NameNotFoundException e) {
        debug.warning("IdentitySubjectEditViewBean.getDefaultValues", e);
    } catch (AMConsoleException e) {
        debug.warning("IdentitySubjectEditViewBean.getDefaultValues", e);
    }
    return (values != null) ? values : Collections.EMPTY_SET;
}
Also used : Policy(com.sun.identity.policy.Policy) CachedPolicy(com.sun.identity.console.policy.model.CachedPolicy) HashSet(java.util.HashSet) 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 20 with NameNotFoundException

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

the class ConditionEditViewBean 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);
        values = condition.getProperties();
    } catch (NameNotFoundException e) {
        debug.warning("ConditionEditViewBean.getDefaultValues", e);
    } catch (AMConsoleException e) {
        debug.warning("ConditionEditViewBean.getDefaultValues", e);
    }
    return values;
}
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) 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