use of com.sun.identity.policy.InvalidNameException in project OpenAM by OpenRock.
the class DSAMERole method setValues.
/**
* Sets the names for the instance of the <code>Subject</code>
* object. The names are obtained from the policy object,
* usually configured when a policy is created.
*
* @param names names selected for the instance of
* the user collection object.
*
* @exception InvalidNameException if the given names are not valid
*/
public void setValues(Set names) throws InvalidNameException {
if (names == null) {
throw (new InvalidNameException(ResBundleUtils.rbName, "role_subject_invalid_role_names", null, null, PolicyException.USER_COLLECTION));
}
if (names.isEmpty()) {
subjectRoles = names;
} else {
subjectRoles = new HashSet();
Iterator iter = names.iterator();
while (iter.hasNext()) {
String role = (String) iter.next();
if (role != null) {
subjectRoles.add(DN.valueOf(role).toString().toLowerCase());
}
}
}
if (debug.messageEnabled()) {
debug.message("Set subjectRoles to: " + subjectRoles);
}
}
use of com.sun.identity.policy.InvalidNameException in project OpenAM by OpenRock.
the class PolicyModelImpl method cachePolicy.
/**
* Caches a policy. Returns the cache ID of the policy object.
*
* @param policyName Name of policy.
* @param description Description of policy.
* @param isReferral <code>true</code> if policy is referral typed.
* @param isActive <code>true</code> if policy is active.
* @return cache ID of the policy object.
* @throws AMConsoleException if policy cannot be cached.
*/
public String cachePolicy(String policyName, String description, boolean isReferral, boolean isActive) throws AMConsoleException {
try {
Policy policy = new Policy(policyName, description, isReferral, isActive);
PolicyCache cache = PolicyCache.getInstance();
return cache.cachePolicy(getUserSSOToken(), new CachedPolicy(policy));
} catch (InvalidNameException e) {
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.policy.InvalidNameException in project OpenAM by OpenRock.
the class PolicyModelImpl method cachePolicy.
/**
* Caches an existing policy. Returns the cache ID of the policy object.
*
* @param realmName Name of realm.
* @param policyName Name of policy.
* @return cache ID of the policy object.
* @throws AMConsoleException if policy cannot be cached.
*/
public String cachePolicy(String realmName, String policyName) throws AMConsoleException {
try {
PolicyManager policyManager = getPolicyManager(realmName);
Policy policy = policyManager.getPolicy(policyName);
PolicyCache cache = PolicyCache.getInstance();
return cache.cachePolicy(getUserSSOToken(), new CachedPolicy(policy));
} catch (InvalidFormatException e) {
throw new AMConsoleException(getErrorString(e));
} catch (InvalidNameException e) {
throw new AMConsoleException(getErrorString(e));
} catch (NoPermissionException e) {
throw new AMConsoleException(getErrorString(e));
} catch (NameNotFoundException e) {
throw new AMConsoleException(getErrorString(e));
} catch (PolicyException e) {
throw new AMConsoleException(getErrorString(e));
} catch (SSOException e) {
throw new AMConsoleException(getErrorString(e));
}
}
use of com.sun.identity.policy.InvalidNameException 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();
}
}
}
use of com.sun.identity.policy.InvalidNameException 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;
}
Aggregations