ce.getBundleActionMessage().setArg3(item.getLabel());
errs.add(Globals.ERROR_KEY, ce.getBundleActionMessage());
}
}
SessionInfo session = LogonControllerFactory.getInstance().getSessionInfo(request);
UserDatabase udb = UserDatabaseManager.getInstance().getUserDatabase(session.getRealm());
for (String account : selectedAccounts) {
try {
udb.getAccount(account);
} catch (Exception e) {
errs.add(Globals.ERROR_KEY, new ActionMessage("editPolicy.error.invalidUser", account));
}
}
for (String role : selectedRoles) {
try {
if (udb.getRole(role) == null) {
throw new Exception();
}
} catch (Exception e) {
errs.add(Globals.ERROR_KEY, new ActionMessage("editPolicy.error.invalidRole", role));
}
}
} catch (Exception e) {
errs.add(Globals.ERROR_KEY, new ActionMessage("editPolicy.failedToValidate", e.getMessage()));
}
SessionInfo info = LogonControllerFactory.getInstance().getSessionInfo(request);
boolean found = false;
try {
List wasAttached = PolicyDatabaseFactory.getInstance().getPrincipalsGrantedPolicy((Policy) this.getResource(),
info.getUser().getRealm()); // objects
List nowAttached = this.getSelectedAccountsList();
// only do this if the super user has been removed.
if (wasAttached.contains(getUser()) && !nowAttached.contains(getUser().getPrincipalName())) {
List authSchemes = ResourceUtil.getGrantedResource(info, PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE);
for (Iterator iter = authSchemes.iterator(); iter.hasNext();) {
AuthenticationScheme element = (DefaultAuthenticationScheme) iter.next();
if (!element.isSystemScheme() && element.getEnabled()) {
List attachedPolicies = PolicyDatabaseFactory.getInstance().getPoliciesAttachedToResource(element,
info.getUser().getRealm());
for (Iterator iterator = attachedPolicies.iterator(); iterator.hasNext();) {
Policy policy = (Policy) iterator.next();
if (!this.getResource().equals(policy)
&& PolicyDatabaseFactory.getInstance().isPolicyGrantedToUser(policy, getUser())) {
found = true;