当前位置: 首页>>代码示例>>Java>>正文


Java WebAuthenticationDetails.getSessionId方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:22,代码来源:EventRouter.java

示例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;
	}
}
 
开发者ID:ozoneplatform,项目名称:owf-security,代码行数:26,代码来源:AuthenticationUtils.java

示例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();
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:16,代码来源:LogoutSuccessHandlerImpl.java

示例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;
}
 
开发者ID:rockagen,项目名称:security-stateless-samples,代码行数:39,代码来源:ExWebAuthenticationDetails.java


注:本文中的org.springframework.security.web.authentication.WebAuthenticationDetails.getSessionId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。