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: * @(#)SecurityService.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: /**
030: * SecurityService.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: */package com.sun.jbi.internal.security;
037:
038: import com.sun.jbi.binding.security.SecurityHandler;
039: import com.sun.jbi.component.ComponentContext;
040: import java.util.HashMap;
041: import javax.jbi.JBIException;
042: import javax.management.MBeanServer;
043: import javax.management.StandardMBean;
044: import javax.management.ObjectName;
045:
046: /**
047: * Implementation of the SecurityService interface.
048: *
049: * @author Sun Microsystems, Inc.
050: */
051: public final class SecurityService extends
052: com.sun.jbi.management.system.ModelSystemService implements
053: com.sun.jbi.binding.security.SecurityService,
054: com.sun.jbi.ServiceLifecycle
055:
056: {
057:
058: /**
059: * The registry of ( ComponnetID: SecurityHandlers )
060: */
061: private HashMap mSecurityHandlers;
062:
063: /**
064: * My Single Instance
065: */
066: private static SecurityService sInstance;
067:
068: /**
069: * The Environment Context.
070: */
071: private com.sun.jbi.EnvironmentContext mEnvCtx;
072:
073: /**
074: * Ctor.
075: */
076: public SecurityService() {
077: mSecurityHandlers = new HashMap();
078: }
079:
080: /**
081: * Get a instance of the Service.
082: * TBD::
083: *
084: * @return a SecurityService instance
085: */
086: public static SecurityService getInstance() {
087: if (sInstance == null) {
088: sInstance = new SecurityService();
089: }
090: return sInstance;
091: }
092:
093: /**
094: * Create a SecurityHandler based on the SecurityConfiguration.
095: *
096: * @param compCtx is the ComponentContext of the Binding Component associated
097: * with the Securityhandler
098: * @param authLayer is the type of layer that requires to use the security services.
099: * @return a instance of the newly created SecurityHandler
100: * @throws IllegalStateException if the SecurityHandler is in a invalid
101: * state on creation.
102: */
103: public SecurityHandler createSecurityHandler(
104: ComponentContext compCtx, String authLayer)
105: throws IllegalStateException {
106: SecurityHandler secHandler = new SecurityHndlr(compCtx);
107: if (compCtx != null) {
108: mSecurityHandlers.put(compCtx.getComponentName(),
109: secHandler);
110: }
111: return secHandler;
112: }
113:
114: /**
115: * Create a SecurityHandler.
116: *
117: * @param compCtx the ComponentContext of the Binding Component associated
118: * with the Securityhandler.
119: * @return a instance of the newly created SecurityHandler
120: * @throws IllegalStateException if the SecurityHandler is in a invalid
121: * state on creation.
122: */
123: public SecurityHandler createSecurityHandler(
124: ComponentContext compCtx) throws IllegalStateException {
125:
126: return this .createSecurityHandler(compCtx, "SOAP");
127: }
128:
129: /**
130: * Get the SecurityHandler for a Component.
131: *
132: * @param componentId is the Component Id
133: * @return a instance of the components SecurityHandler, if it exists null otherwise.
134: */
135: public SecurityHandler getSecurityHandler(String componentId) {
136: return (SecurityHandler) mSecurityHandlers.get(componentId);
137: }
138:
139: /**
140: * Remove the SecurityHandler for the component, this method should be called when
141: * the component is shutdown or uninstalled.
142: *
143: * @param componentId is the Component Id
144: */
145: public void removeSecurityHandler(String componentId) {
146: mSecurityHandlers.remove(componentId);
147: }
148:
149: /**
150: * Initialize the Service.
151: *
152: * @param aContext is the Environment Context.
153: */
154: public void initService(com.sun.jbi.EnvironmentContext aContext)
155: throws javax.jbi.JBIException {
156: mEnvCtx = aContext;
157:
158: //-- no-op
159: }
160:
161: /**
162: * Start the Service.
163: */
164: public void startService() throws javax.jbi.JBIException {
165: //-- no-op
166: }
167:
168: /**
169: * Stop the security service.
170: */
171: public void stopService() throws javax.jbi.JBIException {
172: //-- no-op
173: }
174: }
|