Class WSHandler


  • public abstract class WSHandler
    extends Object
    Extracted from WSDoAllReceiver and WSDoAllSender Extended to all passwordless UsernameTokens and configurable identities.
    • Constructor Detail

      • WSHandler

        public WSHandler()
    • Method Detail

      • doSenderAction

        protected void doSenderAction​(Document doc,
                                      RequestData reqData,
                                      List<HandlerAction> actions,
                                      boolean isRequest)
                               throws WSSecurityException
        Performs all defined security actions to set-up the SOAP request.
        Parameters:
        doc - the request as DOM document
        reqData - a data storage to pass values around between methods
        actions - a list holding the actions to do in the order defined in the deployment file or property, plus an optional associated SecurityActionToken object for that Action
        Throws:
        WSSecurityException
      • decodeTimeToLive

        public int decodeTimeToLive​(RequestData reqData,
                                    boolean timestamp)
        Decode the TimeToLive parameter for either a Timestamp or a UsernameToken Created element, depending on the boolean argument
      • decodeFutureTimeToLive

        protected int decodeFutureTimeToLive​(RequestData reqData,
                                             boolean timestamp)
        Decode the FutureTimeToLive parameter for either a Timestamp or a UsernameToken Created element, depending on the boolean argument
      • loadSignatureCrypto

        public Crypto loadSignatureCrypto​(RequestData requestData)
                                   throws WSSecurityException
        Hook to allow subclasses to load their Signature creation Crypto however they see fit.
        Parameters:
        requestData - the RequestData object
        Returns:
        a Crypto instance to use for Signature creation
        Throws:
        WSSecurityException
      • loadSignatureVerificationCrypto

        public Crypto loadSignatureVerificationCrypto​(RequestData requestData)
                                               throws WSSecurityException
        Hook to allow subclasses to load their Signature verification Crypto however they see fit.
        Parameters:
        requestData - the RequestData object
        Returns:
        a Crypto instance to use for Signature verification
        Throws:
        WSSecurityException
      • loadDecryptionCrypto

        protected Crypto loadDecryptionCrypto​(RequestData requestData)
                                       throws WSSecurityException
        Hook to allow subclasses to load their Decryption Crypto however they see fit.
        Parameters:
        requestData - the RequestData object
        Returns:
        a Crypto instance to use for Decryption creation/verification
        Throws:
        WSSecurityException
      • loadEncryptionCrypto

        protected Crypto loadEncryptionCrypto​(RequestData requestData)
                                       throws WSSecurityException
        Hook to allow subclasses to load their Encryption Crypto however they see fit.
        Parameters:
        requestData - the RequestData object
        Returns:
        a Crypto instance to use for Encryption creation/verification
        Throws:
        WSSecurityException
      • loadCrypto

        protected Crypto loadCrypto​(String cryptoPropertyFile,
                                    String cryptoPropertyRefId,
                                    RequestData requestData)
                             throws WSSecurityException
        Load a Crypto instance. Firstly, it tries to use the cryptoPropertyRefId tag to retrieve a Crypto object via a custom reference Id. Failing this, it tries to load the crypto instance via the cryptoPropertyFile tag.
        Parameters:
        requestData - the RequestData object
        Returns:
        a Crypto instance to use for Encryption creation/verification
        Throws:
        WSSecurityException
      • loadCryptoFromPropertiesFile

        protected Crypto loadCryptoFromPropertiesFile​(String propFilename,
                                                      RequestData reqData)
                                               throws WSSecurityException
        A hook to allow subclass to load Crypto instances from property files in a different way.
        Parameters:
        propFilename - The property file name
        reqData - The RequestData object
        Returns:
        A Crypto instance that has been loaded
        Throws:
        WSSecurityException
      • getCallbackHandler

        public CallbackHandler getCallbackHandler​(String callbackHandlerClass,
                                                  String callbackHandlerRef,
                                                  RequestData requestData)
                                           throws WSSecurityException
        Get a CallbackHandler instance. First try to get an instance via the callbackHandlerRef on the message context. Failing that, try to load a new instance of the CallbackHandler via the callbackHandlerClass argument.
        Parameters:
        callbackHandlerClass - The class name of the CallbackHandler instance
        callbackHandlerRef - The reference name of the CallbackHandler instance
        requestData - The RequestData which supplies the message context
        Returns:
        a CallbackHandler instance
        Throws:
        WSSecurityException
      • getPasswordCallbackHandler

        public CallbackHandler getPasswordCallbackHandler​(RequestData reqData)
                                                   throws WSSecurityException
        Get a CallbackHandler instance to obtain passwords.
        Parameters:
        reqData - The RequestData which supplies the message context
        Returns:
        the CallbackHandler instance to obtain passwords.
        Throws:
        WSSecurityException
      • getPasswordCB

        public WSPasswordCallback getPasswordCB​(String username,
                                                int doAction,
                                                CallbackHandler callbackHandler,
                                                RequestData requestData)
                                         throws WSSecurityException
        Get a password callback (WSPasswordCallback object) from a CallbackHandler instance
        Parameters:
        username - The username to supply to the CallbackHandler
        doAction - The action to perform
        callbackHandler - The CallbackHandler instance
        requestData - The RequestData which supplies the message context
        Returns:
        the WSPasswordCallback object containing the password
        Throws:
        WSSecurityException
      • getStringOption

        public String getStringOption​(String key)
        Returns the option on name.
        Parameters:
        key - the non-null key of the option.
        Returns:
        the option on key if key exists and is of type java.lang.String; otherwise null.
      • getClassLoader

        public ClassLoader getClassLoader​(Object msgCtx)
        Returns the classloader to be used for loading the callback class
        Parameters:
        msgCtx - The MessageContext
        Returns:
        class loader
      • getOption

        public abstract Object getOption​(String key)
      • setProperty

        public abstract void setProperty​(Object msgContext,
                                         String key,
                                         Object value)
      • getPassword

        public abstract String getPassword​(Object msgContext)
      • setPassword

        public abstract void setPassword​(Object msgContext,
                                         String password)