Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/************************************************************************
* *
* Certificate Service - Messages *
* *
* This software is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* License as published by the Free Software Foundation; either *
* version 3 of the License, or any later version. *
* *
* See terms of license at gnu.org. *
* *
*************************************************************************/
package org.certificateservices.messages.signrequest;
import org.certificateservices.messages.MessageContentException;
import org.certificateservices.messages.MessageProcessingException;
import org.certificateservices.messages.csmessages.BasePayloadParser;
import org.certificateservices.messages.csmessages.CSMessageResponseData;
import org.certificateservices.messages.csmessages.PayloadParser;
import org.certificateservices.messages.csmessages.jaxb.Attribute;
import org.certificateservices.messages.csmessages.jaxb.CSMessage;
import org.certificateservices.messages.csmessages.jaxb.Credential;
import org.certificateservices.messages.signrequest.jaxb.*;
import java.io.InputStream;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.util.List;
/**
* Payload Parser for generating SignRequest messages according to
* signrequest_schema2_0.xsd
*
* @author Philip Vendil 2019-10-03
*/
public class SignRequestPayloadParser extends BasePayloadParser {
public static String NAMESPACE = "http://certificateservices.org/xsd/signrequest2_0";
public static final String SIGNREQUEST_PROTOCOL_XSD_SCHEMA_2_0_RESOURCE_LOCATION = "/signrequest_schema2_0.xsd";
public static final String SIGNREQUEST_PROTOCOL_XSD_SCHEMA_2_1_RESOURCE_LOCATION = "/signrequest_schema2_1.xsd";
private ObjectFactory of = new ObjectFactory();
private static final String[] SUPPORTED_SIGNREQUEST_PROTOCOL_VERSIONS = {"2.0", "2.1"};
private static final String DEFAULT_SIGNREQUEST_PROTOCOL_VERSION = "2.1";
/**
* @see PayloadParser#getJAXBPackage()
*/
public String getJAXBPackage() {
return "org.certificateservices.messages.signrequest.jaxb";
}
/**
* @see PayloadParser#getNameSpace()
*/
public String getNameSpace() {
return NAMESPACE;
}
/**
* @see PayloadParser#getSchemaAsInputStream(String)
*/
public InputStream getSchemaAsInputStream(String payLoadVersion)
throws MessageContentException, MessageProcessingException {
if(payLoadVersion.equals("2.0")){
return getClass().getResourceAsStream(SIGNREQUEST_PROTOCOL_XSD_SCHEMA_2_0_RESOURCE_LOCATION);
}
if(payLoadVersion.equals("2.1")){
return getClass().getResourceAsStream(SIGNREQUEST_PROTOCOL_XSD_SCHEMA_2_1_RESOURCE_LOCATION);
}
throw new MessageContentException("Error unsupported CS Sign Request Protocol Payload version: " + payLoadVersion);
}
/**
* @see BasePayloadParser#getSupportedVersions()
*/
@Override
protected String[] getSupportedVersions() {
return SUPPORTED_SIGNREQUEST_PROTOCOL_VERSIONS;
}
/**
* @see BasePayloadParser#getDefaultPayloadVersion()
*/
@Override
protected String getDefaultPayloadVersion() {
return DEFAULT_SIGNREQUEST_PROTOCOL_VERSION;
}
/**
* Method to create a SignRequest to request signature of the list of SignRequestTasks
*
* @param requestId the id of the request
* @param destinationId the destinationId used in the CSMessage.
* @param organisation the related organisation
* @param signRequestTasks Contains a list between 1 and 100 SignRequest tasks.
* @param originator the original requester of a message, null if not applicable
* @param assertions a list of related authorization assertions, or null if no authorization assertions is available.
* @return generated and signed CSMessage in byte[] format.
* @throws MessageContentException if CS message contained invalid data not conforming to the standard.
* @throws MessageProcessingException if internal state occurred when processing the CSMessage
*/
public byte[] genSignRequest(String requestId, String destinationId, String organisation, List signRequestTasks, Credential originator, List