Search in sources :

Example 6 with Authorization

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);
    }
}
Also used : Authorization(com.agiletec.aps.system.services.authorization.Authorization)

Example 7 with 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);
}
Also used : Authorization(com.agiletec.aps.system.services.authorization.Authorization) UserDetails(com.agiletec.aps.system.services.user.UserDetails) MockUser(com.agiletec.aps.system.services.user.MockUser)

Example 8 with Authorization

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);
}
Also used : Role(com.agiletec.aps.system.services.role.Role) Authorization(com.agiletec.aps.system.services.authorization.Authorization) Group(com.agiletec.aps.system.services.group.Group)

Example 9 with Authorization

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);
}
Also used : Authorization(com.agiletec.aps.system.services.authorization.Authorization)

Example 10 with Authorization

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;
}
Also used : Authorization(com.agiletec.aps.system.services.authorization.Authorization) ArrayList(java.util.ArrayList)

Aggregations

Authorization (com.agiletec.aps.system.services.authorization.Authorization)13 UserDetails (com.agiletec.aps.system.services.user.UserDetails)3 Group (com.agiletec.aps.system.services.group.Group)2 Role (com.agiletec.aps.system.services.role.Role)2 MockUser (com.agiletec.aps.system.services.user.MockUser)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2