本文整理汇总了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;
}