Class KeyResolver


  • public class KeyResolver
    extends java.lang.Object
    KeyResolver is factory class for subclass of KeyResolverSpi that represent child element of KeyInfo.
    • Field Detail

      • LOG

        private static final org.slf4j.Logger LOG
      • resolverVector

        private static java.util.List<KeyResolver> resolverVector
        Field resolverVector
      • resolverSpi

        private final KeyResolverSpi resolverSpi
        Field resolverSpi
    • Constructor Detail

      • KeyResolver

        private KeyResolver​(KeyResolverSpi keyResolverSpi)
        Constructor.
        Parameters:
        keyResolverSpi - a KeyResolverSpi instance
    • Method Detail

      • length

        public static int length()
        Method length
        Returns:
        the length of resolvers registered
      • getX509Certificate

        public static final java.security.cert.X509Certificate getX509Certificate​(org.w3c.dom.Element element,
                                                                                  java.lang.String baseURI,
                                                                                  StorageResolver storage)
                                                                           throws KeyResolverException
        Method getX509Certificate
        Parameters:
        element -
        baseURI -
        storage -
        Returns:
        The certificate represented by the element.
        Throws:
        KeyResolverException
      • getPublicKey

        public static final java.security.PublicKey getPublicKey​(org.w3c.dom.Element element,
                                                                 java.lang.String baseURI,
                                                                 StorageResolver storage)
                                                          throws KeyResolverException
        Method getPublicKey
        Parameters:
        element -
        baseURI -
        storage -
        Returns:
        the public key contained in the element
        Throws:
        KeyResolverException
      • register

        public static void register​(java.lang.String className,
                                    boolean globalResolver)
                             throws java.lang.ClassNotFoundException,
                                    java.lang.IllegalAccessException,
                                    java.lang.InstantiationException
        This method is used for registering KeyResolverSpis which are available to all KeyInfo objects. This means that personalized KeyResolverSpis should only be registered directly to the KeyInfo using KeyInfo.registerInternalKeyResolver(org.apache.xml.security.keys.keyresolver.KeyResolverSpi). Please note that this method will create a new copy of the underlying array, as the underlying collection is a CopyOnWriteArrayList.
        Parameters:
        className -
        globalResolver - Whether the KeyResolverSpi is a global resolver or not
        Throws:
        java.lang.InstantiationException
        java.lang.IllegalAccessException
        java.lang.ClassNotFoundException
        java.lang.SecurityException - if a security manager is installed and the caller does not have permission to register the key resolver
      • registerAtStart

        public static void registerAtStart​(java.lang.String className,
                                           boolean globalResolver)
        This method is used for registering KeyResolverSpis which are available to all KeyInfo objects. This means that personalized KeyResolverSpis should only be registered directly to the KeyInfo using KeyInfo.registerInternalKeyResolver(org.apache.xml.security.keys.keyresolver.KeyResolverSpi). Please note that this method will create a new copy of the underlying array, as the underlying collection is a CopyOnWriteArrayList.
        Parameters:
        className -
        globalResolver - Whether the KeyResolverSpi is a global resolver or not
        Throws:
        java.lang.SecurityException - if a security manager is installed and the caller does not have permission to register the key resolver
      • register

        public static void register​(KeyResolverSpi keyResolverSpi,
                                    boolean start)
        This method is used for registering KeyResolverSpis which are available to all KeyInfo objects. This means that personalized KeyResolverSpis should only be registered directly to the KeyInfo using KeyInfo.registerInternalKeyResolver(org.apache.xml.security.keys.keyresolver.KeyResolverSpi). Please note that this method will create a new copy of the underlying array, as the underlying collection is a CopyOnWriteArrayList.
        Parameters:
        keyResolverSpi - a KeyResolverSpi instance to register
        start - whether to register the KeyResolverSpi at the start of the list or not
        Throws:
        java.lang.SecurityException - if a security manager is installed and the caller does not have permission to register the key resolver
      • registerClassNames

        public static void registerClassNames​(java.util.List<java.lang.String> classNames)
                                       throws java.lang.ClassNotFoundException,
                                              java.lang.IllegalAccessException,
                                              java.lang.InstantiationException
        This method is used for registering KeyResolverSpis which are available to all KeyInfo objects. This means that personalized KeyResolverSpis should only be registered directly to the KeyInfo using KeyInfo.registerInternalKeyResolver(org.apache.xml.security.keys.keyresolver.KeyResolverSpi). The KeyResolverSpi instances are not registered as a global resolver.
        Parameters:
        classNames -
        Throws:
        java.lang.InstantiationException
        java.lang.IllegalAccessException
        java.lang.ClassNotFoundException
        java.lang.SecurityException - if a security manager is installed and the caller does not have permission to register the key resolver
      • registerDefaultResolvers

        public static void registerDefaultResolvers()
        This method registers the default resolvers.
      • resolvePublicKey

        public java.security.PublicKey resolvePublicKey​(org.w3c.dom.Element element,
                                                        java.lang.String baseURI,
                                                        StorageResolver storage)
                                                 throws KeyResolverException
        Method resolvePublicKey
        Parameters:
        element -
        baseURI -
        storage -
        Returns:
        resolved public key from the registered from the elements
        Throws:
        KeyResolverException
      • resolveX509Certificate

        public java.security.cert.X509Certificate resolveX509Certificate​(org.w3c.dom.Element element,
                                                                         java.lang.String baseURI,
                                                                         StorageResolver storage)
                                                                  throws KeyResolverException
        Method resolveX509Certificate
        Parameters:
        element -
        baseURI -
        storage -
        Returns:
        resolved X509certificate key from the registered from the elements
        Throws:
        KeyResolverException
      • resolveSecretKey

        public javax.crypto.SecretKey resolveSecretKey​(org.w3c.dom.Element element,
                                                       java.lang.String baseURI,
                                                       StorageResolver storage)
                                                throws KeyResolverException
        Parameters:
        element -
        baseURI -
        storage -
        Returns:
        resolved SecretKey key from the registered from the elements
        Throws:
        KeyResolverException
      • setProperty

        public void setProperty​(java.lang.String key,
                                java.lang.String value)
        Method setProperty
        Parameters:
        key -
        value -
      • getProperty

        public java.lang.String getProperty​(java.lang.String key)
        Method getProperty
        Parameters:
        key -
        Returns:
        the property set for this resolver
      • understandsProperty

        public boolean understandsProperty​(java.lang.String propertyToTest)
        Method understandsProperty
        Parameters:
        propertyToTest -
        Returns:
        true if the resolver understands property propertyToTest
      • resolverClassName

        public java.lang.String resolverClassName()
        Method resolverClassName
        Returns:
        the name of the resolver.
      • iterator

        public static java.util.Iterator<KeyResolverSpi> iterator()