Class BasePayloadParser

    • Field Detail

      • config

        protected java.util.Properties config
      • csMessageObjectFactory

        protected ObjectFactory csMessageObjectFactory
      • payloadVersion

        protected java.lang.String payloadVersion
    • Constructor Detail

      • BasePayloadParser

        public BasePayloadParser()
    • Method Detail

      • parseMessage

        public CSMessage parseMessage​(byte[] messageData)
                               throws MessageContentException,
                                      MessageProcessingException
        Method to parse a message into a CSMessage and verify that it fulfills the registred schemas.

        This method will parse all registered payloads and not only sys config payload messages.

        This method always validates and authorizes the signing certificate.

        Parameters:
        messageData - the data to parse into a CSMessage
        Returns:
        a parsed CS Message object.
        Throws:
        MessageContentException - if input data contained invalid format.
        MessageProcessingException - if internal problems occurred processing the cs message.
      • parseMessage

        public CSMessage parseMessage​(byte[] messageData,
                                      boolean performValidation)
                               throws MessageContentException,
                                      MessageProcessingException
        Method to parse a message into a CSMessage and verify that it fulfills the registred schemas.

        This method will parse all registered payloads and not only sys config payload messages.

        Parameters:
        messageData - the data to parse into a CSMessage
        performValidation - true if the message security provider should perform validate that the signing certificate is valid and authorized for related organisation. Otherwise must validation be performed manually after the message is parsed
        Returns:
        a parsed CS Message object.
        Throws:
        MessageContentException - if input data contained invalid format.
        MessageProcessingException - if internal problems occurred processing the cs message.
      • parseMessage

        public CSMessage parseMessage​(byte[] messageData,
                                      boolean performValidation,
                                      boolean requireSignature)
                               throws MessageContentException,
                                      MessageProcessingException
        Method to parse a message into a CSMessage and verify that it fulfills the registred schemas.
        Parameters:
        messageData - the data to parse into a CSMessage
        performValidation - true if the message security provider should perform validate that the signing certificate is valid and authorized for related organisation. Otherwise must validation be performed manually after the message is parsed.
        requireSignature - if signature should be required.
        Returns:
        a parsed CS Message object.
        Throws:
        MessageContentException - if input data contained invalid format.
        MessageProcessingException - if internal problems occurred processing the cs message.
      • getPayload

        public java.lang.Object getPayload​(CSMessage csMessage)
                                    throws MessageContentException
        Help method to get the payload of a message.
        Parameters:
        csMessage - containing a CS message payload.
        Returns:
        the payload object
        Throws:
        MessageContentException - if message content was illegal.
      • getAssertions

        public java.util.List<java.lang.Object> getAssertions​(IsApprovedResponseType isApprovedResponse)
        Help method to retrieve the assertions from an approved IsApprovedResponseType payload
        Parameters:
        isApprovedResponse - the payload if a IsApprovedResponse or GetApprovedResponse
        Returns:
        the list of assertions or null if no assertions could be found.
      • generateGetApprovalRequest

        public byte[] generateGetApprovalRequest​(java.lang.String requestId,
                                                 java.lang.String destinationId,
                                                 java.lang.String organisation,
                                                 byte[] requestMessage,
                                                 Credential originator,
                                                 java.util.List<java.lang.Object> assertions)
                                          throws MessageContentException,
                                                 MessageProcessingException
        Method generate a Get Approval Request,
        Parameters:
        requestId - id of request to send.
        destinationId - the destination Id to use.
        organisation - the related organisation (short name)
        requestMessage - the request message to get approval for.
        originator - the credential of the original requester, null if this is the origin of the request.
        assertions - a list of related authorization assertions, or null if no authorization assertions is available.
        Returns:
        a generated and signed (if configured) message.
        Throws:
        MessageContentException - if input data contained invalid format.
        MessageProcessingException - if internal problems occurred processing the cs message.
      • generateIsApprovedRequest

        public byte[] generateIsApprovedRequest​(java.lang.String requestId,
                                                java.lang.String destinationId,
                                                java.lang.String organisation,
                                                java.lang.String approvalId,
                                                Credential originator,
                                                java.util.List<java.lang.Object> assertions)
                                         throws MessageContentException,
                                                MessageProcessingException
        Method generate a Is Approved Request,
        Parameters:
        requestId - id of request to send.
        destinationId - the destination Id to use.
        organisation - the related organisation (short name)
        approvalId - the approval id to check.
        originator - the credential of the original requester, null if this is the origin of the request.
        assertions - a list of related authorization assertions, or null if no authorization assertions is available.
        Returns:
        a generated and signed (if configured) message.
        Throws:
        MessageContentException - if input data contained invalid format.
        MessageProcessingException - if internal problems occurred processing the cs message.
      • getSupportedVersions

        protected abstract java.lang.String[] getSupportedVersions()
        Returns:
        an array of version numbers of payload that is supported by this parser.
      • getDefaultPayloadVersion

        protected abstract java.lang.String getDefaultPayloadVersion()
        Returns:
        returns the payload version used by default when generating request messages.
      • isPayloadVersionSupported

        protected void isPayloadVersionSupported​(java.lang.String payloadVersion)
                                          throws MessageContentException
        Help method to determine if a payload version is supported by this parser.
        Parameters:
        payloadVersion - the payload parser to check.
        Throws:
        MessageContentException - if unsupported version was found.
      • getPayloadVersion

        public java.lang.String getPayloadVersion()
        Returns:
        Method to get the current payload version used when generating request messages. Response messages always use the same version as the request.
      • setPayloadVersion

        public void setPayloadVersion​(java.lang.String payloadVersion)
        Method that only should be used under special purposes when generating request message, normally should default payload version be used that is set automatically. Response messages always use the same version as the request.
        Parameters:
        payloadVersion - method to set the payload version to use instead of the default one.
      • getRelatedSchemas

        public java.lang.String[] getRelatedSchemas​(java.lang.String payloadVersion)
        Method that should return related schemas used during payload schema validation.
        Specified by:
        getRelatedSchemas in interface PayloadParser
        Parameters:
        payloadVersion - payload version.
        Returns:
        an array of related schemas if no related schemas exists is empty array returned, never null.