ProviderList.java revision 1266
3876N/A * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2362N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * This class stores the list of providers that this 4632N/A * GSS-Implementation is configured to use. The GSSManagerImpl class 4632N/A * queries this class whenever it needs a mechanism's factory.<p> 4632N/A * This class stores an ordered list of pairs of the form 4632N/A * <provider, oid>. When it attempts to instantiate a mechanism 4632N/A * defined by oid o, it steps through the list looking for an entry 4632N/A * with oid=o, or with oid=null. (An entry with oid=null matches all 4632N/A * mechanisms.) When it finds such an entry, the corresponding 4632N/A * provider is approached for the mechanism's factory class. 4632N/A * At instantiation time this list in initialized to contain those 4632N/A * system wide providers that contain a property of the form 0N/A * "GssApiMechanism.x.y.z..." where "x.y.z..." is a numeric object 0N/A * identifier with numbers x, y, z, etc. Such a property is defined 0N/A * to map to that provider's implementation of the MechanismFactory 4632N/A * interface for the mechanism x.y.z... 0N/A * As and when a MechanismFactory is instantiated, it is 2884N/A * cached for future use. <p> 2884N/A * An application can cause more providers to be added by means of 0N/A * the addProviderAtFront and addProviderAtEnd methods on 0N/A * GSSManager which get delegated to this class. The 0N/A * addProviderAtFront method can also cause a change in the ordering 0N/A * of the providers without adding any new providers, by causing a 0N/A * provider to move up in a list. The method addProviderAtEnd can 4632N/A * only add providers at the end of the list if they are not already 0N/A * in the list. The rationale is that an application will call 3876N/A * addProviderAtFront when it wants a provider to be used in 3876N/A * preference over the default ones. And it will call 3876N/A * addProviderAtEnd when it wants a provider to be used in case 3876N/A * the system ones don't suffice.<p> 0N/A * If a mechanism's factory is being obtained from a provider as a 0N/A * result of encountering a entryof the form <provider, oid> where 0N/A * oid is non-null, then the assumption is that the application added 0N/A * this entry and it wants this mechanism to be obtained from this 0N/A * provider. Thus is the provider does not actually contain the 0N/A * requested mechanism, an exception will be thrown. However, if the 0N/A * entry were of the form <provider, null>, then it is viewed more 0N/A * liberally and is simply skipped over if the provider does not claim to 0N/A * support the requested mechanism. 0N/A =
"sun.security.jgss.spi.MechanismFactory";
0N/A // Undocumented property? 0N/A "sun.security.jgss.mechanism";
0N/A * Set the default mechanism. Kerberos v5 is the default 0N/A * mechanism unless it is overridden by a system property. 0N/A * with a valid OID value 2700N/A // Move on to the next provider 4632N/A * Determines if the given provider property represents a GSS-API 4632N/A * Oid to MechanismFactory mapping. 2700N/A * @return true if this is a GSS-API property, false otherwise. 2700N/A // So the existing code do not have to be changed 2700N/A * Obtains a MechanismFactory for a given mechanism. If the 2700N/A * specified provider is not null, then the impl from the 2700N/A * provider is used. Otherwise, the most preferred impl based 2700N/A * on the configured preferences is used. 2700N/A * @param mechOid the oid of the desired mechanism 2700N/A * @return a MechanismFactory for the desired mechanism. 2700N/A * @throws GSSException when the specified provider does not 2700N/A * support the desired mechanism, or when no provider supports 4632N/A // Iterate thru all preferences to find right provider 2700N/A // Use the impl from the specified provider; return null if the 2700N/A // the mech is unsupported by the specified provider. 2700N/A * Helper routine that uses a preferences entry to obtain an 2700N/A * implementation of a MechanismFactory from it. 2700N/A * @param e the preferences entry that contains the provider and 2700N/A * either a null of an explicit oid that matched the oid of the 2976N/A * @param mechOid the oid of the desired mechanism 2976N/A * @throws GSSException If the application explicitly requested 2976N/A * this entry's provider to be used for the desired mechanism but 2976N/A * some problem is encountered 2700N/A * See if a MechanismFactory was previously instantiated for 2700N/A * this provider and mechanism combination. 2700N/A * Apparently not. Now try to instantiate this class from 3082N/A * This provider does not support this mechanism. 3082N/A * If the application explicitly requested that 2700N/A * this provider be used for this mechanism, then 2976N/A * Helper routine to obtain a MechanismFactory implementation 2976N/A * from the same class loader as the provider of this 2976N/A * @param p the provider whose classloader must be used for 2976N/A * instantiating the desired MechanismFactory 2976N/A * @ param className the name of the MechanismFactory class 2976N/A * @throws GSSException If some error occurs when trying to 2976N/A * instantiate this MechanismFactory. 2700N/A * Load the implementation class with the same class loader 2700N/A * that was used to load the provider. 2700N/A * In order to get the class loader of a class, the 2700N/A * caller's class loader must be the same as or an ancestor of 2700N/A * the class loader being returned. Otherwise, the caller must 2700N/A * have "getClassLoader" permission, or a SecurityException 2700N/A // Only used by getMechFactoryImpl 0N/A +
" does not support " 4632N/A // System.out.println("addProviderAtEnd: No it is not redundant"); 4632N/A * Helper routine to go through all properties contined in a 4632N/A * provider and add its mechanisms to the list of supported 3876N/A * mechanisms. If no default mechanism has been assinged so far, 3876N/A * it sets the default MechanismFactory and Oid as well. 3876N/A * @param p the provider to query 3876N/A * @return true if there is at least one mechanism that this 4632N/A * provider contributed, false otherwise 3876N/A // Get all props for this provider 4632N/A // See if there are any GSS prop's 4632N/A // Ok! This is a GSS provider! 0N/A // Skip to next property 0N/A }
// Processed GSS property 0N/A * Stores a provider and a mechanism oid indicating that the 0N/A * provider should be used for the mechanism. If the mechanism 0N/A * Oid is null, then it indicates that this preference holds for 0N/A * The ProviderList maintains an ordered list of 0N/A * PreferencesEntry's and iterates thru them as it tries to 0N/A * instantiate MechanismFactory's. 2976N/A * Determines if a preference implies another. A preference 2700N/A * implies another if the latter is subsumed by the 2700N/A * former. e.g., <Provider1, null> implies <Provider1, OidX> 2700N/A * because the null in the former indicates that it should 0N/A * be used for all mechanisms. 0N/A * Determines if this entry is applicable to the desired 0N/A * mechanism. The entry is applicable to the desired mech if 0N/A * it contains the same oid or if it contains a null oid 0N/A * indicating that it is applicable to all mechs. 0N/A * @param mechOid the desired mechanism 0N/A * @return true if the provider in this entry should be 0N/A * queried for this mechanism.