Example usage for java.security Principal getName

List of usage examples for java.security Principal getName

Introduction

In this page you can find the example usage for java.security Principal getName.

Prototype

public String getName();

Source Link

Document

Returns the name of this principal.

Usage

From source file:com.epam.ta.reportportal.ws.controller.impl.ProjectSettingsController.java

@Override
@RequestMapping(value = "/sub-type/{id}", method = RequestMethod.DELETE)
@ResponseBody/*from w  ww . j a  v  a2s . c  o m*/
@ResponseStatus(OK)
@PreAuthorize(PROJECT_LEAD)
@ApiOperation("Delete custom project specific issue sub-type")
public OperationCompletionRS deleteProjectIssueSubType(@PathVariable String projectName,
        @PathVariable String id, Principal principal) {
    return deleteSettings.deleteProjectIssueSubType(EntityUtils.normalizeProjectName(projectName),
            principal.getName(), id);
}

From source file:alfio.controller.api.admin.UtilsApiController.java

@RequestMapping(value = "/alfio/info", method = GET)
public Map<String, Object> getApplicationInfo(Principal principal) {
    Map<String, Object> applicationInfo = new HashMap<>();
    applicationInfo.put("version", version);
    applicationInfo.put("username", principal.getName());
    applicationInfo.put("isDemoMode", environment.acceptsProfiles(Initializer.PROFILE_DEMO));
    return applicationInfo;
}

From source file:eu.openanalytics.shinyproxy.controllers.BaseController.java

protected String getUserName(HttpServletRequest request) {
    Principal principal = request.getUserPrincipal();
    String username = (principal == null) ? request.getSession().getId() : principal.getName();
    return username;
}

From source file:com.epam.ta.reportportal.ws.controller.impl.UserFilterController.java

@Override
@RequestMapping(value = "/{filterId}", method = RequestMethod.DELETE)
@ResponseBody//from  w w  w  .j  a  v a2 s  .c  om
@ResponseStatus(HttpStatus.OK)
@ApiOperation("Delete specified user filter by id")
public OperationCompletionRS deleteFilter(@PathVariable String projectName, @PathVariable String filterId,
        Principal principal) {
    return deleteFilterHandler.deleteFilter(filterId, principal.getName(),
            EntityUtils.normalizeProjectName(projectName));
}

From source file:com.lixiaocong.rest.CommentController.java

@RequestMapping(method = RequestMethod.POST)
public Map<String, Object> post(@RequestParam long articleId, @RequestBody @Valid CommentForm comment,
        BindingResult result, Principal principal) throws RestParamException {
    if (result.hasErrors())
        throw new RestParamException();
    User user = userService.getByUsername(principal.getName());

    commentService.create(articleId, user.getId(), comment.getContent());
    return ResponseMsgFactory.createSuccessResponse();
}

From source file:org.fcrepo.auth.roles.basic.BasicRolesPEP.java

private Set<String> getRoles(final Session session, final Set<Principal> principals, final Node node)
        throws RepositoryException {
    final Set<String> result = new HashSet<String>();
    final Map<String, List<String>> acl = this.getAccessRolesProvider().getRoles(node, true);
    for (final Principal p : principals) {
        final List<String> roles = acl.get(p.getName());
        if (roles != null) {
            log.debug("request principal matched role assignment: " + p.getName());
            result.addAll(roles);/* w w w.  j ava 2 s .  c o m*/
        }
    }
    return result;
}

From source file:com.deepsky.spring_security.samples.ServletApiController.java

@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(@ModelAttribute LoginForm loginForm, HttpServletRequest request) {
    Principal principal = request.getUserPrincipal();
    if (principal != null) {
        System.out.println("User principal: " + principal.getName());
    } else {//from  w  w  w.  j a  va 2  s  .  c o m
        System.out.println("Principal is null");
    }

    return "login1";
}

From source file:com.lixiaocong.rest.UserController.java

@RequestMapping(method = RequestMethod.PUT)
public Map<String, Object> put(@RequestBody @Valid UserUpdateForm userUpdateForm, BindingResult result,
        Principal principal) throws RestParamException {
    if (result.hasErrors())
        throw new RestParamException();

    User user = userService.getByUsername(principal.getName());
    user.setPassword(this.encoder.encode(userUpdateForm.getPassword()));
    userService.update(user);/*w  w  w . j  a  v a  2  s  .  co m*/
    return ResponseMsgFactory.createSuccessResponse();
}

From source file:com.epam.ta.reportportal.ws.controller.impl.DashboardController.java

@Override
@RequestMapping(method = RequestMethod.POST)
@ResponseStatus(CREATED)/*from w  w w.  j  a  v  a 2 s  .c  o m*/
@ResponseBody
@ApiOperation("Create dashboard for specified project")
public EntryCreatedRS createDashboard(@PathVariable String projectName,
        @RequestBody @Validated CreateDashboardRQ createRQ, Principal principal) {
    return createHandler.createDashboard(EntityUtils.normalizeProjectName(projectName), createRQ,
            principal.getName());
}

From source file:us.repasky.microblog.controllers.FollowController.java

@RequestMapping(value = "/follow", method = RequestMethod.GET)
public String follow(Map<String, Object> model, final Principal principal) {
    logger.trace("executing inside FollowController follow()");
    String view = "follow";
    String myUsername = principal.getName();
    List<String> following = userService.getFollowingList(myUsername);
    model.put("following", following);
    return view;/*from   w  w  w . j ava2s.c  o m*/
}