List of usage examples for java.security Principal getName
public String getName();
From source file:alfio.controller.AdminConfigurationController.java
@RequestMapping("/admin/configuration/payment/stripe/connect/{orgId}") public String redirectToStripeConnect(Principal principal, @PathVariable("orgId") Integer orgId, HttpSession session) {/*from w ww. j ava 2 s . c o m*/ if (userManager.isOwnerOfOrganization(userManager.findUserByUsername(principal.getName()), orgId)) { StripeManager.ConnectURL connectURL = stripeManager.getConnectURL(Configuration.from(orgId)); session.setAttribute(STRIPE_CONNECT_STATE_PREFIX + orgId, connectURL.getState()); session.setAttribute(STRIPE_CONNECT_ORG, orgId); return "redirect:" + connectURL.getAuthorizationURL(); } return "redirect:/admin/"; }
From source file:com.rest.UserRest.java
@RequestMapping(value = "/changePassword", method = RequestMethod.PUT) @Transactional/*from ww w. j av a 2 s .c o m*/ public ResponseEntity changePassword(@Valid @RequestBody UserPasswordRequestDto userPasswordRequestDto, Principal user) { String username = user.getName(); UserEntity userFromDB = userRepository.findByUsername(username); if (!standardPasswordEncoder.matches(userPasswordRequestDto.getCurrentPassword(), userFromDB.getPassword())) { throw new RuntimeException(bundleMessageReader.getMessage("WrongCurrentPassword")); } String encodedNewPassword = standardPasswordEncoder.encode(userPasswordRequestDto.getNewPassword()); userFromDB.setPassword(encodedNewPassword); userRepository.save(userFromDB); return new ResponseEntity(HttpStatus.OK); }
From source file:business.controllers.UserController.java
@RequestMapping(value = "/admin/users", method = RequestMethod.GET) public List<ProfileRepresentation> getAll(Principal principal) { log.info("GET /admin/users (for user: " + principal.getName() + ")"); List<ProfileRepresentation> users = new ArrayList<ProfileRepresentation>(); for (User user : userService.findAll()) { users.add(new ProfileRepresentation(user)); }//from w ww.j a va 2 s .com return users; }
From source file:com.epam.ta.reportportal.ws.controller.impl.UserFilterController.java
@Override @RequestMapping(method = RequestMethod.GET) @ResponseBody/* ww w . ja v a2 s. c om*/ @ResponseStatus(HttpStatus.OK) @ApiOperation("Get all filters") public Iterable<UserFilterResource> getAllFilters(@PathVariable String projectName, @SortFor(UserFilter.class) Pageable pageable, @FilterFor(UserFilter.class) Filter filter, Principal principal) { return getFilterHandler.getFilters(principal.getName(), pageable, filter, EntityUtils.normalizeProjectName(projectName)); }
From source file:com.orange.clara.tool.controllers.AbstractDefaultController.java
protected User getCurrentUser() { SecurityContext securityContext = this.getSecurityContext(); if (securityContext == null || securityContext.getAuthentication() == null || securityContext.getAuthentication().getPrincipal() == null) { return null; }/*from w w w .j a v a 2 s .c o m*/ Principal principal = (Principal) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); return this.userRepo.findOne(principal.getName()); }
From source file:be.fedict.hsm.model.SignatureServiceBean.java
@Override public Certificate[] getCertificateChain(String alias) throws NoSuchAlgorithmException { Principal callerPrincipal = this.sessionContext.getCallerPrincipal(); LOG.debug("caller principal: " + callerPrincipal.getName()); long appId = Long.parseLong(callerPrincipal.getName()); ApplicationKeyId applicationKeyId = new ApplicationKeyId(appId, alias); ApplicationKeyEntity applicationKeyEntity = this.entityManager.find(ApplicationKeyEntity.class, applicationKeyId);//from ww w .ja va 2 s. com if (null == applicationKeyEntity) { throw new NoSuchAlgorithmException("unknown key alias: " + alias); } String keyStoreAlias = applicationKeyEntity.getKeyStoreKeyAlias(); long keyStoreId = applicationKeyEntity.getKeyStore().getId(); Certificate[] certificateChain = this.keyStoreSingletonBean.getCertificateChain(keyStoreId, keyStoreAlias); return certificateChain; }
From source file:com.epam.ta.reportportal.ws.controller.impl.UserFilterController.java
@Override @RequestMapping(value = "/own", method = RequestMethod.GET) @ResponseBody/* w ww . j a v a2 s.c om*/ @ResponseStatus(HttpStatus.OK) @ApiOperation("Get all filters for specified user who own them") public List<UserFilterResource> getOwnFilters(@PathVariable String projectName, @FilterFor(UserFilter.class) Filter filter, Principal principal) { return getFilterHandler.getOwnFilters(principal.getName(), filter, EntityUtils.normalizeProjectName(projectName)); }
From source file:xyz.autumnn.exam.springsocial.controller.HomeController.java
@RequestMapping("/") public String home(Principal currentUser, Model model) { model.addAttribute("connectionsToProviders", connectionRepositoryProvider.get().findAllConnections()); model.addAttribute("account", accountService.findAccountByUsername(currentUser.getName())); return "home"; }
From source file:com.ushahidi.swiftriver.core.api.controller.FormsController.java
/** * Handler for deleting an existing form. * /*from w w w . ja v a2s.co m*/ * @param id */ @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseBody public void deleteForm(@PathVariable Long id, Principal principal) { formService.deleteForm(id, principal.getName()); }
From source file:be.fedict.hsm.model.SignatureServiceBean.java
@Override public Set<String> getAliases() { Principal callerPrincipal = this.sessionContext.getCallerPrincipal(); LOG.debug("caller principal: " + callerPrincipal.getName()); long appId = Long.parseLong(callerPrincipal.getName()); LOG.debug("getAliases for app id: " + appId); ApplicationEntity applicationEntity = this.entityManager.find(ApplicationEntity.class, appId); List<ApplicationKeyEntity> applicationKeys = ApplicationKeyEntity.getApplicationKeys(this.entityManager, applicationEntity);//from w w w . j ava 2 s . co m LOG.debug("number of aliases: " + applicationKeys.size()); Set<String> aliases = new HashSet<String>(); for (ApplicationKeyEntity applicationKey : applicationKeys) { String alias = applicationKey.getName(); LOG.debug("alias: " + alias); aliases.add(alias); } LOG.debug("aliases: " + aliases); return aliases; }