001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2006-2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.api;
028 import org.opends.messages.Message;
029
030
031
032 import java.util.List;
033 import javax.net.ssl.KeyManager;
034
035 import org.opends.server.admin.std.server.KeyManagerProviderCfg;
036 import org.opends.server.config.ConfigException;
037 import org.opends.server.types.DirectoryException;
038 import org.opends.server.types.InitializationException;
039
040
041
042 /**
043 * This class defines an API that may be used to obtain a set of
044 * {@code javax.net.ssl.KeyManager} objects for use when performing
045 * SSL communication.
046 *
047 * @param <T>
048 * The type of key manager provider configuration handled by
049 * this key manager provider implementation.
050 */
051 @org.opends.server.types.PublicAPI(
052 stability=org.opends.server.types.StabilityLevel.VOLATILE,
053 mayInstantiate=false,
054 mayExtend=true,
055 mayInvoke=true)
056 public abstract class KeyManagerProvider
057 <T extends KeyManagerProviderCfg>
058 {
059 /**
060 * Initializes this key manager provider based on the information in
061 * the provided key manager provider configuration.
062 *
063 * @param configuration
064 * The key manager provider configuration that contains the
065 * information to use to initialize this key manager
066 * provider.
067 * @throws ConfigException
068 * If an unrecoverable problem arises in the process of
069 * performing the initialization as a result of the server
070 * configuration.
071 * @throws InitializationException
072 * If a problem occurs during initialization that is not
073 * related to the server configuration.
074 */
075 public abstract void initializeKeyManagerProvider(T configuration)
076 throws ConfigException, InitializationException;
077
078
079
080 /**
081 * Indicates whether the provided configuration is acceptable for
082 * this key manager provider. It should be possible to call this
083 * method on an uninitialized key manager provider instance in order
084 * to determine whether the key manager provider would be able to
085 * use the provided configuration.
086 * <BR><BR>
087 * Note that implementations which use a subclass of the provided
088 * configuration class will likely need to cast the configuration
089 * to the appropriate subclass type.
090 *
091 * @param configuration The key manager provider
092 * configuration for which to make the
093 * determination.
094 * @param unacceptableReasons A list that may be used to hold the
095 * reasons that the provided
096 * configuration is not acceptable.
097 *
098 * @return {@code true} if the provided configuration is acceptable
099 * for this key manager provider, or {@code false} if not.
100 */
101 public boolean isConfigurationAcceptable(
102 T configuration,
103 List<Message> unacceptableReasons)
104 {
105 // This default implementation does not perform any special
106 // validation. It should be overridden by key manager provider
107 // implementations that wish to perform more detailed validation.
108 return true;
109 }
110
111
112
113 /**
114 * Performs any finalization that may be necessary for this key
115 * manager provider.
116 */
117 public abstract void finalizeKeyManagerProvider();
118
119
120
121 /**
122 * Retrieves a set of {@code KeyManager} objects that may be used
123 * for interactions requiring access to a key manager.
124 *
125 * @return A set of {@code KeyManager} objects that may be used for
126 * interactions requiring access to a key manager.
127 *
128 * @throws DirectoryException If a problem occurs while attempting
129 * to obtain the set of key managers.
130 */
131 public abstract KeyManager[] getKeyManagers()
132 throws DirectoryException;
133 }
134