Search in sources :

Example 51 with NameNotFoundException

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

the class PrivilegeUtils method pravToPav.

static Map pravToPav(Map<String, Boolean> actionValues, String serviceName) throws PolicyException, SSOException {
    if (actionValues == null) {
        return null;
    }
    ServiceType serviceType = null;
    try {
        serviceType = svcTypeManager.getServiceType(serviceName);
    } catch (NameNotFoundException e) {
    //ignore
    }
    Map av = new HashMap();
    Set<String> keySet = actionValues.keySet();
    for (String action : keySet) {
        try {
            Set values = new HashSet();
            Boolean value = actionValues.get(action);
            if (serviceType != null) {
                ActionSchema as = serviceType.getActionSchema(action);
                String trueValue = as.getTrueValue();
                String falseValue = as.getFalseValue();
                if (value.equals(Boolean.TRUE)) {
                    values.add(trueValue);
                } else {
                    values.add(falseValue);
                }
            } else {
                values.add(value.toString());
            }
            av.put(action, values);
        } catch (InvalidNameException e) {
            Boolean value = actionValues.get(action);
            Set values = new HashSet();
            values.add(value.toString());
            av.put(action, values);
        }
    }
    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) HashSet(java.util.HashSet)

Example 52 with NameNotFoundException

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

the class RealmTest method deletePolicy.

@Test(groups = { "cli-realm", "delete-policies" }, dependsOnMethods = { "getPolicy" })
public void deletePolicy() throws CLIException, PolicyException, SSOException {
    entering("deletePolicy", null);
    String[] args = { "delete-policies", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, "/", CLIConstants.PREFIX_ARGUMENT_LONG + RealmDeletePolicy.ARGUMENT_POLICY_NAMES, "clipolicy" };
    SSOToken adminSSOToken = getAdminSSOToken();
    CLIRequest req = new CLIRequest(null, args, adminSSOToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    PolicyManager pm = new PolicyManager(adminSSOToken, "/");
    try {
        Policy p = pm.getPolicy("clipolicy");
        assert (p == null);
    } catch (NameNotFoundException e) {
    // do nothing
    }
    exiting("deletePolicy");
}
Also used : Policy(com.sun.identity.policy.Policy) PolicyManager(com.sun.identity.policy.PolicyManager) SSOToken(com.iplanet.sso.SSOToken) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CLIRequest(com.sun.identity.cli.CLIRequest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

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