1 package org.jacorb.security.sas; 2 3 22 23 import java.security.cert.X509Certificate ; 24 25 import javax.net.ssl.SSLSocket; 26 27 import org.apache.avalon.framework.configuration.Configuration; 28 import org.apache.avalon.framework.configuration.ConfigurationException; 29 import org.apache.avalon.framework.logger.Logger; 30 import org.jacorb.orb.dsi.ServerRequest; 31 import org.jacorb.orb.giop.GIOPConnection; 32 import org.jacorb.orb.iiop.ServerIIOPConnection; 33 import org.jacorb.orb.portableInterceptor.ServerRequestInfoImpl; 34 import org.omg.CORBA.ORB ; 35 import org.omg.CSI.IdentityToken; 36 import org.omg.CSIIOP.CompoundSecMechList; 37 import org.omg.IOP.Codec ; 38 import org.omg.PortableInterceptor.ServerRequestInfo ; 39 40 public class JsseContext 41 implements ISASContext 42 { 43 44 private Logger logger = null; 45 46 private X509Certificate client_cert = null; 47 48 public void configure(Configuration configuration) 49 throws ConfigurationException 50 { 51 } 52 53 54 public JsseContext(Logger logger) 55 { 56 this.logger = logger; 57 } 58 59 public boolean validate(ServerRequestInfo ri, byte[] contextToken) 60 { 61 client_cert = getClientCert(ri); 62 if (client_cert == null) 63 return false; 64 return true; 65 } 66 67 public String getPrincipalName() 68 { 69 if (client_cert == null) 70 return null; 71 return client_cert.getSubjectDN().getName(); 72 } 73 74 78 private X509Certificate getClientCert(ServerRequestInfo ri) 79 { 80 ServerRequest request = ((ServerRequestInfoImpl) ri).request; 81 82 GIOPConnection connection = request.getConnection(); 83 84 if (connection == null) 86 { 87 if (logger.isWarnEnabled()) 88 logger.warn("target has no connection!"); 89 return null; 90 } 91 92 if( !connection.isSSL() ) 93 { 94 return null; 95 } 96 97 ServerIIOPConnection transport = 98 (ServerIIOPConnection) connection.getTransport(); 99 100 SSLSocket sslSocket = (SSLSocket) transport.getSocket(); 101 try 102 { 103 return (X509Certificate )sslSocket.getSession().getPeerCertificates()[0]; 104 } 105 catch( javax.net.ssl.SSLPeerUnverifiedException pue ) 106 { 107 if (logger.isDebugEnabled()) 108 logger.debug("SSLPeerUnverifiedException", pue ); 109 return null; 110 } 111 112 190 } 191 192 195 public byte[] createClientContext(ORB orb, Codec codec, CompoundSecMechList csmList) { 196 return null; 198 } 199 200 203 public String getClientPrincipal() { 204 return null; 206 } 207 208 211 public boolean validateContext(ORB orb, Codec codec, byte[] contextToken) { 212 return false; 214 } 215 216 219 public String getValidatedPrincipal() { 220 return null; 222 } 223 224 227 public void initClient() { 228 230 } 231 232 235 public void initTarget() { 236 238 } 239 240 public String getMechOID() { 241 return ""; 242 } 243 244 247 public IdentityToken createIdentityToken(ORB orb, Codec codec, CompoundSecMechList csmList) { 248 return null; 250 } 251 } 252 | Popular Tags |