use of com.agiletec.aps.system.services.authorization.Authorization in project entando-core by entando.
the class AuthenticationProviderManager method addUserAuthorizations.
protected void addUserAuthorizations(UserDetails user) throws ApsSystemException {
if (null == user) {
return;
}
List<Authorization> auths = this.getAuthorizationManager().getUserAuthorizations(user.getUsername());
if (null == auths) {
return;
}
for (int i = 0; i < auths.size(); i++) {
Authorization authorization = auths.get(i);
user.addAuthorization(authorization);
}
}
use of com.agiletec.aps.system.services.authorization.Authorization in project entando-core by entando.
the class TestDataObjectAuthorization method addUserForTest.
private void addUserForTest(String username, String password) throws Throwable {
MockUser user = new MockUser();
user.setUsername(username);
user.setPassword(password);
user.setDisabled(false);
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 OAuth2TestUtils method addAuthorization.
public static void addAuthorization(User user, String groupName, String roleName, String[] permissions) {
Group group = null;
if (StringUtils.isNotBlank(groupName)) {
group = new Group();
group.setName(groupName);
group.setDescription(groupName + " descr");
}
Role role = null;
if (StringUtils.isNotBlank(roleName)) {
role = new Role();
role.setName(roleName);
role.setDescription(roleName + " descr");
if (null != permissions) {
for (String permissionName : permissions) {
role.addPermission(permissionName);
}
}
}
Authorization auth = new Authorization(group, role);
user.addAuthorization(auth);
}
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 ActionLogManager method extractUserGroupCodes.
private List<String> extractUserGroupCodes(UserDetails loggedUser) {
List<String> codes = new ArrayList<String>();
List<Authorization> auths = (null != loggedUser) ? loggedUser.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());
}
}
}
if (!codes.contains(Group.FREE_GROUP_NAME)) {
codes.add(Group.FREE_GROUP_NAME);
}
return codes;
}
Aggregations