use of com.ctrip.infosec.sso.client.principal.AttributePrincipalImpl in project x-pipe by ctripcorp.
the class CtripSSOFilter method getAssertionIncache.
private Assertion getAssertionIncache(HttpServletRequest request) {
Cookie[] cookies = request.getCookies();
if (cookies == null) {
return null;
}
String memCacheAssertionID = null;
String cookieName = generateCookieName(request.getContextPath());
for (Cookie cookie : cookies) {
if (cookie.getName().equalsIgnoreCase(cookieName)) {
memCacheAssertionID = cookie.getValue();
break;
}
}
Assertion assertionInCache = null;
try {
CloseableHttpResponse response = httpClient.execute(new HttpGet(casServerUrlPrefix + "/client/principal?principalId=" + memCacheAssertionID + "&callback=" + serverName));
String result = EntityUtils.toString(response.getEntity(), "utf-8");
JSONObject jsonObject = JSON.parseObject(result);
if (jsonObject.getJSONObject("result") != null) {
Map user = jsonObject.getJSONObject("result");
assertionInCache = new AssertionImpl(new AttributePrincipalImpl((String) user.get("name"), user));
}
} catch (Exception e) {
logger.error(e.getMessage());
}
return assertionInCache;
}
Aggregations