1 28 29 package com.caucho.server.security; 30 31 import javax.servlet.ServletContext ; 32 import javax.servlet.ServletException ; 33 import javax.servlet.http.HttpServletRequest ; 34 import javax.servlet.http.HttpServletResponse ; 35 import java.io.IOException ; 36 import java.security.Principal ; 37 import java.security.cert.X509Certificate ; 38 39 43 public class ClientCertLogin extends AbstractLogin { 44 47 public String getAuthType() 48 { 49 return "CLIENT-CERT"; 50 } 51 52 63 public Principal authenticate(HttpServletRequest request, 64 HttpServletResponse response, 65 ServletContext application) 66 throws ServletException , IOException 67 { 68 return getUserPrincipal(request, response, application); 69 } 70 71 80 public Principal getUserPrincipal(HttpServletRequest request, 81 HttpServletResponse response, 82 ServletContext application) 83 throws ServletException 84 { 85 X509Certificate []certs; 86 87 certs = (X509Certificate []) request.getAttribute("javax.servlet.request.X509Certificate"); 88 89 if (certs != null) 90 return certs[0].getSubjectDN(); 91 else 92 return null; 93 } 94 } 95 | Popular Tags |