Principal userPrincipal = null;
AuthState targetAuthState = (AuthState) context.getAttribute(
ClientContext.TARGET_AUTH_STATE);
if (targetAuthState != null) {
userPrincipal = getAuthPrincipal(targetAuthState);
if (userPrincipal == null) {
AuthState proxyAuthState = (AuthState) context.getAttribute(
ClientContext.PROXY_AUTH_STATE);
userPrincipal = getAuthPrincipal(proxyAuthState);
}
}
if (userPrincipal == null) {
ManagedClientConnection conn = (ManagedClientConnection) context.getAttribute(
ExecutionContext.HTTP_CONNECTION);
if (conn.isOpen()) {
SSLSession sslsession = conn.getSSLSession();
if (sslsession != null) {
userPrincipal = sslsession.getLocalPrincipal();
}
}
}
return userPrincipal;