< prev index next >

src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java

Print this page




 165     /**
 166      * This method is used for registering {@link KeyResolverSpi}s which are
 167      * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
 168      * personalized {@link KeyResolverSpi}s should only be registered directly
 169      * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
 170      * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
 171      * Please note that this method will create a new copy of the underlying array, as the
 172      * underlying collection is a CopyOnWriteArrayList.
 173      *
 174      * @param className
 175      * @param globalResolver Whether the KeyResolverSpi is a global resolver or not
 176      * @throws InstantiationException
 177      * @throws IllegalAccessException
 178      * @throws ClassNotFoundException
 179      * @throws SecurityException if a security manager is installed and the
 180      *    caller does not have permission to register the key resolver
 181      */
 182     public static void register(String className, boolean globalResolver)
 183         throws ClassNotFoundException, IllegalAccessException, InstantiationException {
 184         JavaUtils.checkRegisterPermission();

 185         KeyResolverSpi keyResolverSpi =
 186             (KeyResolverSpi) Class.forName(className).newInstance();
 187         keyResolverSpi.setGlobalResolver(globalResolver);
 188         register(keyResolverSpi, false);
 189     }
 190 
 191     /**
 192      * This method is used for registering {@link KeyResolverSpi}s which are
 193      * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
 194      * personalized {@link KeyResolverSpi}s should only be registered directly
 195      * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
 196      * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
 197      * Please note that this method will create a new copy of the underlying array, as the
 198      * underlying collection is a CopyOnWriteArrayList.
 199      *
 200      * @param className
 201      * @param globalResolver Whether the KeyResolverSpi is a global resolver or not
 202      * @throws SecurityException if a security manager is installed and the
 203      *    caller does not have permission to register the key resolver
 204      */
 205     public static void registerAtStart(String className, boolean globalResolver) {
 206         JavaUtils.checkRegisterPermission();
 207         KeyResolverSpi keyResolverSpi = null;
 208         Exception ex = null;
 209         try {
 210             keyResolverSpi = (KeyResolverSpi) Class.forName(className).newInstance();


 211         } catch (ClassNotFoundException e) {
 212             ex = e;
 213         } catch (IllegalAccessException e) {
 214             ex = e;
 215         } catch (InstantiationException e) {
 216             ex = e;
 217         }
 218 
 219         if (ex != null) {
 220             throw (IllegalArgumentException) new
 221             IllegalArgumentException("Invalid KeyResolver class name").initCause(ex);
 222         }
 223         keyResolverSpi.setGlobalResolver(globalResolver);
 224         register(keyResolverSpi, true);
 225     }
 226 
 227     /**
 228      * This method is used for registering {@link KeyResolverSpi}s which are
 229      * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
 230      * personalized {@link KeyResolverSpi}s should only be registered directly


 255      * This method is used for registering {@link KeyResolverSpi}s which are
 256      * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
 257      * personalized {@link KeyResolverSpi}s should only be registered directly
 258      * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
 259      * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
 260      * The KeyResolverSpi instances are not registered as a global resolver.
 261      *
 262      *
 263      * @param classNames
 264      * @throws InstantiationException
 265      * @throws IllegalAccessException
 266      * @throws ClassNotFoundException
 267      * @throws SecurityException if a security manager is installed and the
 268      *    caller does not have permission to register the key resolver
 269      */
 270     public static void registerClassNames(List<String> classNames)
 271         throws ClassNotFoundException, IllegalAccessException, InstantiationException {
 272         JavaUtils.checkRegisterPermission();
 273         List<KeyResolver> keyResolverList = new ArrayList<KeyResolver>(classNames.size());
 274         for (String className : classNames) {

 275             KeyResolverSpi keyResolverSpi =
 276                 (KeyResolverSpi) Class.forName(className).newInstance();
 277             keyResolverSpi.setGlobalResolver(false);
 278             keyResolverList.add(new KeyResolver(keyResolverSpi));
 279         }
 280         resolverVector.addAll(keyResolverList);
 281     }
 282 
 283     /**
 284      * This method registers the default resolvers.
 285      */
 286     public static void registerDefaultResolvers() {
 287 
 288         List<KeyResolver> keyResolverList = new ArrayList<KeyResolver>();
 289         keyResolverList.add(new KeyResolver(new RSAKeyValueResolver()));
 290         keyResolverList.add(new KeyResolver(new DSAKeyValueResolver()));
 291         keyResolverList.add(new KeyResolver(new X509CertificateResolver()));
 292         keyResolverList.add(new KeyResolver(new X509SKIResolver()));
 293         keyResolverList.add(new KeyResolver(new RetrievalMethodResolver()));
 294         keyResolverList.add(new KeyResolver(new X509SubjectNameResolver()));




 165     /**
 166      * This method is used for registering {@link KeyResolverSpi}s which are
 167      * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
 168      * personalized {@link KeyResolverSpi}s should only be registered directly
 169      * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
 170      * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
 171      * Please note that this method will create a new copy of the underlying array, as the
 172      * underlying collection is a CopyOnWriteArrayList.
 173      *
 174      * @param className
 175      * @param globalResolver Whether the KeyResolverSpi is a global resolver or not
 176      * @throws InstantiationException
 177      * @throws IllegalAccessException
 178      * @throws ClassNotFoundException
 179      * @throws SecurityException if a security manager is installed and the
 180      *    caller does not have permission to register the key resolver
 181      */
 182     public static void register(String className, boolean globalResolver)
 183         throws ClassNotFoundException, IllegalAccessException, InstantiationException {
 184         JavaUtils.checkRegisterPermission();
 185         @SuppressWarnings("deprecation")
 186         KeyResolverSpi keyResolverSpi =
 187             (KeyResolverSpi) Class.forName(className).newInstance();
 188         keyResolverSpi.setGlobalResolver(globalResolver);
 189         register(keyResolverSpi, false);
 190     }
 191 
 192     /**
 193      * This method is used for registering {@link KeyResolverSpi}s which are
 194      * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
 195      * personalized {@link KeyResolverSpi}s should only be registered directly
 196      * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
 197      * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
 198      * Please note that this method will create a new copy of the underlying array, as the
 199      * underlying collection is a CopyOnWriteArrayList.
 200      *
 201      * @param className
 202      * @param globalResolver Whether the KeyResolverSpi is a global resolver or not
 203      * @throws SecurityException if a security manager is installed and the
 204      *    caller does not have permission to register the key resolver
 205      */
 206     public static void registerAtStart(String className, boolean globalResolver) {
 207         JavaUtils.checkRegisterPermission();
 208         KeyResolverSpi keyResolverSpi = null;
 209         Exception ex = null;
 210         try {
 211             @SuppressWarnings("deprecation")
 212             Object tmp = Class.forName(className).newInstance();
 213             keyResolverSpi = (KeyResolverSpi) tmp;
 214         } catch (ClassNotFoundException e) {
 215             ex = e;
 216         } catch (IllegalAccessException e) {
 217             ex = e;
 218         } catch (InstantiationException e) {
 219             ex = e;
 220         }
 221 
 222         if (ex != null) {
 223             throw (IllegalArgumentException) new
 224             IllegalArgumentException("Invalid KeyResolver class name").initCause(ex);
 225         }
 226         keyResolverSpi.setGlobalResolver(globalResolver);
 227         register(keyResolverSpi, true);
 228     }
 229 
 230     /**
 231      * This method is used for registering {@link KeyResolverSpi}s which are
 232      * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
 233      * personalized {@link KeyResolverSpi}s should only be registered directly


 258      * This method is used for registering {@link KeyResolverSpi}s which are
 259      * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
 260      * personalized {@link KeyResolverSpi}s should only be registered directly
 261      * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
 262      * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
 263      * The KeyResolverSpi instances are not registered as a global resolver.
 264      *
 265      *
 266      * @param classNames
 267      * @throws InstantiationException
 268      * @throws IllegalAccessException
 269      * @throws ClassNotFoundException
 270      * @throws SecurityException if a security manager is installed and the
 271      *    caller does not have permission to register the key resolver
 272      */
 273     public static void registerClassNames(List<String> classNames)
 274         throws ClassNotFoundException, IllegalAccessException, InstantiationException {
 275         JavaUtils.checkRegisterPermission();
 276         List<KeyResolver> keyResolverList = new ArrayList<KeyResolver>(classNames.size());
 277         for (String className : classNames) {
 278             @SuppressWarnings("deprecation")
 279             KeyResolverSpi keyResolverSpi =
 280                 (KeyResolverSpi) Class.forName(className).newInstance();
 281             keyResolverSpi.setGlobalResolver(false);
 282             keyResolverList.add(new KeyResolver(keyResolverSpi));
 283         }
 284         resolverVector.addAll(keyResolverList);
 285     }
 286 
 287     /**
 288      * This method registers the default resolvers.
 289      */
 290     public static void registerDefaultResolvers() {
 291 
 292         List<KeyResolver> keyResolverList = new ArrayList<KeyResolver>();
 293         keyResolverList.add(new KeyResolver(new RSAKeyValueResolver()));
 294         keyResolverList.add(new KeyResolver(new DSAKeyValueResolver()));
 295         keyResolverList.add(new KeyResolver(new X509CertificateResolver()));
 296         keyResolverList.add(new KeyResolver(new X509SKIResolver()));
 297         keyResolverList.add(new KeyResolver(new RetrievalMethodResolver()));
 298         keyResolverList.add(new KeyResolver(new X509SubjectNameResolver()));


< prev index next >