/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.dsp.testcases;

import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;
import java.security.cert.CertificateException;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.dicomparserserializers.DicomParser;
import cdac.medinfo.sdk.dcm30_04.enums.EnumLoggingLevel;
import cdac.medinfo.sdk.dcm30_04.exceptions.ParseException;
import cdac.medinfo.sdk.dcm30_04.services.dsp.DSPVerifier;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;

public class Compartibility_with_NET
{
	public static final String DIGITAL_SIGNATURE_UUID = "e9e5ce1c-8001-42cb-93d7-9e74210f0926";
	
	public static void main(String[] args) throws ParseException, IOException, InvalidKeyException, NoSuchAlgorithmException, CertificateException, SignatureException 
	{

        
        DicomConfig.createInstance().enableLogging(EnumLoggingLevel.INFO);

//        // Digital Signature UID and Secret Key Collection should be shared between sender and receiver in order
//        // to prevent man in the middle attacks and verify data integrity.             
//        IPairedCollection<String, SecretKey > objDSUIDSecrectKeyCollection = new PairedCollection<String, SecretKey>();

        DicomParser objDicomParser = new DicomParser();
        // Parse dicom file generated by C# Digital Signature Signer.
        IDataSet objDataSet = objDicomParser.parseAsPart10File("D:\\dcmbAfteraddingDSPC#.dcm", true);        
  
 
//    	byte[] skk1 = SECRET_KEY.getBytes();
//		SecretKey objSpec = new SecretKeySpec(skk1,"SECRET_KEY_ALGO");
//
//        // initialize paired collection with UID and Secret Key.
//        objDSUIDSecrectKeyCollection.put(DIGITAL_SIGNATURE_UUID, objSpec);

        // Create instance of Digital Signature Verifier
        DSPVerifier objVerifier = new DSPVerifier();

        // Verify All the Digital Sigantures present in DataSet
        boolean verified = objVerifier.VerifyDigitalSignatures(objDataSet);
 
        System.out.println("DataSet verified : " + verified);
	}

}

