use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class GroupsByPermissionTag method getAllowedGroups.
protected Set<String> getAllowedGroups() {
Set<String> groupCodes = new HashSet<String>();
UserDetails currentUser = (UserDetails) this.pageContext.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
String permissionName = this.getPermission();
if (null != currentUser && null != permissionName) {
IAuthorizationManager authManager = (IAuthorizationManager) ApsWebApplicationUtils.getBean(SystemConstants.AUTHORIZATION_SERVICE, this.pageContext);
List<Group> groupsByPermission = authManager.getGroupsByPermission(currentUser, permissionName);
if (null != groupsByPermission) {
for (Group group : groupsByPermission) {
if (null != group) {
groupCodes.add(group.getName());
}
}
}
}
return groupCodes;
}
use of com.agiletec.aps.system.services.group.Group 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.group.Group in project entando-core by entando.
the class ContentGroupBulkAction method join.
public String join() {
try {
String groupName = this.getGroupName();
Group group = this.getGroupManager().getGroup(groupName);
if (null != group) {
this.getExtraGroupNames().add(groupName);
}
} catch (Throwable t) {
_logger.error("Error joining group for bulk action", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class BaseContentDispenser method getRenderizationInfo.
protected ContentRenderizationInfo getRenderizationInfo(PublicContentAuthorizationInfo authInfo, String contentId, long modelId, String langCode, RequestContext reqCtx, boolean cacheable) {
ContentRenderizationInfo renderInfo = null;
try {
UserDetails currentUser = (null != reqCtx) ? (UserDetails) reqCtx.getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER) : null;
List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
if (authInfo.isUserAllowed(userGroups)) {
renderInfo = this.getBaseRenderizationInfo(authInfo, contentId, modelId, langCode, currentUser, reqCtx, cacheable);
if (null == renderInfo) {
return null;
}
} else {
String renderedContent = "Current user '" + currentUser.getUsername() + "' can't view this content";
Content contentToRender = this.getContentManager().loadContent(contentId, true, cacheable);
renderInfo = new ContentRenderizationInfo(contentToRender, renderedContent, modelId, langCode, null);
renderInfo.setRenderedContent(renderedContent);
return renderInfo;
}
} catch (Throwable t) {
_logger.error("Error while rendering content {}", contentId, t);
return null;
}
return renderInfo;
}
use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class BaseContentDispenser method getBaseRenderizationInfo.
public ContentRenderizationInfo getBaseRenderizationInfo(PublicContentAuthorizationInfo authInfo, String contentId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx, boolean cacheable) {
ContentRenderizationInfo renderInfo = null;
try {
List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
if (authInfo.isUserAllowed(userGroups)) {
Content contentToRender = this.getContentManager().loadContent(contentId, true, cacheable);
String renderedContent = this.buildRenderedContent(contentToRender, modelId, langCode, reqCtx);
if (null != renderedContent && renderedContent.trim().length() > 0) {
List<AttributeRole> roles = this.getContentManager().getAttributeRoles();
renderInfo = new ContentRenderizationInfo(contentToRender, renderedContent, modelId, langCode, roles);
}
}
} catch (Throwable t) {
_logger.error("Error while rendering content {}", contentId, t);
return null;
}
return renderInfo;
}
Aggregations