Interface Output

  • All Known Implementing Classes:
    SimpleOutput

    public interface Output
    Core interface for handling encrypted/signed payloads.

    An object implementing this interface is always returned by a SecurityService instance when any of the encrypt, sign or verify methods.

    Ultimately the object implementing this interface will be reponsible for reading from and writing to an encrypted payload. This payload could be in any particular format e.g. something like S/MIME or EDI-INT with boundaries and such.

    The type of output that is represented can be determined using the getType() method.

    Three types of message are defined

    • ENCRYPTED
    • PLAIN
    • SIGNED

    For payloads that are both encrypted and signed, the operations

    • if (Output.getType() & Output.ENCRYPTED) > 0)
    • if (Output.getType() & Output.SIGNED) > 0)
    should be true

    Alternatively, the isEncrypted(), isSigned(), isPlain() methods can be used.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ENCRYPTED
      encrypted output
      static int PLAIN
      decrypted output
      static int SIGNED
      signed output
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getAsString()
      Return the internal message, either encrypted or decrypted.
      java.lang.String getAsString​(java.lang.String enc)
      Return the internal message, either encrypted or decrypted.
      byte[] getBytes()
      Return the internal message, either encrypted or decrypted.
      int getType()
      Return the type of message this is, encrypted, plain, signed.
      boolean isEncrypted()
      isEncrypted.
      boolean isPlain()
      isPlain.
      boolean isSigned()
      isSigned.
    • Method Detail

      • getAsString

        java.lang.String getAsString()
                              throws AdaptrisSecurityException
        Return the internal message, either encrypted or decrypted.

        This will return a String (using the platform default encoding) in the appropriate format, ready for writing to an OutputStream or further processing

        Returns:
        a string containing required output
        Throws:
        AdaptrisSecurityException - for any error
      • getAsString

        java.lang.String getAsString​(java.lang.String enc)
                              throws AdaptrisSecurityException,
                                     java.io.UnsupportedEncodingException
        Return the internal message, either encrypted or decrypted.

        This will return a String (using the specified encoding) in the appropriate format, ready for writing to an OutputStream or further processing

        Parameters:
        enc - the encoding
        Returns:
        a string containing required output
        Throws:
        AdaptrisSecurityException - wrapping any other underlying exception
        java.io.UnsupportedEncodingException - if the encoding type is not supported.
      • getBytes

        byte[] getBytes()
                 throws AdaptrisSecurityException
        Return the internal message, either encrypted or decrypted.

        This returns the raw bytes in the appropriate format, ready for writing to an OutputStream or further processing

        Returns:
        a byte array containing the required output
        Throws:
        AdaptrisSecurityException - for any error
      • getType

        int getType()
        Return the type of message this is, encrypted, plain, signed.
        Returns:
        an integer representing the type.
      • isEncrypted

        boolean isEncrypted()
        isEncrypted.
        Returns:
        true if the output is encrypted
      • isPlain

        boolean isPlain()
        isPlain.
        Returns:
        true if the output is plain
      • isSigned

        boolean isSigned()
        isSigned.
        Returns:
        true if the output is signed