List of usage examples for java.security Principal getName
public String getName();
From source file:org.cloudfoundry.identity.api.web.ApiController.java
@RequestMapping("/info") public View info(Map<String, Object> model, Principal principal) throws Exception { model.put("loginUrl", loginUrl); model.put("uaaUrl", uaaUrl); if (principal != null) { model.put("user", principal.getName()); } else {/*ww w . ja va2 s . c om*/ model.put("user", null); } return new SpelView(infoResource); }
From source file:org.mitreid.multiparty.service.InMemoryResourceService.java
@Override public SharedResourceSet getSharedResourceSetForUser(Principal p) { if (p == null) { return null; } else {//w w w.j av a2s .c om SharedResourceSet sharedResourceSet = sharedResourceSets.get(p.getName()); return sharedResourceSet; } }
From source file:com.dps.ring2park.web.VehicleController.java
@RequestMapping(method = RequestMethod.GET) public String listForm(Model model, Principal currentUser) { List<Vehicle> vehicles = null; if (currentUser != null) { vehicles = vehicleService.findVehicles(currentUser.getName()); }//from ww w. ja va 2 s . c o m model.addAttribute("vehicleList", vehicles); return "vehicles/list"; }
From source file:alfio.controller.api.admin.UsersApiController.java
@RequestMapping(value = "/organizations/{id}", method = GET) public Organization getOrganization(@PathVariable("id") int id, Principal principal) { return userManager.findOrganizationById(id, principal.getName()); }
From source file:com.epam.ta.reportportal.ws.controller.impl.FavoriteResourceController.java
@Override @RequestMapping(method = RequestMethod.DELETE) @ResponseBody/*from www. j a v a2 s . c o m*/ @ResponseStatus(HttpStatus.OK) @ApiOperation("Remove resource from favorites") public OperationCompletionRS removeFromFavorites(Principal principal, @RequestParam(value = "resource_id") String resourceId, @RequestParam(value = "resource_type") String resourceType) { return favoritesHandler.remove(resourceType, resourceId, principal.getName()); }
From source file:org.openinfinity.sso.security.spring.IdentityBasedAuthenticationUserDetailsService.java
public UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token) throws UsernameNotFoundException { LOGGER.debug("IdentityBasedAuthenticationUserDetailsService.loadUserDetails initialized."); String sessionIdentifier = httpServletRequest.getAttribute(ATTRIBUTE_SESSION_IDENTIFIER) != null ? (String) httpServletRequest.getAttribute(ATTRIBUTE_SESSION_IDENTIFIER) : (String) httpServletRequest.getAttribute(HEADER_SESSION_IDENTIFIER); String sessionId = (String) httpServletRequest.getAttribute(sessionIdentifier); Assert.isNull(sessionId, "Session id not found from the request."); LOGGER.debug(/*from w w w. j av a 2 s.c om*/ "IdentityBasedAuthenticationUserDetailsService.loadUserDetails fetched identity with session id [" + sessionId + "]"); final Identity identity = IdentityContext.loadIdentity(sessionId); LOGGER.debug("IdentityBasedAuthenticationUserDetailsService.loadUserDetails session found for identity id [" + identity.getUserPrincipal().getName() + "]"); token.setDetails(identity); return new UserDetails() { private static final long serialVersionUID = 1404244132102359899L; public Collection<? extends GrantedAuthority> getAuthorities() { Collection<GrantedAuthority> grantedAuthorities = new TreeSet<GrantedAuthority>(); for (Principal principal : identity.getAllPrincipalsForIdentity()) { GrantedAuthority grantedAuthority = new SimpleGrantedAuthority(principal.getName()); grantedAuthorities.add(grantedAuthority); } return grantedAuthorities; } public String getPassword() { return identity.getPassword(); } public String getUsername() { return identity.getUserPrincipal().getName(); } public boolean isAccountNonExpired() { return true; } public boolean isAccountNonLocked() { return true; } public boolean isCredentialsNonExpired() { return true; } public boolean isEnabled() { return true; } }; }
From source file:alfio.controller.api.admin.AdminWaitingQueueApiController.java
@RequestMapping(value = "/count", method = RequestMethod.GET) public Integer countWaitingPeople(@PathVariable("eventName") String eventName, Principal principal, HttpServletResponse response) {/*from w ww . j a v a 2 s . c o m*/ Optional<Integer> count = optionally(() -> eventManager.getSingleEvent(eventName, principal.getName())) .map(e -> waitingQueueManager.countSubscribers(e.getId())); if (count.isPresent()) { return count.get(); } response.setStatus(HttpServletResponse.SC_NOT_FOUND); return 0; }
From source file:com.springsource.oauthservice.develop.AppController.java
@RequestMapping(value = "/apps", method = RequestMethod.POST) public String create(Principal user, @Valid AppForm form, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return "develop/apps/new"; }/* w ww . j a v a 2 s . c o m*/ return "redirect:/develop/apps/" + appRepository.createApp(user.getName(), form); }
From source file:net.duckling.ddl.web.interceptor.access.VWBDenyListener.java
public void onDeny(HttpServletRequest request, HttpServletResponse response, RequirePermission requirePermission) throws IOException { VWBSession m_session = VWBSession.findSession(request); VWBContainer container = VWBContainerImpl.findContainer(); Principal currentUser = m_session.getCurrentUser(); try {/*from w w w . java 2s. co m*/ if (m_session.isAuthenticated()) { LOGGER.info("User " + currentUser.getName() + " has no access - forbidden (permission=" + getRequiredPermission(requirePermission) + ") URL:" + request.getRequestURI()); response.setHeader("ddl-auth", "Permission dend"); response.sendError(HttpServletResponse.SC_FORBIDDEN); } else { LOGGER.info("User " + currentUser.getName() + " has no access - redirecting (permission=" + getRequiredPermission(requirePermission) + ") URL:" + request.getRequestURI()); String requesturl = (String) request.getAttribute(Attributes.REQUEST_URL); if (requesturl == null) { requesturl = getRequestURL(request); } m_session.setAttribute(Attributes.REQUEST_URL, requesturl); m_session.setAttribute(Attributes.TEAM_ID_FOR_JOIN_PUBLIC_TEAM, request.getParameter("teamId")); if (isAjaxRequest(request)) { response.setStatus(450); } else { if (isHashURL(requesturl)) { m_session.removeAttribute(Attributes.REQUEST_URL); request.setAttribute("url", UrlUtil.changeSchemeToHttps( container.getURL(UrlPatterns.LOGIN, null, null, false), request)); request.getRequestDispatcher("/jsp/aone/hash/dealHashRequest.jsp").forward(request, response); } else { String redirect = UrlUtil.changeSchemeToHttps( container.getURL(UrlPatterns.LOGIN, null, null, false), request); response.sendRedirect(redirect); } } } } catch (IOException e) { LOGGER.error("Redirect failed for:" + e.getMessage(), e); throw new InternalVWBException(e.getMessage()); } catch (ServletException e) { LOGGER.error("Redirect failed for:" + e.getMessage(), e); throw new InternalVWBException(e.getMessage()); } }
From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.server.GPSecureServerResource.java
@POST @Path(value = GPServiceRSPathConfig.INSERT_SERVER_PATH) @Override// ww w .j ava 2 s .com public Long insertServer(@Auth Principal principal, GeoPlatformServer server) { logger.debug("\n\n@@@@@@@@@@@@@@Executing secure insertServer - " + "Principal : {}\n\n", principal.getName()); return super.insertServer(server); }