Search in sources :

Example 1 with ANNISSecurityManager

use of annis.security.ANNISSecurityManager in project ANNIS by korpling.

the class AdminServiceImpl method deleteGroup.

@DELETE
@Path("groups/{groupName}")
public Response deleteGroup(@PathParam("groupName") String groupName) {
    Subject requestingUser = SecurityUtils.getSubject();
    requestingUser.checkPermission("admin:write:group");
    if (SecurityUtils.getSecurityManager() instanceof ANNISSecurityManager) {
        ANNISUserConfigurationManager confManager = getConfManager();
        if (confManager != null) {
            if (confManager.deleteGroup(groupName)) {
                return Response.ok().build();
            }
        }
    }
    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Could not delete group").build();
}
Also used : ANNISUserConfigurationManager(annis.security.ANNISUserConfigurationManager) ANNISSecurityManager(annis.security.ANNISSecurityManager) Subject(org.apache.shiro.subject.Subject) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 2 with ANNISSecurityManager

use of annis.security.ANNISSecurityManager in project ANNIS by korpling.

the class AdminServiceImpl method listUsers.

@GET
@Path("users")
@Produces("application/xml")
public List<User> listUsers() {
    Subject requestingUser = SecurityUtils.getSubject();
    requestingUser.checkPermission("admin:read:user");
    if (SecurityUtils.getSecurityManager() instanceof ANNISSecurityManager) {
        ANNISUserConfigurationManager confManager = getConfManager();
        if (confManager != null) {
            return confManager.listAllUsers();
        }
    }
    return new LinkedList<>();
}
Also used : ANNISUserConfigurationManager(annis.security.ANNISUserConfigurationManager) ANNISSecurityManager(annis.security.ANNISSecurityManager) Subject(org.apache.shiro.subject.Subject) LinkedList(java.util.LinkedList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with ANNISSecurityManager

use of annis.security.ANNISSecurityManager in project ANNIS by korpling.

the class AdminServiceImpl method deleteUser.

@DELETE
@Path("users/{userName}")
public Response deleteUser(@PathParam("userName") String userName) {
    Subject requestingUser = SecurityUtils.getSubject();
    requestingUser.checkPermission("admin:write:user");
    if (SecurityUtils.getSecurityManager() instanceof ANNISSecurityManager) {
        ANNISUserConfigurationManager confManager = getConfManager();
        if (confManager != null) {
            if (confManager.deleteUser(userName)) {
                // also delete any possible user configs
                adminDao.deleteUserConfig(userName);
                // if no error until here everything went well
                return Response.ok().build();
            }
        }
    }
    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Could not delete user").build();
}
Also used : ANNISUserConfigurationManager(annis.security.ANNISUserConfigurationManager) ANNISSecurityManager(annis.security.ANNISSecurityManager) Subject(org.apache.shiro.subject.Subject) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 4 with ANNISSecurityManager

use of annis.security.ANNISSecurityManager in project ANNIS by korpling.

the class AdminServiceImpl method updateOrCreateGroup.

@PUT
@Path("groups/{groupName}")
@Consumes("application/xml")
public Response updateOrCreateGroup(Group group, @PathParam("groupName") String groupName) {
    Subject requestingUser = SecurityUtils.getSubject();
    requestingUser.checkPermission("admin:write:group");
    if (!groupName.equals(group.getName())) {
        return Response.status(Response.Status.BAD_REQUEST).entity("Group name in object is not the same as in path").build();
    }
    if (SecurityUtils.getSecurityManager() instanceof ANNISSecurityManager) {
        ANNISUserConfigurationManager confManager = getConfManager();
        if (confManager != null) {
            if (confManager.writeGroup(group)) {
                return Response.ok().build();
            }
        }
    }
    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Could not update/create group").build();
}
Also used : ANNISUserConfigurationManager(annis.security.ANNISUserConfigurationManager) ANNISSecurityManager(annis.security.ANNISSecurityManager) Subject(org.apache.shiro.subject.Subject) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 5 with ANNISSecurityManager

use of annis.security.ANNISSecurityManager in project ANNIS by korpling.

the class AdminServiceImpl method listGroups.

@GET
@Path("groups")
@Produces("application/xml")
public List<Group> listGroups() {
    Subject requestingUser = SecurityUtils.getSubject();
    requestingUser.checkPermission("admin:read:group");
    if (SecurityUtils.getSecurityManager() instanceof ANNISSecurityManager) {
        ANNISUserConfigurationManager confManager = getConfManager();
        if (confManager != null) {
            return new LinkedList<>(confManager.getGroups().values());
        }
    }
    return new LinkedList<>();
}
Also used : ANNISUserConfigurationManager(annis.security.ANNISUserConfigurationManager) ANNISSecurityManager(annis.security.ANNISSecurityManager) Subject(org.apache.shiro.subject.Subject) LinkedList(java.util.LinkedList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

ANNISSecurityManager (annis.security.ANNISSecurityManager)5 ANNISUserConfigurationManager (annis.security.ANNISUserConfigurationManager)5 Path (javax.ws.rs.Path)5 Subject (org.apache.shiro.subject.Subject)5 LinkedList (java.util.LinkedList)2 DELETE (javax.ws.rs.DELETE)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1