YazanSh
YazanSh
CC#
Created by YazanSh on 5/31/2023 in #help
❔ Validate CADESignature
//Extracting the Data enveloped inside signature String extractedData = mapper .convertValue(new String((byte[]) cAdESSignature.getCmsSignedData().getSignedContent().getContent(), StandardCharsets.UTF_8), String.class); //Is Input Data matching with the data retrieved from Signature? // If yes, then first criteria is Valid if (inputData.equalsIgnoreCase(extractedData)) { //Verify the Certificase of Signature CMSSignedData signedData = cAdESSignature.getCmsSignedData(); Store<X509CertificateHolder> store = signedData.getCertificates(); SignerInformationStore signers = signedData.getSignerInfos(); Collection<SignerInformation> c = signers.getSigners(); for (SignerInformation signer : c) { Collection certCollection = store.getMatches(signer.getSID()); Iterator certIt = certCollection.iterator(); X509CertificateHolder certHolder = (X509CertificateHolder) certIt.next(); X509Certificate certFromSignedData; certFromSignedData = new JcaX509CertificateConverter().setProvider("BC").getCertificate(certHolder); if (signer .verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(certFromSignedData))) { //Signature is verified (second criteria met) LOG.info("Signature verified"); validated = true; } else { LOG.info("Signature verification failed"); } } } return validated; //Return the result of Verification }
4 replies
CC#
Created by YazanSh on 5/31/2023 in #help
❔ Validate CADESignature
/** * This method Takes an Input String and the CAdES signature on that String. It * then Verifies two things - * 1. If the Signature corresponds to this Input String * 2. If the certificate inside signature is valid * <p> * This method returns a boolean true/false, after validating both criteria * stated above. * * @param inputSignature CAdES signarure data on the input data * @param inputData Actual input data (String)/ SHA256 Hash of the encoded payload * @return Boolean */ public boolean validateCADESignature(String inputSignature, String inputData) throws CMSException, CertificateException, OperatorCreationException { Boolean validated = false; CAdESSignature cAdESSignature; //Base64 decode of input signature cAdESSignature = new CAdESSignature(Base64.getDecoder().decode(inputSignature)); ObjectMapper mapper = new ObjectMapper(); mapper.findAndRegisterModules();
4 replies
CC#
Created by YazanSh on 3/22/2023 in #help
❔ Npgsql with EF Core - column "status" is of type status_enum but expression is of type integer
the project is still being built from scratch
9 replies
CC#
Created by YazanSh on 3/22/2023 in #help
❔ Npgsql with EF Core - column "status" is of type status_enum but expression is of type integer
wasn't my choice 😦 My manager asked me to because DB was already built and there are still many changes on the tables
9 replies
CC#
Created by YazanSh on 3/22/2023 in #help
❔ Npgsql with EF Core - column "status" is of type status_enum but expression is of type integer
9 replies
CC#
Created by YazanSh on 3/22/2023 in #help
❔ Npgsql with EF Core - column "status" is of type status_enum but expression is of type integer
9 replies