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.DashboardController.java

@Override
@RequestMapping(value = "/{dashboardId}", method = RequestMethod.PUT)
@ResponseBody/*from  ww w .  j a v a  2s .  co  m*/
@ResponseStatus(OK)
@ApiOperation("Update specified dashboard for specified project")
public OperationCompletionRS updateDashboard(@PathVariable String projectName, @PathVariable String dashboardId,
        @RequestBody @Validated UpdateDashboardRQ updateRQ, Principal principal) {
    return updateHandler.updateDashboard(updateRQ, dashboardId, principal.getName(),
            EntityUtils.normalizeProjectName(projectName));
}

From source file:runtheshow.resource.webservice.InvitationService.java

/**
 * // w w  w.j  a va 2  s. com
 * @param user
 * @return 
 */
@RequestMapping(value = "/retreiveSentInvit", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
public List<Invitation> retreiveSentInvit(Principal user) {
    return userMetier.getAllInvitationUserSent(userMetier.getUserByName(user.getName()));
}

From source file:sample.U2fController.java

@RequestMapping("/u2f/authenticate")
public String authenticateForm(Principal principal, Map<String, Object> model)
        throws NoEligableDevicesException {
    String username = principal.getName();
    // Generate a challenge for each U2F device that this user has
    // registered
    AuthenticateRequestData requestData = u2f.startAuthentication(SERVER_ADDRESS, getRegistrations(username));

    // Store the challenges for future reference
    requestStorage.save(requestData);//www.  j  a  va  2s  .c  o  m

    // Return an HTML page containing the challenges
    model.put("data", requestData.toJson());
    return "u2f/authenticate";
}

From source file:com.salesmanager.core.module.impl.application.logon.CustomLogonImpl.java

@Override
public String getUser(HttpServletRequest request) throws ServiceException {
    // TODO Auto-generated method stub

    HttpSession session = request.getSession();
    Principal p = (Principal) session.getAttribute("PRINCIPAL");

    if (p != null) {
        return p.getName();
    } else {//from  ww  w  . j  a  v a  2s. com
        throw new ServiceException("User does not exist");
    }

}

From source file:com.eretailservice.security.BookingRestController.java

@RequestMapping(method = RequestMethod.GET)
Resources<BookingResource> readBookings(Principal principal) {
    this.validateUser(principal);

    List<BookingResource> bookingResourceList = bookingRepository.findByAccountUsername(principal.getName())
            .stream().map(BookingResource::new).collect(Collectors.toList());

    return new Resources<>(bookingResourceList);
}

From source file:runtheshow.resource.webservice.InvitationService.java

/**
 * //from  w ww. j  a  va 2  s  .c  o  m
 * @param user
 * @return 
 */
@RequestMapping(value = "/retreiveReceivedInvit", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
public List<Invitation> retreiveReceivedInvit(Principal user) {
    return userMetier.getAllInvitationUserReceived(userMetier.getUserByName(user.getName()));
}

From source file:info.fcrp.keepitsafe.service.KeepService.java

@RequestMapping(method = RequestMethod.POST)
public @ResponseBody Keep create(@RequestBody Keep keep, Principal principal) {
    for (Secret sc : keep.getSecrets()) {
        sc.setKeep(keep);//  w  ww.  j  ava2  s. c  om
    }
    keep.getRoleMap().setKing("user:" + principal.getName());

    keepDAO.save(keep);
    return keep;
}

From source file:org.ng200.openolympus.controller.contest.ContestViewController.java

@PreAuthorize(SecurityExpressionConstants.IS_ADMIN + SecurityExpressionConstants.OR + '('
        + SecurityExpressionConstants.IS_USER + SecurityExpressionConstants.AND
        + SecurityExpressionConstants.THIS_CONTEST_IN_PROGRESS_FOR_USER + ')')
@Cacheable(value = "contests", key = "#contest.id", unless = "#result == null")
@RequestMapping(value = "/api/contest/{contest}", method = RequestMethod.GET)
@JsonView(UnprivilegedView.class)
public ContestDTO showContestHub(@PathVariable(value = "contest") final Contest contest,
        final Principal principal) {
    User user = userService.getUserByUsername(principal.getName());
    Set<Task> tasks = new HashSet<Task>(contest.getTasks());
    return new ContestDTO(contest.getName(),
            new TimingDTO(contest.getStartTime(),
                    Date.from(contest.getStartTime().toInstant().plus(contest.getDuration())),
                    contestService.getContestEndTimeForUser(contest, user)),
            tasks);// w ww .  ja va2s. co  m
}

From source file:org.starfishrespect.myconsumption.server.business.controllers.UserController.java

@RequestMapping(value = "/{name}", method = RequestMethod.DELETE)
public SimpleResponseDTO deleteUser(Principal principal, @PathVariable String name) {

    // Check if this user can access this resource
    if (!(principal.getName().equals(name)))
        return new SimpleResponseDTO(false, "you are not allowed to delete this user");

    mUserRepository.deleteUser(name);/*w w w.ja  v a  2  s.c om*/

    return new SimpleResponseDTO(true, "user deleted");
}

From source file:com.github.jguaneri.notifications.web.controller.NotificationController.java

@RequestMapping(value = "/acknowledge/{notificationId}", method = RequestMethod.POST)
public void acknowledge(@PathVariable("notificationId") String notificationId, Principal principal)
        throws Exception {
    notificationService.acknowledgeNotification(notificationId, principal.getName());
}