Class BasePayloadParser
- java.lang.Object
-
- org.certificateservices.messages.csmessages.BasePayloadParser
-
- All Implemented Interfaces:
PayloadParser
- Direct Known Subclasses:
AssertionPayloadParser,AuthorizationPayloadParser,AutoEnrollPayloadParser,CredManagementPayloadParser,CSAgentProtocolPayloadParser,CSExportProtocolPayloadParser,EncryptedCSMessagePayloadParser,KeystoreMgmtPayloadParser,SignRequestPayloadParser,SysConfigPayloadParser,V2XBackendPayloadParser,V2XPayloadParser
public abstract class BasePayloadParser extends java.lang.Object implements PayloadParser
Base implementation of a PayLoadParser that other implementations might inherit.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Propertiesconfigprotected ObjectFactorycsMessageObjectFactoryprotected CSMessageParsercustomCSMessageParserprotected java.lang.StringpayloadVersionprotected MessageSecurityProvidersecProv
-
Constructor Summary
Constructors Constructor Description BasePayloadParser()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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)Method generate a Get Approval Request,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)Method generate a Is Approved Request,java.util.List<java.lang.Object>getAssertions(IsApprovedResponseType isApprovedResponse)Help method to retrieve the assertions from an approved IsApprovedResponseType payloadprotected CSMessageParsergetCSMessageParser()protected abstract java.lang.StringgetDefaultPayloadVersion()java.lang.ObjectgetPayload(CSMessage csMessage)Help method to get the payload of a message.java.lang.StringgetPayloadVersion()java.lang.String[]getRelatedSchemas(java.lang.String payloadVersion)Method that should return related schemas used during payload schema validation.RequestStatusgetResponseStatus(CSMessage csMessage)Help method to get the request status from a CS response message.protected abstract java.lang.String[]getSupportedVersions()voidinit(java.util.Properties config, MessageSecurityProvider secProv)Default initializer setting the parser and config properties.voidinit(java.util.Properties config, MessageSecurityProvider secProv, CSMessageParser customCSMessageParser)Alternativ initializer setting the parser and config properties and custom CSMessageParser.protected voidisPayloadVersionSupported(java.lang.String payloadVersion)Help method to determine if a payload version is supported by this parser.CSMessageparseMessage(byte[] messageData)Method to parse a message into a CSMessage and verify that it fulfills the registred schemas.CSMessageparseMessage(byte[] messageData, boolean performValidation)Method to parse a message into a CSMessage and verify that it fulfills the registred schemas.CSMessageparseMessage(byte[] messageData, boolean performValidation, boolean requireSignature)Method to parse a message into a CSMessage and verify that it fulfills the registred schemas.voidsetPayloadVersion(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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.certificateservices.messages.csmessages.PayloadParser
getJAXBPackage, getNameSpace, getSchemaAsInputStream
-
-
-
-
Field Detail
-
config
protected java.util.Properties config
-
secProv
protected MessageSecurityProvider secProv
-
customCSMessageParser
protected CSMessageParser customCSMessageParser
-
csMessageObjectFactory
protected ObjectFactory csMessageObjectFactory
-
payloadVersion
protected java.lang.String payloadVersion
-
-
Method Detail
-
init
public void init(java.util.Properties config, MessageSecurityProvider secProv) throws MessageProcessingExceptionDefault initializer setting the parser and config properties.- Specified by:
initin interfacePayloadParser- Parameters:
config- the configuration of the parser.secProv- the related message security provider.- Throws:
MessageProcessingException- if configuration contained bad configuration of security provider.- See Also:
PayloadParser.init(java.util.Properties, MessageSecurityProvider)
-
init
public void init(java.util.Properties config, MessageSecurityProvider secProv, CSMessageParser customCSMessageParser) throws MessageProcessingExceptionAlternativ initializer setting the parser and config properties and custom CSMessageParser. Usen mainly during testing.
-
getCSMessageParser
protected CSMessageParser getCSMessageParser() throws MessageProcessingException
- Throws:
MessageProcessingException
-
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 CSMessageperformValidation- 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 CSMessageperformValidation- 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.
-
getResponseStatus
public RequestStatus getResponseStatus(CSMessage csMessage) throws MessageContentException
Help method to get the request status from a CS response message.- Parameters:
csMessage- containing a CS response message.- Returns:
- the request status.
- Throws:
MessageContentException- if message content was illegal.
-
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, MessageProcessingExceptionMethod 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, MessageProcessingExceptionMethod 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 MessageContentExceptionHelp 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:
getRelatedSchemasin interfacePayloadParser- Parameters:
payloadVersion- payload version.- Returns:
- an array of related schemas if no related schemas exists is empty array returned, never null.
-
-