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.TrustManager; 034 035 import org.opends.server.admin.std.server.TrustManagerProviderCfg; 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.TrustManager} objects for use when performing 045 * SSL/StartTLS negotiation. 046 * 047 * @param <T> The type of trust manager provider configuration 048 * handled by this trust manager provider implementation. 049 */ 050 @org.opends.server.types.PublicAPI( 051 stability=org.opends.server.types.StabilityLevel.VOLATILE, 052 mayInstantiate=false, 053 mayExtend=true, 054 mayInvoke=true) 055 public abstract class TrustManagerProvider<T extends 056 TrustManagerProviderCfg> 057 { 058 /** 059 * Initializes this trust manager provider based on the information 060 * in the provided configuration entry. 061 * 062 * @param configuration The configuration to use for this trust 063 * manager provider. 064 * 065 * @throws ConfigException If an unrecoverable problem arises in 066 * the process of performing the 067 * initialization as a result of the 068 * server configuration. 069 * 070 * @throws InitializationException If a problem occurs during 071 * initialization that is not 072 * related to the server 073 * configuration. 074 */ 075 public abstract void initializeTrustManagerProvider( 076 T configuration) 077 throws ConfigException, InitializationException; 078 079 080 081 /** 082 * Indicates whether the provided configuration is acceptable for 083 * this trust manager provider. It should be possible to call this 084 * method on an uninitialized trust manager provider instance in 085 * order to determine whether the trust manager provider would be 086 * able to use the provided configuration. 087 * <BR><BR> 088 * Note that implementations which use a subclass of the provided 089 * configuration class will likely need to cast the configuration 090 * to the appropriate subclass type. 091 * 092 * @param configuration The trust manager provider 093 * configuration for which to make the 094 * determination. 095 * @param unacceptableReasons A list that may be used to hold the 096 * reasons that the provided 097 * configuration is not acceptable. 098 * 099 * @return {@code true} if the provided configuration is acceptable 100 * for this trust manager provider, or {@code false} if 101 * not. 102 */ 103 public boolean isConfigurationAcceptable( 104 TrustManagerProviderCfg configuration, 105 List<Message> unacceptableReasons) 106 { 107 // This default implementation does not perform any special 108 // validation. It should be overridden by trust manager provider 109 // implementations that wish to perform more detailed validation. 110 return true; 111 } 112 113 114 115 /** 116 * Performs any finalization that may be necessary for this trust 117 * manager provider. 118 */ 119 public abstract void finalizeTrustManagerProvider(); 120 121 122 123 /** 124 * Retrieves a set of {@code TrustManager} objects that may be used 125 * for interactions requiring access to a trust manager. 126 * 127 * @return A set of {@code TrustManager} objects that may be used 128 * for interactions requiring access to a trust manager. 129 * 130 * @throws DirectoryException If a problem occurs while attempting 131 * to obtain the set of trust managers. 132 */ 133 public abstract TrustManager[] getTrustManagers() 134 throws DirectoryException; 135 } 136