Monday, 15 March 2010

xml - Java WebService call with authentication -


I need to have been working on a webservice client authentication and XML Signature I have read many articles but it seems That looks a different to me.

I need to send a request containing a tag with some certificate details. I service provider some files (certificate.crt, certificate.p12, certificate.pem)

I managed to engage CRT file request using follString ProviderName =

  get the system .getProperty ( "jsr105Provider", "org.jcp.xml.dsig.internal.dom.XMLDSigRI"); XMLSignatureFactory FAC = XMLSignatureFactory.getInstance ( "Dome" (provider) Class.forName (ProviderName) .newInstance ()); Reference ref = fac.newReference ( "", fac.newDigestMethod (DigestMethod.SHA1, tap), Collections.singletonList (FAC .newTransform (Transform.ENVELOPED, (XMLStructure) NULL)), null, null); // SignedInfo SignedInfo si = Create fac.newSignedInfo (fac.newCanonicalizationMethod (CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS, (C14NMethodParameterSpec) TAP), fac.newSignatureMethod (SignatureMethod.RSA_SHA1, tap), Collections.singletonList (reference)); KeyPair Generator kpg = KeyPairGenerator.getInstance ("RSA"); Kpg.initialize (512); Kipier KP = kpg.generateKeyPair (); KeyInfoFactory kif = fac.getKeyInfoFactory (); KEYWELL KV = kif.newKeyValue (kp.getPublic ()); CERTIFICATE Pacific CF = Certificate Fattery Get Instances ("X.509"); Certificate Certificate = cf.generate certificate (new FileInputStream (new file ("certificate.crt"))); X509 data x50 9d = kif.Navx509 data (collection, singleton list); KeyInfo ki = kif.newKeyInfo (Arrays.asList (x50 9D, KV)); Document doc = (document) result.getNode (); DOMSignContext DSC = New DOMSignContext (kp.getPrivate (), doc.getDocumentElement ()); XML signature sign = FAC. NAVxML signature (SI, K); Signature.sign (dsc);   

But the RSA key is generated and each call is different. This is obvious because I am using KeyPair Generator. Is it possible to import my private key from P12 file instead?

When I run this app on the badge, do I need to configure it in some way to enable HTTPS calls to serve?

You can use

itemprop = "text" > KeyStore ks = KeyStore .getInstance ("PKCS12"); FileInputStream ksin = New FileInputStream ("myfile.p12"); Ks.load (ksin, "password"); GetKey ("keyalis", "password");

No comments:

Post a Comment