當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。