Module 
Package org.xnio.sasl

Class SaslWrapper


  • public abstract class SaslWrapper
    extends java.lang.Object
    A wrapper delegation class for SASL that presents the same wrap/unwrap API regardless of whether it is dealing with a SASL client or server.
    Author:
    David M. Lloyd
    • Constructor Summary

      Constructors 
      Constructor Description
      SaslWrapper()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static SaslWrapper create​(javax.security.sasl.SaslClient saslClient)
      Create a SASL wrapper for a SASL client.
      static SaslWrapper create​(javax.security.sasl.SaslServer saslServer)
      Create a SASL wrapper for a SASL server.
      byte[] unwrap​(byte[] bytes)
      Unwrap a message.
      abstract byte[] unwrap​(byte[] bytes, int off, int len)
      Unwrap a message.
      abstract byte[] unwrap​(java.nio.ByteBuffer source)
      Unwrap a message.
      void unwrap​(java.nio.ByteBuffer destination, java.nio.ByteBuffer source)
      Unwrap a message.
      byte[] wrap​(byte[] bytes)
      Wrap a message.
      abstract byte[] wrap​(byte[] bytes, int off, int len)
      Wrap a message.
      abstract byte[] wrap​(java.nio.ByteBuffer source)
      Wrap a message.
      void wrap​(java.nio.ByteBuffer destination, java.nio.ByteBuffer source)
      Wrap a message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SaslWrapper

        public SaslWrapper()
    • Method Detail

      • wrap

        public abstract byte[] wrap​(byte[] bytes,
                                    int off,
                                    int len)
                             throws javax.security.sasl.SaslException
        Wrap a message.
        Parameters:
        bytes - the incoming message
        off - the offset into the byte array
        len - the length of the byte array to wrap
        Returns:
        the wrap result
        Throws:
        javax.security.sasl.SaslException - if a problem occurs
      • wrap

        public final byte[] wrap​(byte[] bytes)
                          throws javax.security.sasl.SaslException
        Wrap a message.
        Parameters:
        bytes - the incoming message
        Returns:
        the wrap result
        Throws:
        javax.security.sasl.SaslException - if a problem occurs
      • wrap

        public abstract byte[] wrap​(java.nio.ByteBuffer source)
                             throws javax.security.sasl.SaslException
        Wrap a message.
        Parameters:
        source - the buffer from which bytes should be read
        Returns:
        the wrap result
        Throws:
        javax.security.sasl.SaslException - if a problem occurs
      • unwrap

        public abstract byte[] unwrap​(byte[] bytes,
                                      int off,
                                      int len)
                               throws javax.security.sasl.SaslException
        Unwrap a message.
        Parameters:
        bytes - the incoming message
        off - the offset into the byte array
        len - the length of the byte array to wrap
        Returns:
        the unwrap result
        Throws:
        javax.security.sasl.SaslException - if a problem occurs
      • unwrap

        public final byte[] unwrap​(byte[] bytes)
                            throws javax.security.sasl.SaslException
        Unwrap a message.
        Parameters:
        bytes - the incoming message
        Returns:
        the unwrap result
        Throws:
        javax.security.sasl.SaslException - if a problem occurs
      • unwrap

        public abstract byte[] unwrap​(java.nio.ByteBuffer source)
                               throws javax.security.sasl.SaslException
        Unwrap a message.
        Parameters:
        source - the buffer from which bytes should be read
        Returns:
        the unwrap result
        Throws:
        javax.security.sasl.SaslException - if a problem occurs
      • wrap

        public final void wrap​(java.nio.ByteBuffer destination,
                               java.nio.ByteBuffer source)
                        throws javax.security.sasl.SaslException
        Wrap a message. Wrapping occurs from the source buffer to the destination idea.

        The source buffer should have its position and remaining length set to encompass exactly one SASL message (without the length field). The SASL message itself does not encode any length information so it is up to the protocol implementer to ensure that the message is properly framed.

        Parameters:
        destination - the buffer into which bytes should be written
        source - the buffers from which bytes should be read
        Throws:
        javax.security.sasl.SaslException - if a SASL error occurs
        See Also:
        SaslClient.wrap(byte[], int, int), SaslServer.wrap(byte[], int, int)
      • unwrap

        public final void unwrap​(java.nio.ByteBuffer destination,
                                 java.nio.ByteBuffer source)
                          throws javax.security.sasl.SaslException
        Unwrap a message. Unwrapping occurs from the source buffer to the destination idea.

        The source buffer should have its position and remaining length set to encompass exactly one SASL message (without the length field). The SASL message itself does not encode any length information so it is up to the protocol implementer to ensure that the message is properly framed.

        Parameters:
        destination - the buffer into which bytes should be written
        source - the buffers from which bytes should be read
        Throws:
        javax.security.sasl.SaslException - if a SASL error occurs
        See Also:
        SaslClient.unwrap(byte[], int, int)
      • create

        public static SaslWrapper create​(javax.security.sasl.SaslClient saslClient)
        Create a SASL wrapper for a SASL client.
        Parameters:
        saslClient - the SASL client
        Returns:
        the wrapper
      • create

        public static SaslWrapper create​(javax.security.sasl.SaslServer saslServer)
        Create a SASL wrapper for a SASL server.
        Parameters:
        saslServer - the SASL server
        Returns:
        the wrapper