use of com.agiletec.aps.system.services.authorization.Authorization in project entando-core by entando.
the class BaseDataListHelper method getAllowedGroupCodes.
public static Collection<String> getAllowedGroupCodes(UserDetails user) {
Set<String> codes = new HashSet<String>();
codes.add(Group.FREE_GROUP_NAME);
List<Authorization> auths = (null != user) ? user.getAuthorizations() : null;
if (null != auths) {
for (int i = 0; i < auths.size(); i++) {
Authorization auth = auths.get(i);
if (null != auth && null != auth.getGroup()) {
codes.add(auth.getGroup().getName());
}
}
}
return codes;
}
use of com.agiletec.aps.system.services.authorization.Authorization in project entando-core by entando.
the class MockUser method addAuthorization.
public void addAuthorization(Group group, Role role) {
if (null == group)
return;
Authorization auth = new Authorization(group, role);
super.addAuthorization(auth);
}
use of com.agiletec.aps.system.services.authorization.Authorization in project entando-core by entando.
the class TestAuthenticationProviderManager method addUserForTest.
private void addUserForTest(String username, String password) throws Throwable {
MockUser user = new MockUser();
user.setUsername(username);
user.setPassword(password);
Authorization auth = new Authorization(this._groupManager.getGroup(Group.FREE_GROUP_NAME), this._roleManager.getRole("editor"));
user.addAuthorization(auth);
this._userManager.removeUser(user);
UserDetails extractedUser = _userManager.getUser(username);
assertNull(extractedUser);
this._userManager.addUser(user);
this._authorizationManager.addUserAuthorization(username, auth);
}
use of com.agiletec.aps.system.services.authorization.Authorization in project entando-core by entando.
the class UserAuthorizationAction method addAuthorization.
public String addAuthorization() {
try {
if (!this.checkAuthorizationSessionBean()) {
return "userList";
}
String groupName = this.getGroupName();
String roleName = this.getRoleName();
Group group = this.getGroupManager().getGroup(groupName);
Role role = this.getRoleManager().getRole(roleName);
if (!StringUtils.isEmpty(groupName) && null == group) {
this.addFieldError("groupName", this.getText("error.userAuthorization.invalidGroup", new String[] { groupName }));
}
if (!StringUtils.isEmpty(roleName) && null == role) {
this.addFieldError("roleName", this.getText("error.userAuthorization.invalidRole", new String[] { groupName }));
}
if (null == group && null == role) {
this.addFieldError("groupName", this.getText("error.userAuthorization.invalidGroupAndRole"));
this.addFieldError("roleName", this.getText("error.userAuthorization.invalidGroupAndRole"));
}
if (this.hasFieldErrors()) {
return INPUT;
}
Authorization authorization = new Authorization(group, role);
boolean result = this.getUserAuthsFormBean().addAuthorization(authorization);
if (!result) {
this.addActionError(this.getText("error.userAuthorization.alreadyExists", new String[] { groupName, roleName }));
return INPUT;
}
} catch (Throwable t) {
_logger.error("error adding user authorization", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.authorization.Authorization in project entando-core by entando.
the class AbstractUser method addAuthorizations.
@Override
public void addAuthorizations(List<Authorization> auths) {
for (int i = 0; i < auths.size(); i++) {
Authorization auth = auths.get(i);
this.addAuthorization(auth);
}
}
Aggregations