01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.yoko;
17:
18: import junit.framework.TestCase;
19: import org.apache.xmlbeans.XmlCursor;
20: import org.apache.xmlbeans.XmlException;
21: import org.apache.xmlbeans.XmlObject;
22:
23: import org.apache.geronimo.gbean.AbstractName;
24: import org.apache.geronimo.kernel.Jsr77Naming;
25: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
26: import org.apache.geronimo.kernel.Naming;
27: import org.apache.geronimo.kernel.repository.Artifact;
28:
29: import org.omg.CORBA.SystemException;
30: import org.apache.geronimo.corba.CORBABean;
31: import org.apache.geronimo.corba.security.config.ConfigAdapter;
32: import org.apache.geronimo.corba.security.config.tss.TSSConfigEditor;
33: import org.apache.geronimo.corba.security.config.tss.TSSConfig;
34:
35: /**
36: * @version $Revision: 545781 $ $Date: 2007-06-09 10:44:02 -0700 (Sat, 09 Jun 2007) $
37: */
38: public class TSSConfigEditorTest extends TestCase {
39:
40: private XmlObject getXmlObject(String xmlString)
41: throws XmlException {
42: XmlObject xmlObject = XmlObject.Factory.parse(xmlString);
43: XmlCursor xmlCursor = xmlObject.newCursor();
44: try {
45: xmlCursor.toFirstChild();
46: return xmlCursor.getObject();
47: } finally {
48: xmlCursor.dispose();
49: }
50: }
51:
52: private static final String TEST_XML4 = " <tss:tss xmlns:tss=\"http://openejb.apache.org/xml/ns/corba-tss-config-2.1\" xmlns:sec=\"http://geronimo.apache.org/xml/ns/security-1.2\">\n"
53: + " <tss:SSL port=\"6685\" hostname=\"localhost\">\n"
54: + " <tss:supports>Integrity Confidentiality EstablishTrustInTarget EstablishTrustInClient</tss:supports>\n"
55: + " <tss:requires>Integrity Confidentiality EstablishTrustInClient</tss:requires>\n"
56: + " </tss:SSL>\n"
57: + " <tss:compoundSecMechTypeList>\n"
58: + " <tss:compoundSecMech>\n"
59: + " <tss:GSSUP targetName=\"geronimo-properties-realm\"/>\n"
60: + " <tss:sasMech>\n"
61: + " <tss:identityTokenTypes><tss:ITTAnonymous/><tss:ITTPrincipalNameGSSUP principal-class=\"org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal\" domain=\"foo\"/><tss:ITTDistinguishedName domain=\"foo\"/><tss:ITTX509CertChain domain=\"foo\"/></tss:identityTokenTypes>\n"
62: + " </tss:sasMech>\n"
63: + " </tss:compoundSecMech>\n"
64: + " </tss:compoundSecMechTypeList>\n"
65: + " </tss:tss>";
66:
67: public void testCORBABean() throws Exception {
68: ClassLoader classLoader = getClass().getClassLoader();
69: Naming naming = new Jsr77Naming();
70: AbstractName testName = naming.createRootName(new Artifact(
71: "test", "stuff", "", "ear"), "gbean",
72: NameFactory.CORBA_SERVICE);
73: ConfigAdapter configAdapter = new org.apache.geronimo.yoko.ORBConfigAdapter();
74: CORBABean corbaBean = new CORBABean(testName, configAdapter,
75: "localhost", 8050, classLoader, null, null, null);
76: XmlObject xmlObject = getXmlObject(TEST_XML4);
77: TSSConfigEditor editor = new TSSConfigEditor();
78: Object o = editor.getValue(xmlObject, null, classLoader);
79: TSSConfig tss = (TSSConfig) o;
80:
81: corbaBean.setTssConfig(tss);
82:
83: try {
84: corbaBean.doStart();
85: } catch (SystemException se) {
86: se.printStackTrace();
87: fail(se.getCause().getMessage());
88: } finally {
89: try {
90: corbaBean.doStop();
91: } catch (Throwable e) {
92:
93: }
94: }
95: }
96: }
|