List of usage examples for java.security Principal getName
public String getName();
From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.message.GPSecureMessageResource.java
@GET @Path(value = GPServiceRSPathConfig.GET_ALL_MESSAGES_BY_RECIPIENT_PATH) @Override//from w w w .j a va2 s . com public GetMessageResponse getAllMessagesByRecipient(@Auth Principal principal, @PathParam(value = "recipientID") Long recipientID) throws Exception { logger.debug("\n\n@@@@@@@@@@@@@@Executing secure getMessageDetail - " + "Principal : {}\n\n", principal.getName()); return super.getAllMessagesByRecipient(recipientID); }
From source file:us.repasky.microblog.controllers.UserController.java
@RequestMapping(value = "/", method = RequestMethod.POST) public String doMessagePost(@Valid Post post, BindingResult result, @RequestParam(defaultValue = "0") final String page, Map<String, Object> model, final Principal principal) { logger.trace("executing inside UserController doMessagePost()"); String view = ""; String myUsername = principal.getName(); if (!result.hasErrors()) { String errorMessage = userService.createPost(myUsername, post); if (StringUtils.isBlank(errorMessage)) { model.put("message", "Post created successfully"); view = "createPost"; } else {//www .j a v a2 s . co m model.put(ERROR_MESSAGE, errorMessage); view = "error"; } } else { logger.debug("Posted message failed validation."); model.put("post", post); view = "createPost"; } showPostsFromFollowers(page, model, principal); return view; }
From source file:net.sourceforge.safr.jaas.permission.PermissionManagerImpl.java
private void grantPermissionNoCheck(Principal principal, InstancePermission permission) { getPermissionMap(principal).getEager(principal.getName()).add(permission); }
From source file:net.sourceforge.safr.jaas.permission.PermissionManagerImpl.java
private void revokePermissionNoCheck(Principal principal, InstancePermission permission) { getPermissionMap(principal).getEager(principal.getName()).remove(permission); }
From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.viewport.GPSecureViewportResource.java
@GET @Path(value = GPServiceRSPathConfig.GET_DEFAULT_VIEWPORT_PATH) @Override//from w w w. ja v a 2s .co m public GPViewport getDefaultViewport(@Auth Principal principal, @PathParam(value = "accountProjectID") Long accountProjectID) throws Exception { logger.debug("\n\n@@@@@@@@@@@@@@Executing secure getDefaultViewport - " + "Principal : {}\n\n", principal.getName()); return super.getDefaultViewport(accountProjectID); }
From source file:alfio.controller.api.admin.UsersApiController.java
@RequestMapping(value = "/users/new", method = POST) public UserWithPasswordAndQRCode insertUser(@RequestBody UserModification userModification, @RequestParam("baseUrl") String baseUrl, Principal principal) { Role requested = Role.valueOf(userModification.getRole()); Validate.isTrue(userManager.getAvailableRoles(principal.getName()).stream().anyMatch(requested::equals), String.format("Requested role %s is not available for current user", userModification.getRole())); UserWithPassword userWithPassword = userManager.insertUser(userModification.getOrganizationId(), userModification.getUsername(), userModification.getFirstName(), userModification.getLastName(), userModification.getEmailAddress(), requested, User.Type.INTERNAL); return new UserWithPasswordAndQRCode(userWithPassword, toBase64QRCode(userWithPassword, baseUrl)); }
From source file:com.jd.survey.web.settings.VelocityTemplateController.java
@Secured({ "ROLE_ADMIN" }) @RequestMapping(produces = "text/html") public String list(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Principal principal, Model uiModel) { try {// w ww . ja v a 2 s . c om User user = userService.user_findByLogin(principal.getName()); log.error("list():"); if (!user.isAdmin()) { return "accessDenied"; } if (page != null || size != null) { int sizeNo = size == null ? 10 : size.intValue(); final int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo; uiModel.addAttribute("velocityTemplates", surveySettingsService.velocityTemplate_findAll(firstResult, sizeNo)); float nrOfPages = (float) surveySettingsService.velocityTemplate_getCount() / sizeNo; uiModel.addAttribute("maxPages", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages)); } else { uiModel.addAttribute("velocityTemplates", surveySettingsService.velocityTemplate_findAll()); } return "admin/templates/list"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }
From source file:com.app.inventario.controlador.Controlador.java
@RequestMapping(value = "/principal") public String devolverPantallaPrincipal(ModelMap model, Principal principal, HttpServletRequest request) { //Authentication auth = SecurityContextHolder.getContext().getAuthentication(); model.addAttribute("username", principal.getName().toUpperCase()); return "paginas/principal"; }
From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.folder.GPSecureFolderResource.java
@POST @Path(value = GPServiceRSPathConfig.INSERT_FOLDER_PATH) @Override/*w w w.java2 s . co m*/ public Long insertFolder(@Auth Principal principal, InsertFolderRequest insertFolderRequest) throws Exception { logger.debug("\n\n@@@@@@@@@@@@@@@@@Executing secure insertFolder - " + "Principal : {}\n\n", principal.getName()); return super.insertFolder(insertFolderRequest); }
From source file:com.jd.survey.web.security.AuthorityController.java
@Secured({ "ROLE_ADMIN" }) @RequestMapping(value = "/{id}", params = "form", produces = "text/html") public String updateForm(@PathVariable("id") Long id, Principal principal, Model uiModel) { log.info("updateForm(): id=" + id); try {/* www. jav a 2 s . co m*/ User user = userService.user_findByLogin(principal.getName()); populateEditForm(uiModel, userService.authority_findById(id), user); return "security/authorities/update"; } catch (Exception e) { log.error(e.getMessage(), e); throw (new RuntimeException(e)); } }