use of com.agiletec.aps.system.services.authorization.Authorization in project entando-core by entando.
the class TestContentAuthorization 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 BaseContentListHelper 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 (Authorization auth : auths) {
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 BaseContentDispenser method getRenderizationInfoCacheKey.
public static String getRenderizationInfoCacheKey(String contentId, long modelId, String langCode, RequestContext reqCtx) {
UserDetails currentUser = (null != reqCtx) ? (UserDetails) reqCtx.getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER) : null;
StringBuffer key = new StringBuffer();
key.append(contentId).append("_").append(modelId).append("_").append(langCode).append("_RENDER_INFO_CacheKey");
if (null != currentUser && !currentUser.getUsername().equals(SystemConstants.GUEST_USER_NAME)) {
List<String> codes = new ArrayList<String>();
if (null != currentUser.getAuthorizations()) {
for (int i = 0; i < currentUser.getAuthorizations().size(); i++) {
Authorization auth = currentUser.getAuthorizations().get(i);
if (null != auth && null != auth.getGroup()) {
String code = auth.getGroup().getAuthority() + "_";
if (null != auth.getRole()) {
code += auth.getRole().getAuthority();
} else {
code += "null";
}
codes.add(code);
}
}
}
if (!codes.isEmpty()) {
key.append("_AUTHS:");
appendAuthCodes(codes, key);
}
}
return key.toString();
}
Aggregations