List of usage examples for org.springframework.security.web.authentication WebAuthenticationDetails getSessionId
public String getSessionId()
From source file:org.cloudfoundry.identity.uaa.authentication.UaaAuthenticationDetails.java
public UaaAuthenticationDetails(HttpServletRequest request) { WebAuthenticationDetails webAuthenticationDetails = new WebAuthenticationDetails(request); this.origin = webAuthenticationDetails.getRemoteAddress(); this.sessionId = webAuthenticationDetails.getSessionId(); String clientId = request.getParameter("client_id"); if (clientId != null) { this.clientId = clientId; }/*from w ww. j a v a 2s. co m*/ }
From source file:org.springframework.security.web.jackson2.WebAuthenticationDetailsMixinTest.java
@Test public void webAuthenticationDetailsDeserializeTest() throws IOException, JSONException { String actualJson = "{\"@class\": \"org.springframework.security.web.authentication.WebAuthenticationDetails\"," + "\"sessionId\": \"1\", \"remoteAddress\": \"/home\"}"; WebAuthenticationDetails details = this.mapper.readValue(actualJson, WebAuthenticationDetails.class); assertThat(details).isNotNull();/* w w w.j a v a 2s .c o m*/ assertThat(details.getRemoteAddress()).isEqualTo("/home"); assertThat(details.getSessionId()).isEqualTo("1"); }
From source file:fi.helsinki.opintoni.config.audit.AuditEventConverter.java
/** * Internal conversion. This method will allow to save additional data. * By default, it will save the object as string * * @param data the data to convert/*from w w w .j a v a2s . com*/ * @return a map of String, String */ public Map<String, String> convertDataToStrings(Map<String, Object> data) { Map<String, String> results = new HashMap<>(); if (data != null) { for (String key : data.keySet()) { Object object = data.get(key); // Extract the data that will be saved. if (object instanceof WebAuthenticationDetails) { WebAuthenticationDetails authenticationDetails = (WebAuthenticationDetails) object; results.put("remoteAddress", authenticationDetails.getRemoteAddress()); results.put("sessionId", authenticationDetails.getSessionId()); } else { results.put(key, object.toString()); } } } return results; }
From source file:com.rockagen.gnext.service.spring.security.extension.BasicWebAuthenticationDetails.java
@Override public boolean equals(Object obj) { if (obj instanceof WebAuthenticationDetails) { WebAuthenticationDetails rhs = (WebAuthenticationDetails) obj; if ((getRemoteAddress() == null) && (rhs.getRemoteAddress() != null)) { return false; }/* ww w . j av a 2 s . c om*/ if ((getRemoteAddress() != null) && (rhs.getRemoteAddress() == null)) { return false; } if (getRemoteAddress() != null) { if (!getRemoteAddress().equals(rhs.getRemoteAddress())) { return false; } } if ((getSessionId() == null) && (rhs.getSessionId() != null)) { return false; } if ((getSessionId() != null) && (rhs.getSessionId() == null)) { return false; } if (getSessionId() != null) { if (!getSessionId().equals(rhs.getSessionId())) { return false; } } return true; } return false; }
From source file:org.apache.ranger.biz.SessionMgr.java
public UserSessionBase processSuccessLogin(int authType, String userAgent, HttpServletRequest httpRequest) { boolean newSessionCreation = true; UserSessionBase userSession = null;/*from w w w . ja v a 2 s .c om*/ RangerSecurityContext context = RangerContextHolder.getSecurityContext(); if (context != null) { userSession = context.getUserSession(); } Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); WebAuthenticationDetails details = (WebAuthenticationDetails) authentication.getDetails(); String currentLoginId = authentication.getName(); if (userSession != null) { if (validateUserSession(userSession, currentLoginId)) { newSessionCreation = false; } } if (newSessionCreation) { getSSOSpnegoAuthCheckForAPI(currentLoginId, httpRequest); // Need to build the UserSession XXPortalUser gjUser = daoManager.getXXPortalUser().findByLoginId(currentLoginId); if (gjUser == null) { logger.error("Error getting user for loginId=" + currentLoginId, new Exception()); return null; } XXAuthSession gjAuthSession = new XXAuthSession(); gjAuthSession.setLoginId(currentLoginId); gjAuthSession.setUserId(gjUser.getId()); gjAuthSession.setAuthTime(DateUtil.getUTCDate()); gjAuthSession.setAuthStatus(XXAuthSession.AUTH_STATUS_SUCCESS); gjAuthSession.setAuthType(authType); if (details != null) { gjAuthSession.setExtSessionId(details.getSessionId()); gjAuthSession.setRequestIP(details.getRemoteAddress()); } if (userAgent != null) { gjAuthSession.setRequestUserAgent(userAgent); } gjAuthSession.setDeviceType(httpUtil.getDeviceType(userAgent)); HttpSession session = httpRequest.getSession(); if (session != null) { if (session.getAttribute("auditLoginId") == null) { synchronized (session) { if (session.getAttribute("auditLoginId") == null) { boolean isDownloadLogEnabled = PropertiesUtil .getBooleanProperty("ranger.downloadpolicy.session.log.enabled", false); if (isDownloadLogEnabled) { gjAuthSession = storeAuthSession(gjAuthSession); session.setAttribute("auditLoginId", gjAuthSession.getId()); } else if (!StringUtils.isEmpty(httpRequest.getRequestURI()) && !(httpRequest.getRequestURI().contains("/secure/policies/download/") || httpRequest.getRequestURI().contains("/secure/download/"))) { gjAuthSession = storeAuthSession(gjAuthSession); session.setAttribute("auditLoginId", gjAuthSession.getId()); } else if (StringUtils.isEmpty(httpRequest.getRequestURI())) { gjAuthSession = storeAuthSession(gjAuthSession); session.setAttribute("auditLoginId", gjAuthSession.getId()); } else { //NOPMD //do not log the details for download policy and tag } } } } } userSession = new UserSessionBase(); userSession.setXXPortalUser(gjUser); userSession.setXXAuthSession(gjAuthSession); if (httpRequest.getAttribute("spnegoEnabled") != null && (boolean) httpRequest.getAttribute("spnegoEnabled")) { userSession.setSpnegoEnabled(true); } resetUserSessionForProfiles(userSession); resetUserModulePermission(userSession); Calendar cal = Calendar.getInstance(); if (details != null) { logger.info("Login Success: loginId=" + currentLoginId + ", sessionId=" + gjAuthSession.getId() + ", sessionId=" + details.getSessionId() + ", requestId=" + details.getRemoteAddress() + ", epoch=" + cal.getTimeInMillis()); } else { logger.info("Login Success: loginId=" + currentLoginId + ", sessionId=" + gjAuthSession.getId() + ", details is null" + ", epoch=" + cal.getTimeInMillis()); } } return userSession; }