List of usage examples for java.security Principal getName
public String getName();
From source file:com.mycompany.rent.controllers.UserController.java
@RequestMapping(value = "/profile", method = RequestMethod.GET) public String profilePage(Principal principal, Map model) { String name = principal.getName(); User u = userDao.getByUsername(name); List<ForRent> rentals = forRentDao.rentalsByUserId(u.getId()); model.put("rentals", rentals); return "profile"; }
From source file:com.springsource.oauthservice.develop.AppController.java
@RequestMapping(value = "/apps/{slug}", method = RequestMethod.DELETE) public String delete(@PathVariable String slug, Principal user) { appRepository.deleteApp(user.getName(), slug); return "redirect:/develop/apps"; }
From source file:business.controllers.RoleController.java
@RequestMapping(value = "/admin/roles", method = RequestMethod.GET) public List<RoleRepresentation> getAll(Principal principal) { LogFactory.getLog(getClass()).info("GET /admin/roles (for user: " + principal.getName() + ")"); List<RoleRepresentation> roles = new ArrayList<RoleRepresentation>(); for (Role role : roleRepository.findAll()) { roles.add(new RoleRepresentation(role)); }//w w w .j ava2 s . c o m return roles; }
From source file:mx.gob.cfe.documentos.web.LoginController.java
@RequestMapping(value = "/welcome", method = RequestMethod.GET) public String printWelcome(ModelMap model, Principal principal, HttpServletRequest request) { String name = principal.getName(); log.debug("Usuario con rpe{} logeado", name); Usuario usuario = usuarioDao.obtinePorUsername(name); request.getSession().setAttribute("usuarioLogeado", usuario); model.addAttribute("username", name); model.addAttribute("message", "Spring Security Custom Form example"); return "hello"; }
From source file:org.taverna.server.master.utils.UsernamePrincipal.java
@Override public boolean equals(Object o) { if (o instanceof Principal) { Principal p = (Principal) o; return name.equals(p.getName()); }/*from ww w .j a va2s .com*/ return false; }
From source file:com.msyla.usergreeter.user.web.UserResource.java
@RequestMapping({ "/user", "/me" }) public Map<String, String> user(Principal principal) { Map<String, String> map = new LinkedHashMap<>(); map.put("name", principal.getName()); return map;/*w w w . j a v a 2s .c om*/ }
From source file:MyServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<HTML>"); out.println("<HEAD>"); out.println("<TITLE>"); out.println("User Authentication"); out.println("</TITLE>"); out.println("</HEAD>"); out.println("<BODY>"); out.println("<H1>User Authentication</H1>"); String type = request.getAuthType(); out.println("Welcome to this secure page.<BR>"); out.println("Authentication mechanism: " + type + "<BR>"); Principal principal = request.getUserPrincipal(); out.println("Your username is: " + principal.getName() + "<BR>"); out.println("</BODY>"); out.println("</HTML>"); }
From source file:org.magnum.mobilecloud.video.AFilledController.java
@RequestMapping(value = VIDEO_LIKE_PATH, method = RequestMethod.POST) public void likeVideo(@PathVariable(VIDEO_ID) long id, HttpServletResponse response, Principal p) { setLike(id, p.getName(), response, true); }
From source file:org.magnum.mobilecloud.video.AFilledController.java
@RequestMapping(value = VIDEO_UNLIKE_PATH, method = RequestMethod.POST) public void unlikeVideo(@PathVariable(VIDEO_ID) long id, HttpServletResponse response, Principal p) { setLike(id, p.getName(), response, false); }
From source file:com.adito.boot.KeyStoreManager.java
/** * Utility method to extract an entity from a certificates subject DN * /*from www .j a va 2s. c om*/ * @param c certificate * @param entity entity to extract * @return entity value */ public static String getX509CertificateEntity(X509Certificate c, String entity) { // This assumes the keystore returns the last certificate in the chain // the actual certifcate that is signed by a CA or untrusted cert Principal subjectPrincipal = c.getSubjectDN(); StringTokenizer t = new StringTokenizer(subjectPrincipal.getName(), ","); while (t.hasMoreTokens()) { String e = t.nextToken().trim(); String f = entity.trim() + "="; if (e.toLowerCase().startsWith(f.toLowerCase())) { return e.substring(f.length()).trim(); } } return ""; }