Search in sources :

Example 1 with AuthorizationRepresentation

use of org.neo4j.server.rest.repr.AuthorizationRepresentation in project neo4j by neo4j.

the class UserService method getUser.

@GET
@Path("/{username}")
public Response getUser(@PathParam("username") String username, @Context HttpServletRequest req) {
    Principal principal = req.getUserPrincipal();
    if (principal == null || !principal.getName().equals(username)) {
        return output.notFound();
    }
    SecurityContext securityContext = getSecurityContextFromUserPrincipal(principal);
    UserManager userManager = userManagerSupplier.getUserManager(securityContext);
    try {
        User user = userManager.getUser(username);
        return output.ok(new AuthorizationRepresentation(user));
    } catch (InvalidArgumentsException e) {
        return output.notFound();
    }
}
Also used : User(org.neo4j.kernel.impl.security.User) UserManager(org.neo4j.kernel.api.security.UserManager) SecurityContext(org.neo4j.kernel.api.security.SecurityContext) AuthorizationRepresentation(org.neo4j.server.rest.repr.AuthorizationRepresentation) InvalidArgumentsException(org.neo4j.kernel.api.exceptions.InvalidArgumentsException) AuthorizedRequestWrapper.getSecurityContextFromUserPrincipal(org.neo4j.server.rest.dbms.AuthorizedRequestWrapper.getSecurityContextFromUserPrincipal) Principal(java.security.Principal) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

Principal (java.security.Principal)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 InvalidArgumentsException (org.neo4j.kernel.api.exceptions.InvalidArgumentsException)1 SecurityContext (org.neo4j.kernel.api.security.SecurityContext)1 UserManager (org.neo4j.kernel.api.security.UserManager)1 User (org.neo4j.kernel.impl.security.User)1 AuthorizedRequestWrapper.getSecurityContextFromUserPrincipal (org.neo4j.server.rest.dbms.AuthorizedRequestWrapper.getSecurityContextFromUserPrincipal)1 AuthorizationRepresentation (org.neo4j.server.rest.repr.AuthorizationRepresentation)1