List of usage examples for java.security Principal getName
public String getName();
From source file:alfio.controller.api.admin.CheckInApiController.java
@RequestMapping(value = "/check-in/{eventName}/label-layout", method = GET) public ResponseEntity<LabelLayout> getLabelLayoutForEvent(@PathVariable("eventName") String eventName, Principal principal) { return optionally(() -> eventManager.getSingleEvent(eventName, principal.getName())) .filter(checkInManager.isOfflineCheckInAndLabelPrintingEnabled()).map(this::parseLabelLayout) .orElseGet(() -> new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED)); }
From source file:us.repasky.microblog.controllers.UserController.java
@RequestMapping(value = "/", method = RequestMethod.GET) public String showPostsFromFollowers(@RequestParam(defaultValue = "0") final String page, Map<String, Object> model, final Principal principal) { logger.trace("executing inside UserController showPostsFromFollowers()"); String myUsername = principal.getName(); Page<Post> posts = userService.getAllFollowersPostsForUser(myUsername, readPageNumber(page)); model.put("posts", posts); if (!model.containsKey("post")) { model.put("post", new Post()); }/* w w w . java 2 s .co m*/ return "createPost"; }
From source file:com.epam.ta.reportportal.ws.controller.impl.ExternalSystemController.java
@Override @RequestMapping(method = RequestMethod.POST, value = "{systemId}/ticket") @ResponseBody/*w w w .ja v a2s. co m*/ @ResponseStatus(HttpStatus.CREATED) @ApiOperation("Post ticket to external system") public Ticket createIssue(@Validated @RequestBody PostTicketRQ ticketRQ, @PathVariable String projectName, @PathVariable String systemId, Principal principal) { return createTicketHandler.createIssue(ticketRQ, EntityUtils.normalizeProjectName(projectName), systemId, principal.getName()); }
From source file:com.epam.ta.reportportal.ws.controller.impl.TestItemController.java
@DeleteMapping("/{item}") @ResponseBody/*w w w . jav a 2 s . co m*/ @ResponseStatus(OK) @Override @ApiOperation("Delete test item") public OperationCompletionRS deleteTestItem(@PathVariable String projectName, @PathVariable String item, Principal principal) { return deleteTestItemHandler.deleteTestItem(item, normalizeProjectName(projectName), principal.getName()); }
From source file:alfio.controller.api.AdminApiController.java
@RequestMapping(value = "/events/{eventName}/pending-payments/{reservationId}/confirm", method = POST) public String confirmPayment(@PathVariable("eventName") String eventName, @PathVariable("reservationId") String reservationId, Principal principal) { eventManager.confirmPayment(eventName, reservationId, principal.getName()); return OK;// w ww.ja v a 2 s.c o m }
From source file:com.epam.ta.reportportal.ws.controller.impl.ExternalSystemController.java
@Override @RequestMapping(value = "/clear", method = RequestMethod.DELETE) @ResponseBody//from w ww . j a v a 2 s . c om @PreAuthorize(PROJECT_LEAD) @ResponseStatus(HttpStatus.OK) @ApiOperation("Delete all external system assigned to specified project") public OperationCompletionRS deleteAllExternalSystems(@PathVariable String projectName, Principal principal) { return deleteExternalSystemHandler.deleteAllExternalSystems(EntityUtils.normalizeProjectName(projectName), principal.getName()); }
From source file:alfio.controller.api.admin.AdminWaitingQueueApiController.java
private ResponseEntity<Map<String, Object>> performStatusModification(String eventName, int subscriberId, Principal principal, WaitingQueueSubscription.Status newStatus, WaitingQueueSubscription.Status currentStatus) { return optionally(() -> eventManager.getSingleEvent(eventName, principal.getName())) .flatMap(e -> waitingQueueManager.updateSubscriptionStatus(subscriberId, newStatus, currentStatus) .map(s -> Pair.of(s, e))) .map(pair -> {/*w w w. j a va 2 s .c om*/ Map<String, Object> out = new HashMap<>(); out.put("modified", pair.getLeft()); out.put("list", waitingQueueManager.loadAllSubscriptionsForEvent(pair.getRight().getId())); return out; }).map(ResponseEntity::ok).orElseGet(() -> new ResponseEntity<>(HttpStatus.BAD_REQUEST)); }
From source file:com.epam.ta.reportportal.ws.controller.impl.TestItemController.java
@Override @PutMapping("/issue/add") @ResponseBody// w w w . java2 s . c o m @ResponseStatus(OK) @PreAuthorize(ASSIGNED_TO_PROJECT) @ApiOperation("Attach external issue for specified test items") public List<OperationCompletionRS> addExternalIssues(@PathVariable String projectName, @RequestBody @Validated AddExternalIssueRQ rq, Principal principal) { return updateTestItemHandler.addExternalIssues(normalizeProjectName(projectName), rq, principal.getName()); }
From source file:org.magnum.mobilecloud.video.Assign2Controller.java
@RequestMapping(value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/like", method = RequestMethod.POST) public @ResponseBody void likeVideo(@PathVariable("id") long id, Principal p, HttpServletResponse response) throws IOException { System.out.println("This is like again " + p.getName()); Video v = null;/* ww w. j a va 2s. co m*/ if (!videos.exists(id)) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); } else { v = videos.findOne(id); Set<String> likesUserNames = v.getLikesUsernames(); // System.out.println("This is like again"+ p.getName()); if (likesUserNames.contains(p.getName())) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); //new ResponseEntity<Void>(HttpStatus.BAD_REQUEST); } else { // keep track of users have liked a video likesUserNames.add(p.getName()); v.setLikesUsernames(likesUserNames); v.setLikes(likesUserNames.size()); videos.save(v); response.setStatus(200); } } }
From source file:net.lightbody.bmp.proxy.jetty.http.ClientCertAuthenticator.java
/** * @return UserPrinciple if authenticated or null if not. If * Authentication fails, then the authenticator may have committed * the response as an auth challenge or redirect. * @exception IOException // www . j a v a 2s .c o m */ public Principal authenticate(UserRealm realm, String pathInContext, HttpRequest request, HttpResponse response) throws IOException { java.security.cert.X509Certificate[] certs = (java.security.cert.X509Certificate[]) request .getAttribute("javax.servlet.request.X509Certificate"); if (response != null && (certs == null || certs.length == 0 || certs[0] == null)) { // No certs available so lets try and force the issue // Get the SSLSocket Object s = HttpConnection.getHttpConnection().getConnection(); if (!(s instanceof SSLSocket)) return null; SSLSocket socket = (SSLSocket) s; if (!socket.getNeedClientAuth()) { // Need to re-handshake socket.setNeedClientAuth(true); socket.startHandshake(); // Need to wait here - but not forever. The Handshake // Listener API does not look like a good option to // avoid waiting forever. So we will take a slightly // busy timelimited approach. For now: for (int i = (_maxHandShakeSeconds * 4); i-- > 0;) { certs = (java.security.cert.X509Certificate[]) request .getAttribute("javax.servlet.request.X509Certificate"); if (certs != null && certs.length > 0 && certs[0] != null) break; try { Thread.sleep(250); } catch (Exception e) { break; } } } } if (certs == null || certs.length == 0 || certs[0] == null) return null; Principal principal = certs[0].getSubjectDN(); if (principal == null) principal = certs[0].getIssuerDN(); String username = principal == null ? "clientcert" : principal.getName(); Principal user = realm.authenticate(username, certs, request); request.setAuthType(SecurityConstraint.__CERT_AUTH); if (user != null) request.setAuthUser(user.getName()); request.setUserPrincipal(user); return user; }