KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jrmp > test > SSLFailuresSocketsUnitTestCase


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.jrmp.test;
23
24 import java.io.IOException JavaDoc;
25 import java.rmi.RemoteException JavaDoc;
26 import java.net.URL JavaDoc;
27 import javax.ejb.CreateException JavaDoc;
28 import javax.naming.InitialContext JavaDoc;
29 import javax.naming.NamingException JavaDoc;
30
31 import junit.framework.Test;
32 import junit.framework.TestCase;
33 import junit.framework.TestSuite;
34
35 import org.jboss.test.JBossTestCase;
36
37 import org.jboss.test.jrmp.interfaces.StatelessSession;
38 import org.jboss.test.jrmp.interfaces.StatelessSessionHome;
39
40 /**
41  * Test of using custom RMI socket factories with the JRMP ejb container
42  * invoker.
43  *
44  * @author Scott.Stark@jboss.org
45  * @version $Revision: 37406 $
46  */

47 public class SSLFailuresSocketsUnitTestCase extends JBossTestCase
48 {
49    /**
50     * Constructor for the CustomSocketsUnitTestCase object
51     *
52     * @param name Description of Parameter
53     */

54    public SSLFailuresSocketsUnitTestCase(String JavaDoc name)
55    {
56       super(name);
57    }
58
59    /**
60     * Test basic ejb access over the ssl socket requiring a client cert
61     *
62     * @exception Exception Description of Exception
63     */

64    public void testClientCertSSLAccessFailure() throws Exception JavaDoc
65    {
66       log.info("+++ testClientCertSSLAccessFailure");
67       // Install the truststore to use for the server cert
68
String JavaDoc res = super.getResourceURL("test-configs/tomcat-ssl/conf/client.keystore");
69       log.info("client.keystore: "+res);
70       URL JavaDoc clientURL = new URL JavaDoc(res);
71       System.setProperty("javax.net.ssl.trustStore", clientURL.getFile());
72       System.setProperty("javax.net.ssl.keyStore", clientURL.getFile());
73       System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client");
74       System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-client");
75       InitialContext JavaDoc jndiContext = new InitialContext JavaDoc();
76       log.debug("Lookup StatelessSessionWithSSL");
77       Object JavaDoc obj = jndiContext.lookup("StatelessSessionWithSSL");
78       StatelessSessionHome home = (StatelessSessionHome)obj;
79       log.debug("Found StatelessSessionWithSSL Home");
80       StatelessSession bean = home.create();
81       log.debug("Created StatelessSessionWithSSL");
82       // Test that the Entity bean sees username as its principal
83
String JavaDoc echo = bean.echo("jrmp");
84       log.debug("bean.echo(jrmp) = " + echo);
85       bean.remove();
86    }
87
88    public static Test suite() throws Exception JavaDoc
89    {
90       return getDeploySetup(SSLFailuresSocketsUnitTestCase.class, "jrmp-comp.jar");
91    }
92
93 }
94
Popular Tags