List of usage examples for javax.servlet.http HttpServletRequest getUserPrincipal
public java.security.Principal getUserPrincipal();
java.security.Principal
object containing the name of the current authenticated user. From source file:com.appleframework.monitor.security.UserInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (request.getUserPrincipal() != null) { //request.setAttribute(SimpleAuthz.USER_PRINCIPAL, request.getUserPrincipal()); request.setAttribute("userName", request.getUserPrincipal().getName()); }//from w w w.jav a2 s .c o m logger.debug("receive a page request "); return true; }
From source file:org.fuzzydb.samples.social.ConnectedToHandlerInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (request.getUserPrincipal() != null) { request.setAttribute("connectedToTwitter", connectionRepository.findConnections("twitter").size() > 0); request.setAttribute("connectedToFacebook", connectionRepository.findConnections("facebook").size() > 0); }// w w w . ja va 2s .co m return true; }
From source file:org.beangle.security.web.auth.preauth.j2ee.RemoteUsernameSource.java
public String obtainUsername(HttpServletRequest request) { String username = null;//from ww w.ja v a 2 s . c o m Principal p = request.getUserPrincipal(); if (null != p) { username = p.getName(); } if (StringUtils.isEmpty(username)) { username = request.getRemoteUser(); } if (null != username && isStripPrefix()) { username = stripPrefix(username); } if (null != username) { logger.debug("Obtained username=[{}] from remote user", username); } return username; }
From source file:com.skymobi.monitor.security.UserInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (request.getUserPrincipal() != null) { request.setAttribute(SimpleAuthz.USER_PRINCIPAL, request.getUserPrincipal()); request.setAttribute("userName", request.getUserPrincipal().getName()); }//from w w w . j av a 2 s. c o m logger.debug("receive a page request "); return true; }
From source file:org.nuxeo.ecm.webengine.jaxrs.session.CoreSessionProvider.java
protected CoreSession _createSession(HttpServletRequest request, String repoName) throws Exception { if (request.getUserPrincipal() == null) { throw new java.lang.IllegalStateException("Not authenticated user is trying to get a core session"); }/*from ww w . ja v a 2 s . c o m*/ return CoreInstance.openCoreSession(repoName); }
From source file:org.pentaho.platform.web.http.security.UsernameSubstringPreAuthenticatedProcessingFilter.java
@Override protected Object getPreAuthenticatedPrincipal(final HttpServletRequest httpRequest) { String username = httpRequest.getUserPrincipal() == null ? null : httpRequest.getUserPrincipal().getName(); logger.debug("original user principal: " + username); //$NON-NLS-1$ httpRequest.setAttribute(PENTAHO_ORIG_USER_PRINCIPAL, username); if (username != null && pattern != null) { Matcher m = pattern.matcher(username); logger.debug("pattern: " + pattern); //$NON-NLS-1$ logger.debug("input: " + username); //$NON-NLS-1$ if (m.find()) { logger.debug("pattern matches input; saving capture group"); //$NON-NLS-1$ username = m.group(1);/*from www. ja v a2 s . c o m*/ } } if (logger.isDebugEnabled()) { logger.debug("Windows PreAuthenticated J2EE principal: " + username); //$NON-NLS-1$ } return username; }
From source file:org.nuxeo.ecm.mobile.handler.AnonymousRequestHandler.java
protected String getUsernameFromRequest(HttpServletRequest request) { Principal principal = request.getUserPrincipal(); String result = null;/* ww w . j a v a 2 s . c om*/ if (principal != null) { result = principal.getName(); } else { Object att = request.getSession().getAttribute(USERIDENT_KEY); if (att == null || !(att instanceof CachableUserIdentificationInfo)) { log.debug("No identity found in session, Application not selected"); return null; } principal = ((CachableUserIdentificationInfo) att).getPrincipal(); result = principal.getName(); } log.debug("username fetched in session: " + result); return result; }
From source file:org.hdiv.logs.UserData.java
public String getUsername(HttpServletRequest request) { // Find username in JEE standard security Principal principal = request.getUserPrincipal(); if (principal != null && principal.getName() != null) { return principal.getName(); }/*ww w . ja v a 2 s . c om*/ // Find username in Spring Security if (springSecurityPresent) { SecurityContext securityContext = SecurityContextHolder.getContext(); if (securityContext != null && securityContext.getAuthentication() != null) { return securityContext.getAuthentication().getName(); } } // Return anonymous return IUserData.ANONYMOUS; }
From source file:com.github.wnameless.spring.papertrail.PaperTrailService.java
private String getUserTypedId(HttpServletRequest request) { return request.getUserPrincipal() == null ? null : request.getUserPrincipal().getName(); }
From source file:org.jasig.cas.adaptors.trusted.web.flow.PrincipalFromRequestUserPrincipalNonInteractiveCredentialsAction.java
protected Credentials constructCredentialsFromRequest(final RequestContext context) { final HttpServletRequest request = WebUtils.getHttpServletRequest(context); final Principal principal = request.getUserPrincipal(); if (principal != null) { if (logger.isDebugEnabled()) { logger.debug("UserPrincipal [" + principal.getName() + "] found in HttpServletRequest"); }// ww w .ja v a 2 s. c om return new PrincipalBearingCredentials(new SimplePrincipal(principal.getName())); } if (logger.isDebugEnabled()) { logger.debug("UserPrincipal not found in HttpServletRequest."); } return null; }