use of org.apache.shiro.authz.annotation.RequiresRoles in project mica2 by obiba.
the class DataAccessFormResource method permissions.
@Path("/permissions")
@RequiresRoles(Roles.MICA_ADMIN)
public SubjectAclResource permissions() {
SubjectAclResource subjectAclResource = applicationContext.getBean(SubjectAclResource.class);
subjectAclResource.setResourceInstance("/data-access-request", "*");
subjectAclResource.addOtherResourceName("action-logs");
subjectAclResource.addOtherResourceName("private-comment");
subjectAclResource.setFileResourceInstance("/file", "/data-access-request");
return subjectAclResource;
}
use of org.apache.shiro.authz.annotation.RequiresRoles in project shiro by apache.
the class RoleAnnotationHandlerTest method testGuestMultipleRolesAssertion.
// Added to satisfy SHIRO-146
@Test(expected = UnauthenticatedException.class)
public void testGuestMultipleRolesAssertion() throws Throwable {
RoleAnnotationHandler handler = new RoleAnnotationHandler();
Annotation requiresRolesAnnotation = new RequiresRoles() {
public String[] value() {
return new String[] { "blah", "blah2" };
}
public Class<? extends Annotation> annotationType() {
return RequiresRoles.class;
}
public Logical logical() {
return Logical.AND;
}
};
handler.assertAuthorized(requiresRolesAnnotation);
}
use of org.apache.shiro.authz.annotation.RequiresRoles in project shiro by apache.
the class AccountInfoController method home.
@RequiresRoles("admin")
@RequestMapping("/account-info")
public String home(Model model) {
String name = "World";
Subject subject = SecurityUtils.getSubject();
PrincipalCollection principalCollection = subject.getPrincipals();
if (principalCollection != null && !principalCollection.isEmpty()) {
name = principalCollection.getPrimaryPrincipal().toString();
}
model.addAttribute("name", name);
return "account-info";
}
Aggregations