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: * @(#)SecurityHandlerImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: /**
030: * SecurityHandler.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 October 8, 2004, 6:28 PM
037: */package com.sun.jbi.internal.security;
038:
039: import com.sun.jbi.EnvironmentContext;
040: import com.sun.jbi.StringTranslator;
041: import com.sun.jbi.component.ComponentContext;
042: import com.sun.jbi.binding.security.DeploymentListener;
043: import com.sun.jbi.binding.security.Interceptor;
044:
045: import com.sun.jbi.internal.security.config.SecurityConfiguration;
046: import com.sun.jbi.internal.security.msg.SecurityProcessor;
047: import com.sun.jbi.internal.security.https.SSLHelper;
048:
049: import java.util.logging.Logger;
050:
051: /**
052: * The SecurityHandler interface will be used a Binding Component to
053: * secure outgoing Messages and validate incoming messages. There is a 1:1 association
054: * between a Binding Component and a Security Handler.
055: *
056: * @author Sun Microsystems, Inc.
057: */
058: public class SecurityHandlerImpl implements
059: com.sun.jbi.binding.security.SecurityHandler {
060: /** The Instalation Security Configuration associated with this handler */
061: private SecurityConfiguration mInstallSecConfig = null;
062:
063: /** The Logger. */
064: private static Logger sLogger = null;
065:
066: /** The Security Processor */
067: private SecurityProcessor mSecurityProcessor;
068:
069: /**
070: * The Environment Context of the Component associated with the Security Handler
071: */
072: private com.sun.jbi.internal.security.ComponentContext mEnvCtx;
073:
074: /** The String translator */
075: private StringTranslator mTranslator;
076:
077: /** The SSLHelper Util instance. */
078: private SSLHelper mSSLHelper;
079:
080: /** The DeploymentListenerImpl. */
081: private DeploymentListenerImpl mDeploymentListener;
082:
083: /** The SecurityHandlers Handle to the SecurityService. */
084: private SecurityService mSecSvc;
085:
086: /**
087: * This method creates and initializes the SecurityHandler with the
088: * SecurityConfiguration and the ComponentContext.
089: *
090: * @param secConfig is the installation SecurityConfiguration
091: * @param cmpCtx is the Component Context
092: * @param envCtx is the Security Service Environment Context
093: * @param authLayer is the authentication layer ex. SOAP.
094: * @param secSvc is a handle to the Security Service that created this instance.
095: * @throws IllegalStateException if the SecurityHandler cannot be initialized
096: * successfully.
097: *
098: */
099: protected SecurityHandlerImpl(SecurityConfiguration secConfig,
100: ComponentContext cmpCtx, EnvironmentContext envCtx,
101: SecurityService secSvc, String authLayer)
102: throws IllegalStateException {
103: initialize(secConfig, cmpCtx, envCtx, secSvc, authLayer);
104: }
105:
106: /**
107: * This method initializes the SecurityHandler with the
108: * SecurityConfiguration and the ComponentContext.
109: *
110: * @param secConfig is the installation SecurityConfiguration
111: * @param cmpCtx is the ComponentContext
112: * @param envCtx is the SecurityService EnvironmentContext.
113: * @param secSvc is a handle to the Security Service that created this instance.
114: * @param authLayer is the authentication layer ex. SOAP.
115: * @throws IllegalStateException if the SecurityHandler cannot be initialized
116: * successfully.
117: *
118: */
119: public void initialize(SecurityConfiguration secConfig,
120: ComponentContext cmpCtx, EnvironmentContext envCtx,
121: SecurityService secSvc, String authLayer)
122: throws IllegalStateException {
123: mSecSvc = secSvc;
124: mEnvCtx = new BindingComponentContext(cmpCtx, envCtx);
125: sLogger = Logger
126: .getLogger(com.sun.jbi.internal.security.Constants.PACKAGE);
127:
128: mSSLHelper = new SSLHelper();
129: mInstallSecConfig = secConfig;
130: mSecurityProcessor = new com.sun.jbi.internal.security.msg.SecurityProcessor(
131: mEnvCtx, authLayer);
132: mDeploymentListener = new DeploymentListenerImpl(secSvc
133: .getSchemaDir());
134: mDeploymentListener.addDeploymentObserver(mSSLHelper);
135: mDeploymentListener.addDeploymentObserver(mSecurityProcessor);
136:
137: initStringTranslator();
138: sLogger.info(mTranslator.getString(
139: LocalStringConstants.BC_INFO_SECHANDLER_INITIALIZED,
140: getComponentName()));
141: }
142:
143: /**
144: * Initialize the String translator
145: *
146: */
147: private void initStringTranslator() {
148: mTranslator = mEnvCtx.getStringTranslator(Constants.PACKAGE);
149: }
150:
151: /**
152: * Get an Instance of the Deployment Listener.
153: *
154: * @return an Instance of the Deployment Listener
155: */
156: public DeploymentListener getDeploymentListener() {
157: return mDeploymentListener;
158: }
159:
160: /**
161: * Get an Instance of the Interceptor.
162: *
163: * @return an Instance of the Deployment Listener
164: */
165: public Interceptor getInterceptor() {
166: return mSecurityProcessor;
167: }
168:
169: /**
170: *
171: * Get the HttpSecurityHandler.
172: *
173: * @return a new Instance of the HttpSecurityHandler
174: */
175: public com.sun.jbi.binding.security.HttpSecurityHandler getHttpSecurityHandler() {
176: return new com.sun.jbi.internal.security.https.HttpSecurityHandler(
177: mSSLHelper);
178: }
179:
180: /**
181: * Get the ComponentContext of the Component associated with the
182: * handler. The Environment Context is useful in getting the ComponentId and
183: * the StringTranslator
184: *
185: * @return the ComponentContext instance.
186: */
187: public com.sun.jbi.internal.security.ComponentContext getComponentContext() {
188: return mEnvCtx;
189: }
190:
191: /**
192: * Get the Name of the Component associated with the handler.
193: *
194: * @return the String Component Id.
195: */
196: public String getComponentName() {
197: return mEnvCtx.getComponentName();
198: }
199:
200: }
|