001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)TestEndptSecConfigReader.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: /**
030: * TestEndptSecConfigReader.java
031: *
032: * SUN PROPRIETARY/CONFIDENTIAL.
033: * This software is the proprietary information of Sun Microsystems, Inc.
034: * Use is subject to license terms.
035: *
036: * Created on March 21, 2005, 2:35 PM
037: */package com.sun.jbi.internal.security.config;
038:
039: import com.sun.jbi.internal.security.Util;
040: import java.io.File;
041:
042: /**
043: *
044: * @author Sun Microsystems, Inc.
045: */
046: public class TestEndptSecConfigReader extends junit.framework.TestCase {
047: private String mConfig;
048: private String mConfigSchemaDir;
049:
050: /** Creates a new instance of TestSecurityInstallConfigReader */
051: public TestEndptSecConfigReader(String testname) {
052: super (testname);
053: String srcroot = System.getProperty("junit.srcroot");
054: String security = "/runtime/esb-security"; // open-esb build
055:
056: java.io.File f = new java.io.File(srcroot + security);
057: if (!f.exists()) {
058: security = "/shasta/security"; // mainline/whitney build
059: }
060:
061: mConfig = srcroot + security
062: + "/regress/deployconfig/EndptDeployConfig.xml";
063: mConfigSchemaDir = srcroot + security + "/schema";
064: }
065:
066: /**
067: *
068: */
069: public void testRead() throws Exception {
070: try {
071: EndptSecConfigReader reader = new EndptSecConfigReader(
072: Util
073: .getStringTranslator("com.sun.jbi.internal.security"),
074: mConfigSchemaDir);
075: EndpointSecurityConfig epSecConfig = reader
076: .read(new java.io.File(mConfig));
077:
078: // -- Is the Message Policy Read correctly ?
079: MessageSecPolicy msgPolicy = epSecConfig
080: .getMessagePolicy("getTicker");
081: assertNotNull(msgPolicy);
082:
083: assertEquals("OperationMessageProvider", msgPolicy
084: .getMessageProviderId());
085:
086: com.sun.enterprise.security.jauth.AuthPolicy reqPolicy = msgPolicy
087: .getRequestPolicy();
088: assertNotNull(reqPolicy);
089: assertTrue(reqPolicy.isContentAuthRequired());
090: assertTrue(reqPolicy.isRecipientAuthRequired());
091: assertTrue(reqPolicy.isRecipientAuthBeforeContent());
092:
093: com.sun.enterprise.security.jauth.AuthPolicy respPolicy = msgPolicy
094: .getResponsePolicy();
095: assertNotNull(respPolicy);
096: assertTrue(respPolicy.isSenderAuthRequired());
097: assertTrue(respPolicy.isRecipientAuthRequired());
098: assertFalse(respPolicy.isRecipientAuthBeforeContent());
099:
100: // -- Is the Security Environment Read Correctly
101: SecurityContext secCtx = epSecConfig.getSecurityContext();
102:
103: assertNotNull(secCtx);
104: assertEquals("file", secCtx.getUserDomainName());
105: assertEquals("javaks", secCtx.getKeyStoreManagerName());
106: assertEquals("EndpointMessageProvider", secCtx
107: .getMessageProviderId());
108:
109: } catch (Exception ex) {
110: ex.printStackTrace();
111: fail();
112: }
113:
114: }
115:
116: }
|