SSLSession session = httpsExch.getSSLSession();
if (session != null) {
try {
Principal p = session.getPeerPrincipal();
response = new Success(new HttpPrincipal(p.getName(), realm));
} catch (SSLPeerUnverifiedException e) {
}
}
}
if (response == null) {
response = super.authenticate(httpExchange);
}
if (response instanceof Success) {
// For this method to have been called a Subject with HttpPrincipal was not found within the HttpExchange so now
// create a new one.
HttpPrincipal principal = ((Success) response).getPrincipal();
try {
SubjectUserInfo userInfo = callbackHandler.get().createSubjectUserInfo(principal);
httpExchange.setAttribute(Subject.class.getName(), userInfo.getSubject(), AttributeScope.CONNECTION);