Class ServerSaslPeer

  • All Implemented Interfaces:
    SaslPeer

    public class ServerSaslPeer
    extends java.lang.Object
    implements SaslPeer
    Server side sasl peer, a wrapper around SaslServer to provide some handy methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      ServerSaslPeer​(javax.security.sasl.SaslServer saslServer)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()
      Close this peer and release resources.
      byte[] evaluate​(byte[] negotiationMessage)
      Evaluate and validate the negotiation message (response/challenge) received from peer.
      boolean isAuthenticated()  
      boolean isDataProtected()
      This method can only be called when the negotiation is complete (isAuthenticated returns true).
      byte[] unwrap​(byte[] data, int offset, int length)
      Unwrap protected data to raw bytes.
      byte[] wrap​(byte[] data, int offset, int length)
      Wrap raw bytes to protect it.
      • Methods inherited from class java.lang.Object

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

      • ServerSaslPeer

        public ServerSaslPeer​(javax.security.sasl.SaslServer saslServer)
    • Method Detail

      • evaluate

        public byte[] evaluate​(byte[] negotiationMessage)
                        throws TSaslNegotiationException
        Description copied from interface: SaslPeer
        Evaluate and validate the negotiation message (response/challenge) received from peer.
        Specified by:
        evaluate in interface SaslPeer
        Parameters:
        negotiationMessage - response/challenge received from peer.
        Returns:
        new response/challenge to send to peer, can be null if authentication becomes success.
        Throws:
        TSaslNegotiationException - if sasl authentication fails.
      • isAuthenticated

        public boolean isAuthenticated()
        Specified by:
        isAuthenticated in interface SaslPeer
        Returns:
        true if authentication is done.
      • isDataProtected

        public boolean isDataProtected()
        Description copied from interface: SaslPeer
        This method can only be called when the negotiation is complete (isAuthenticated returns true). Otherwise it will throw IllegalStateExceptiion.
        Specified by:
        isDataProtected in interface SaslPeer
        Returns:
        if the qop requires some integrity/confidential protection.
      • wrap

        public byte[] wrap​(byte[] data,
                           int offset,
                           int length)
                    throws TTransportException
        Description copied from interface: SaslPeer
        Wrap raw bytes to protect it.
        Specified by:
        wrap in interface SaslPeer
        Parameters:
        data - raw bytes.
        offset - the start position of the content to wrap.
        length - the length of the content to wrap.
        Returns:
        bytes with protection to send to peer.
        Throws:
        TTransportException - if failure.
      • unwrap

        public byte[] unwrap​(byte[] data,
                             int offset,
                             int length)
                      throws TTransportException
        Description copied from interface: SaslPeer
        Unwrap protected data to raw bytes.
        Specified by:
        unwrap in interface SaslPeer
        Parameters:
        data - protected data received from peer.
        offset - the start position of the content to unwrap.
        length - the length of the content to unwrap.
        Returns:
        raw bytes.
        Throws:
        TTransportException - if failed.
      • dispose

        public void dispose()
        Description copied from interface: SaslPeer
        Close this peer and release resources.
        Specified by:
        dispose in interface SaslPeer