本文整理匯總了Java中org.springframework.security.web.authentication.WebAuthenticationDetails.getSessionId方法的典型用法代碼示例。如果您正苦於以下問題:Java WebAuthenticationDetails.getSessionId方法的具體用法?Java WebAuthenticationDetails.getSessionId怎麽用?Java WebAuthenticationDetails.getSessionId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.security.web.authentication.WebAuthenticationDetails
的用法示例。
在下文中一共展示了WebAuthenticationDetails.getSessionId方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onApplicationEvent
import org.springframework.security.web.authentication.WebAuthenticationDetails; //導入方法依賴的package包/類
@Override
public void onApplicationEvent(AbstractSubProtocolEvent ev) {
if(ev instanceof SessionSubscribeEvent) {
sendHistoryToNewSubscriber(ev);
} else if(ev instanceof SessionConnectEvent || ev instanceof SessionDisconnectEvent) {
Authentication user = (Authentication)ev.getUser();
Object details = user.getDetails();
String sessionId = null;
String address = null;
if(details instanceof WebAuthenticationDetails) {
WebAuthenticationDetails wad = (WebAuthenticationDetails) details;
address = wad.getRemoteAddress();
sessionId = wad.getSessionId();
}
if(ev instanceof SessionDisconnectEvent) {
log.info("WebSocket user \"{}\" was disconnected from {} with HTTP session: {}", user.getName(), address, sessionId);
} else {
log.info("WebSocket user \"{}\" was connected from {} with HTTP session: {}", user.getName(), address, sessionId);
}
}
}
示例2: getDetailsMap
import org.springframework.security.web.authentication.WebAuthenticationDetails; //導入方法依賴的package包/類
public Map<String, String> getDetailsMap(final Authentication authentication){
if(authentication == null){
return new HashMap<String, String>();
}else{
//GET SESSION ID AND IP ADDRESS
WebAuthenticationDetails metaDetails = (WebAuthenticationDetails) authentication.getDetails();
String sessionId = ((metaDetails == null)? null : metaDetails.getSessionId());
String ipAddress = ((metaDetails == null)? null : metaDetails.getRemoteAddress());
HashMap<String, String> detailsMap = new HashMap<String, String>();
detailsMap.put(MAP_KEY_IP_ADDRESS, ipAddress);
detailsMap.put(MAP_KEY_SESSION_ID, sessionId);
//GET USERNAME
Object user = authentication.getPrincipal();
String username = null;
if(user instanceof OWFUserDetailsImpl){
username = ((OWFUserDetailsImpl)user).getUsername();
} else {
username = ((user instanceof String) ? (String)user : null);
}
detailsMap.put(MAP_KEY_USERNAME, username);
return detailsMap;
}
}
示例3: getSessionId
import org.springframework.security.web.authentication.WebAuthenticationDetails; //導入方法依賴的package包/類
public String getSessionId(Authentication authentication) {
if (authentication == null) {
return "";
}
Object details = authentication.getDetails();
if (!(details instanceof WebAuthenticationDetails)) {
return "";
}
WebAuthenticationDetails webDetails = (WebAuthenticationDetails) details;
return webDetails.getSessionId();
}
示例4: equals
import org.springframework.security.web.authentication.WebAuthenticationDetails; //導入方法依賴的package包/類
public boolean equals(Object obj) {
if (obj instanceof WebAuthenticationDetails) {
WebAuthenticationDetails rhs = (WebAuthenticationDetails) obj;
if ((remoteAddress == null) && (rhs.getRemoteAddress() != null)) {
return false;
}
if ((remoteAddress != null) && (rhs.getRemoteAddress() == null)) {
return false;
}
if (remoteAddress != null) {
if (!remoteAddress.equals(rhs.getRemoteAddress())) {
return false;
}
}
if ((sessionId == null) && (rhs.getSessionId() != null)) {
return false;
}
if ((sessionId != null) && (rhs.getSessionId() == null)) {
return false;
}
if (sessionId != null) {
if (!sessionId.equals(rhs.getSessionId())) {
return false;
}
}
return true;
}
return false;
}
開發者ID:saintdan,項目名稱:spring-microservices-boilerplate,代碼行數:38,代碼來源:CustomWebAuthenticationDetails.java
示例5: equals
import org.springframework.security.web.authentication.WebAuthenticationDetails; //導入方法依賴的package包/類
@Override
public boolean equals(Object obj) {
if (obj instanceof WebAuthenticationDetails) {
WebAuthenticationDetails rhs = (WebAuthenticationDetails) obj;
if ((getRemoteAddress() == null) && (rhs.getRemoteAddress() != null)) {
return false;
}
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;
}