java - How to run CoSign Signature SOAP API in IBM Lotus Notes? -
java - How to run CoSign Signature SOAP API in IBM Lotus Notes? -
session session = getsession(); agentcontext agentcontext = session.getagentcontext(); // custom values string filepath = "c://20/tosign.pdf"; // pdf file sign string filemimetype = "application/pdf"; // file mime type string username = "xyz@gmail.com"; // cosign business relationship username,not these credentials, have entered cosign username , password here. string password = "password"; // cosign business relationship password string domain = ""; // cosign business relationship domain int sigpagenum = 1; // create signature on first page int sigx = 145; // signature field x location int sigy = 125; // signature field y location int sigwidth = 160; // signature field width int sigheight = 45; // signature field height string timeformat = "hh:mm:ss"; // display format of time string dateformat = "dd/mm/yyyy"; // display format of date long appearancemask = 11; string signaturetype = "http://arx.com/sapiws/dss/1.0/signature-field-create-sign"; // actual operation of sign request function string wsdlurl = "https://prime.cosigntrial.com:8080/sapiws/dss.asmx?wsdl"; // url wsdl file // read file contents bufferedreader br = new bufferedreader(new filereader(new file(filepath))); string line; string filebuffercontent=""; while ((line=br.readline())!=null){ filebuffercontent=filebuffercontent+line ; } byte[] filebuffer = filebuffercontent.getbytes(); // set file contents + mime type (the soap library automatically base64 encodes data) documenttype document = new documenttype(); base64data base64data = new base64data(); base64data.setvalue(filebuffer); base64data.setmimetype(filemimetype); document.setbase64data(base64data); // set user credentials. in case of active directory, domain name should defined in namequalifier attribute claimedidentity claimedidentity = new claimedidentity(); nameidentifiertype nameidentifier = new nameidentifiertype(); nameidentifier.setvalue(username); nameidentifier.setnamequalifier(domain); cosignauthdatatype cosignauthdata = new cosignauthdatatype(); cosignauthdata.setlogonpassword(password); claimedidentity.setname(nameidentifier); claimedidentity.setsupportinginfo(cosignauthdata); system.out.println("credentials set"); // define signature field settings sapisigfieldsettingstype sigfieldsettings = new sapisigfieldsettingstype(); sigfieldsettings.setinvisible(false); sigfieldsettings.setx(sigx); sigfieldsettings.sety(sigy); sigfieldsettings.setwidth(sigwidth); sigfieldsettings.setheight(sigheight); sigfieldsettings.setpage(sigpagenum); sigfieldsettings.setappearancemask(appearancemask); timedateformattype timedateformat = new timedateformattype(); timedateformat.settimeformat(timeformat); timedateformat.setdateformat(dateformat); timedateformat.setexttimeformat(extendedtimeformatenum.gmt); sigfieldsettings.settimeformat(timedateformat); // build finish request object signrequest signrequest = new signrequest(); requestbasetype.inputdocuments inputdocuments = new requestbasetype.inputdocuments(); inputdocuments.getdocumentortransformeddataordocumenthash().add(document); requestbasetype.optionalinputs optionalinputs = new requestbasetype.optionalinputs(); optionalinputs.setsignaturetype(signaturetype); optionalinputs.setclaimedidentity(claimedidentity); optionalinputs.setsapisigfieldsettings(sigfieldsettings); optionalinputs.setreturnpdftailonly(true); signrequest.setoptionalinputs(optionalinputs); signrequest.setinputdocuments(inputdocuments); // initiate service client // dss client = new dss(new url(wsdlurl), new qname("http://arx.com/sapiws/dss/1.0/", "dss")); // send request dsssignresult response = client.getdsssoap().dsssign(signrequest); // check response output if ("urn:oasis:names:tc:dss:1.0:resultmajor:success".equals(response.getresult().getresultmajor())) { // on success- append signature object source pdf document (the soap library automatically decodes base64 encoded output) byte[] signatureobjectbuffer = response.getsignatureobject().getbase64signature().getvalue(); //files.write(paths.get(filepath), signatureobjectbuffer, standardopenoption.append); bufferedwriter bw = new bufferedwriter(new filewriter( new file(filepath))); string signatureobjectbufferstring = signatureobjectbuffer.tostring(); bw.write(signatureobjectbufferstring); bw.close(); } else { // on failure- raise exception result error message throw new exception(response.getresult().getresultmessage().getvalue()); }
using code http://developer.arx.com/quick-start/sapi-web-services/#t-helloworld .i have written code compatible java 1.6, getting errors "accesscontrolexception: access denied", missing something?
note username apis email, not username utilize developers portal.
the service point url shown on getting started tab of api overview
service point url trial/developer system
java soap digital-signature cosign-api
Comments
Post a Comment