1 23 24 package com.sun.enterprise.web; 25 26 import java.io.ByteArrayInputStream ; 27 import java.security.cert.X509Certificate ; 28 import java.security.cert.CertificateException ; 29 import java.security.cert.CertificateFactory ; 30 import javax.servlet.http.HttpServletRequest ; 31 import com.sun.appserv.ProxyHandler; 32 33 36 public class ProxyHandlerImpl extends ProxyHandler { 37 38 54 public X509Certificate [] getSSLClientCertificateChain( 55 HttpServletRequest request) 56 throws CertificateException { 57 58 X509Certificate [] certs = null; 59 60 String clientCert = request.getHeader("Proxy-auth-cert"); 61 if (clientCert != null) { 62 clientCert = clientCert.replaceAll("% d% a", "\n"); 63 clientCert = "-----BEGIN CERTIFICATE-----\n" + clientCert 64 + "\n-----END CERTIFICATE-----"; 65 byte[] certBytes = new byte[clientCert.length()]; 66 clientCert.getBytes(0, clientCert.length(), certBytes, 0); 67 ByteArrayInputStream bais = new ByteArrayInputStream (certBytes); 68 CertificateFactory cf = CertificateFactory.getInstance("X.509"); 69 certs = new X509Certificate [1]; 70 certs[0] = (X509Certificate ) cf.generateCertificate(bais); 71 } 72 73 return certs; 74 } 75 76 88 public int getSSLKeysize(HttpServletRequest request) { 89 90 int keySize = -1; 91 92 String header = request.getHeader("Proxy-keysize"); 93 if (header != null) { 94 keySize = Integer.parseInt(header); 95 } 96 97 return keySize; 98 } 99 100 110 public String getRemoteAddress(HttpServletRequest request) { 111 return request.getHeader("Proxy-ip"); 112 } 113 } 114 | Popular Tags |