use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class GroupAction method delete.
public String delete() {
try {
String check = this.checkGroupForDelete();
if (null != check)
return check;
IGroupManager groupManager = this.getGroupManager();
Group group = groupManager.getGroup(this.getName());
this.getGroupManager().removeGroup(group);
} catch (Throwable t) {
_logger.error("error in delete", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class UserControllerIntegrationTest method shouldAddUserAuthorities.
@Test
public void shouldAddUserAuthorities() throws Exception {
Group group = createGroup(1);
Role role = createRole(1);
try {
this.groupManager.addGroup(group);
this.roleManager.addRole(role);
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
String mockJson = "[{\"group\":\"group1\", \"role\":\"role1\"}]";
ResultActions result = mockMvc.perform(put("/users/{target}/authorities", "mockuser").sessionAttr("user", user).content(mockJson).contentType(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + accessToken));
result.andExpect(status().isOk());
result.andExpect(jsonPath("$.payload[0].group", is("group1")));
} finally {
this.authorizationManager.deleteUserAuthorizations("mockuser");
this.groupManager.removeGroup(group);
this.roleManager.removeRole(role);
}
}
use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class UserControllerIntegrationTest method createGroup.
private Group createGroup(int i) {
Group group = new Group();
group.setDescription("descr" + i);
group.setName("group" + i);
return group;
}
use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.
the class ContentPreviewDispenser method getBaseRenderizationInfo.
@Override
public ContentRenderizationInfo getBaseRenderizationInfo(PublicContentAuthorizationInfo authInfo, String contentId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx) {
ContentRenderizationInfo renderInfo = null;
try {
List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
if (authInfo.isUserAllowed(userGroups)) {
Content contentOnSession = this.extractContentOnSession(reqCtx);
String renderedContent = this.buildRenderedContent(contentOnSession, modelId, langCode, reqCtx);
if (null != renderedContent && renderedContent.trim().length() > 0) {
List<AttributeRole> roles = this.getContentManager().getAttributeRoles();
renderInfo = new ContentRenderizationInfo(contentOnSession, renderedContent, modelId, langCode, roles);
}
}
} 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 PublicContentAuthorizationInfo method isUserAllowed.
/**
* Verifica i permessi dell'utente in accesso al contenuto.
* Restituisce true se l'utente specificato è abilitato
* ad accedere al contenuto, false in caso contrario.
* @param userGroups I gruppi dell'utente di cui verificarne l'abilitazione.
* @return true se l'utente specificato è abilitato ad accedere
* al contenuto, false in caso contrario.
*/
public boolean isUserAllowed(List<Group> userGroups) {
if (null == userGroups) {
userGroups = new ArrayList<Group>();
}
Set<String> codes = new HashSet<String>();
for (int i = 0; i < userGroups.size(); i++) {
Group group = userGroups.get(i);
codes.add(group.getAuthority());
}
return this.isUserAllowed(codes);
}
Aggregations