The conversion between signature types can be performed by using the class BaseSignedData
. Firstly, the list of the signers are accessed by the method BaseSignedData.getSignerList()
from the signed document. Then the signer to be converted is found in the list and the method convert()
of the signer is called.
The sample code below converts a BES signature to EST:
byte[] inputBES = AsnIO.dosyadanOKU(BES_SIGNATURE_FILE); BaseSignedData sd = new BaseSignedData(inputBES); HashMap<String, Object> params = new HashMap<String, Object>(); //necessary for getting signaturetimestamp params.put(EParameters.P_TSS_INFO, getTSSettings()); ValidationPolicy policy= PolicyReader.readValidationPolicy( New FileInputStream(POLICY_FILE)); //necessary for validating signer certificate according to time of //signaturetimestamp params.put(EParameters.P_CERT_VALIDATION_POLICY, policy); sd.getSignerList().get(0).convert(ESignatureType.TYPE_EST, params); AsnIO.dosyayaz(sd.getEncoded(),CONVERTED_TO_EST_FILE);
byte[] inputBES = AsnIO.dosyadanOKU(BES_SIGNATURE_FILE); BaseSignedData sd = new BaseSignedData(inputBES); Dictionary<String, Object> params_ = new Dictionary<String, Object>(); //necessary for getting signaturetimestamp params_[EParameters.P_TSS_INFO] = getTSSettings(); ValidationPolicy policy = PolicyReader.readValidationPolicy(new FileStream(POLICY_FILE, FileMode.Open, FileAccess.Read)); //necessary for validating signer certificate according to time of //signaturetimestamp params_[EParameters.P_CERT_VALIDATION_POLICY] = policy; sd.getSignerList()[0].convert(ESignatureType.TYPE_EST, params_); AsnIO.dosyayaz(sd.getEncoded(), CONVERTED_TO_EST_FILE);