Xml encryption

i have a query for u folks
i have a requirment such that questions and answers will be in a xml file and a students takes a exam from that xml file.
my file is xml encoded file.
now student can see the xml file in xml editor.
how can i encrypt that file and decrypt it.
plz give me suggestions

Note: This thread was originally posted in the Swing forum, but moved to this forum for closer topic alignment.

Similar Messages

  • XML encrypt/decrypt

    Hi All,
    I'm a newbie, and want to know if the output XML file (UUT test report) from TestStand can be encrypted without using any third party software?
    Actually I want to know if TestStand itself supports encryption/decryption of XML?
    And if TestStand doesn't supports, is there any work around for this requirement?
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

    Hello,
    Encryption in XML file is required to encrypt the various configuration parameter values so that a user cannot view / edited it external outside the to the test application. By making use of Private / Public keys data would be encrypted.This key will be exchanged between TestStand & XML to decrypt & display it to user.
    See additional details on XML encryption on : http://www.w3.org/TR/xmlenc-core/
    We can encrypt the step result using LabVIEW encryption example --> http://zone.ni.com/devzone/cda/epd/p/id/3473
    My question now is --> How to include the customize XML report header to include the encryption standard?
    I saw many articles to make use of "ModifyReportHeader". Can someone furnish me with a working example of modifying the header through TestStand? I tried ... but in Vain..

  • Problem in XML Encryption

    Hello Experts,
    I am trying to invoke the other platform encrypted service.
    I imported the public key given by the other platform so that i would be able to encrypt the request.
    In the receiver agreement I encrypted the request and decrypted the response using my pvt key.
    Using the soapui tool i tested and it failed. It shows the following error.
    com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.engine.interfaces.messaging.api.exception.MessagingException: XIAdapter:ADAPTER.SOAP_EXCEPTION:soap fault: weblogic.xml.crypto.encrypt.api.XMLEncryptionException: Unable to resolve encryption key for weblogic.xml.crypto.encrypt.api.EncryptedType{keyInfo=null, cipherData=CipherValue: u0MSUd43Onj/fTW02gFSfV/IbOEkvQ1teKVVxJQd1e8pXS+ZFq04rnx3YIx4fKsEk5pogEF8HHb546plmZFZCca3Wx2mTuPctRK1M9k8uioEqUBQdJHG3f3aheXyYZnhw2vkEv0lHNjbSn7El8NMdzbWB7brpZBU
    How shall i solve it.?
    Regards,
    Kevin
    Edited by: Kevin Mascarenhas on Aug 18, 2008 8:19 AM

    Hi,
    check out this weblog
    Setup HTTPS (SSL) for the Sneak Preview SAP NetWeaver 04 ABAP Edition on Windows
    go through these links,hope these ll help you to solve your problem
    http://www.sap-si.com/files/Security_final_en.pdf
    /people/gregor.wolf3/blog
    Regards,
    Surya

  • More about XML encryption

    Hi, all.
    I'm generating a ciphered XML file (using apache.xml libraries). I've discovered that if I encrypt and decrypt an in-memory XML document, everything works fine.
    However, if I save the ciphered XML document and then I load it and try to decipher, I get the following exception:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
            at java.util.Vector.elementAt(Vector.java:435)
            at org.apache.xerces.dom.DeepNodeListImpl.item(Unknown Source)
            at org.apache.xml.security.encryption.XMLCipher$Factory.newEncryptedKey(Unknown Source)
            at org.apache.xml.security.encryption.XMLCipher.loadEncryptedKey(Unknown Source)
            at org.apache.xml.security.encryption.XMLCipher.loadEncryptedKey(Unknown Source)
            at uoc.cripto.fases.fase21.decipherRSA(phase21.java:82)
            at uoc.cripto.fases.fase21.main(phase21.java:100)I suppose that the problem is in the way I'm serializing to a file the ciphered XML document, or maybe the method to deserialize it. I'm using this code to serialize to a file:
        public static void writeFile(Document doc, String fileName) throws Exception {
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer();
            Source input = new DOMSource(doc);
            FileWriter writer = new FileWriter(fileName);
            Result output = new StreamResult(writer);
            transformer.transform(input, output);
        }And for deserializing:
        public static Document readFile (String fileName) throws Exception {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            File file = new File(fileName);
            Document doc = builder.parse(file);
            return doc;
        }Can anyone help me? I'm seriously lost, and I need to solve this problem in order to pass a subject...
    Thanks.

    Hi, all.
    I've found the answer. It's enough to insert this line in the "readFile" function:
            factory.setNamespaceAware(true);The exception seems to be thrown because the system can't find certain elements if the property NamespaceAware is false, and this is the default value.
    So, that's all, folks!
    Thank you for your patience,

  • Error while calling Encryption Policy in OWSM

    Hi,
    I have a simple BPEL process and which is registered in OWSM with Encryption/decryption policies using jks
    I get below error in gatway logs.Please let me know any thoughts
    2009-06-22 04:57:32,503 FINE [AJPRequestHandler-HTTPThreadGroup-8] CSWComponent - Executing policy step. Policy='SID0003053', Step Name='XML Encrypt', Step Class='com.cfluent.policysteps.security.wssecurity.EncryptStep'
    2009-06-22 04:57:32,503 FINER [AJPRequestHandler-HTTPThreadGroup-8] wssecurity.SecurityBaseStep - Step XML Encrypt called
    2009-06-22 04:57:32,507 FINEST [AJPRequestHandler-HTTPThreadGroup-8] wssecurity.EncryptStep - Encrypting Soap XPATH
    2009-06-22 04:57:32,515 FINEST [AJPRequestHandler-HTTPThreadGroup-8] wssecurity.SecurityBaseStep - XPath= /descendant-or-self::node()/child::*[(attribute::encrypted = "true")]
    2009-06-22 04:57:32,516 WARNING [AJPRequestHandler-HTTPThreadGroup-8] wssecurity.SecurityBaseStep - Failure while applying XML Security
    java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1768)
    at com.cfluent.policysteps.security.wssecurity.SecurityBaseStep.setLocationsForXPath(SecurityBaseStep.java:518)
    at com.cfluent.policysteps.security.wssecurity.EncryptStep.setEncryptLocationsForXPath(EncryptStep.java:225)
    at com.cfluent.policysteps.security.wssecurity.EncryptStep.getEncryptLocations(EncryptStep.java:202)
    at com.cfluent.policysteps.security.wssecurity.EncryptStep.performXmlSecurity(EncryptStep.java:177)
    at com.cfluent.policysteps.security.wssecurity.SecurityBaseStep.execute(SecurityBaseStep.java:256)
    at com.cfluent.pipelineengine.container.DefaultPipeline.executeStep(DefaultPipeline.java:124)
    at com.cfluent.pipelineengine.container.DefaultPipeline.execute(DefaultPipeline.java:97)
    at com.cfluent.pipelineengine.container.DefaultPolicy$DeferredPipeline.execute(DefaultPolicy.java:63)
    at com.cfluent.pipelineengine.container.DefaultPolicy$DeferredPipeline.access$300(DefaultPolicy.java:18)
    at com.cfluent.pipelineengine.container.DefaultPolicy.execute(DefaultPolicy.java:126)
    at com.cfluent.pipelineengine.container.PipelineContainer.execute(PipelineContainer.java:114)
    at com.cfluent.agent.Agent.intercept(Agent.java:123)
    at com.cfluent.agent.AgentRuntime.intercept(AgentRuntime.java:252)
    at com.cfluent.pipelineengine.util.PolicyInvoker.execute(PolicyInvoker.java:30)
    at com.cfluent.pipelineengine.util.InvokerChain.execute(InvokerChain.java:30)
    at com.cfluent.gateway.Invoker.execute(Invoker.java:148)
    at com.cfluent.gateway.listener.ProtocolListener$ListenerTask.run(ProtocolListener.java:272)
    at com.cfluent.gateway.listener.ProtocolListener.invoke(ProtocolListener.java:110)
    at com.cfluent.gateway.listener.GatewayRuntime.invoke(GatewayRuntime.java:32)
    at com.cfluent.gateway.listener.http.HttpListener.invoke(HttpListener.java:30)
    at com.cfluent.gateway.listener.http.ServicesServlet.handlePost(ServicesServlet.java:57)
    at com.cfluent.common.servlet.BaseServlet.doPost(BaseServlet.java:264)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
    at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
    at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:302)
    at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:190)
    at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    at java.lang.Thread.run(Thread.java:595)
    2009-06-22 04:57:32,519 FINE [AJPRequestHandler-HTTPThreadGroup-8] CSWComponent - Step execution failed: Fault Code=[http://schemas.oblix.com/ws/2003/08/Faults/GenericFault] Fault String=[WS-Security process failure:String index out of range: -1] Policy=[SID0003053] Pipeline=[Request] Step Name=[XML Encrypt] Step Class=[com.cfluent.policysteps.security.wssecurity.EncryptStep]
    Thanks
    Vinay

    you missed one question of mine  <b>Do you create the PDF after creating the GUID ?</b>
    try giving a fixed URL just to test.
    Aman

  • How to get input XML

    Hello. Prompt please... For a call wsdl I use webServiceProxy. Before a call of a method from wsdl, I need to code entrance xml, as it to receive in the form of xml to transform and then to send

    May be I wrote in wrong thread....Until we know what your question is about it is impossible to say.
    I need to get an xml, which shape by webServiceProxy for send to webService, because i need to secure it.Please try again.
    P.S Sorry for my bad EnglishThanks but that's the problem. You haven't expressed your problem clearly. So it can't be answered, whether in this thread or any other.
    At the moment I can't tell whether your problem is getting the XML, parsing the XML, constructing the XML, sending the XML, encrypting the XML, decrypting the XML, signing the XML, verifying the signature in the XML, ...

  • Web Sevices Manager encryption and  identyfication

    Hi,
    I installed Oracle Web Services Manager (coresv 4.0.3) with bundled AS on one machine . After registering one test service (from another AS) I wrote simple java client in JDeveloper, which requests service and print output on screen, and everything works fine - owsm get request, call service from another AS, get response, and finally send response to java client.But, problems start with XML Encrypt and XML Decrypt policy steps in owsm, i found that in either case error message was same: Step execution error. I should say that I use encryption key which is proven in another application, so it works fine. Have someone any idea?
    Second problem is when I set policy step: Active directory authenticate. This step is configured to work with localhost (which is domain controller), listening port 389 and baseDN: CN=Users,DC=ocean,DC=ba (this is correct baseDN, when I use ldp.exe to query Active Directory, this baseDN gives me all users in system). In my client, I wrote something like this:
    myPort.setUsername("Administrator");
    myPort.setPassword("*************");
    but owsm gives error message:
    Invalid username and password
    Interesting thing is that, when I set wrong port (e.g. 999,766, 901....) I still have same error message.
    Thanks, Almir

    Hi,
    I'd be happy to know how you succeded in installing owsm on AS?
    I've been trying and don't succeed...
    thanks
    deborah

  • Signed XML in SOAP Adapter

    Hello Experts,
    I have a scenario with receiver SOAP adapter, I have used the security profile in the channel and receiver agreement i have selected sign and all rudimentary requirements..
    But im unable to see the signed payload in the CC monitoring..it should be in the format
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" EncodingType="................</wsse:BinarySecurityToken>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <ds:SignedInfo>
    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
    <ds:Reference URI="#id-24819136">
    <ds:Transforms>
    <ds:Transform Algorithm=...........
    Im not able to see it in the SOAP adapter...have i missed something in the config...I have generated the cert in visual admin and given the correct values too in the channel and recv agreement.
    Can ne one elucidate on this please...
    How can i view the signed xml coming from the SOAP adapter?
    Regards,
    Farooq
    Edited by: Farooq Hussain on Nov 12, 2008 7:46 PM

    Hi  Farooq
    You have generated certificates? this will encrypt complete xml while sending. for that you need to set procedure as Encrypt this is what my understanding in this.
    XML Signature
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/55814003-0b01-0010-1ca2-c683a191ebfc
    Did you have checked with this
    Using Digital Signatures in XI
    it doesn't talk about generating the certificate and encrypting complete message but it actually encrypt complete message when you generate certificate.
    How XML Encryption can be done using web services security in SAP NetWeaver XI
    This also speaks similar. I am not able to get the link .. try search for "Ensure the Confidentiality of Your SOAP Message Content" to understand more on this
    Thanks
    Gaurav

  • Creating a signature and Encrypt the file

    Hi Experts,
        I have an requirement,  I need to create a module in which I need to pass four values (Namely signing key, signing algorithm, encyption key and encryption algorithm) through parameters as inputs.  Based on these parameters, I need to create the signature for the input xml file and I have to encrypted the file.  Please Guide me.  Give some useful links, documents or codes to how to do this.  Help me in this regard.
    Thanks in Advance,
    Venkatesh.K

    Hi,
    Digitally signing of messages is possible by using cryptographic toolkits.
    All required java programs are imported as archives into XI. Java mapping is written utilizing the imported java archives which actually performs the digital signature creation for the outgoing messages from XI and digital signature verification for the incoming messages to XI.
    refer
    SAP Network Blog: Using Digital Signatures in XI
    /people/sap.user72/blog/2005/06/16/using-digital-signatures-in-xi
    SAP Network Blog: How to use Digital Certificates for Signing & Encrypting Messages in XI
    /people/varadharajan.krishnasamy/blog/2007/05/11/how-to-use-digital-certificates-for-signing-encrypting-messages-in-xi
    SAP Network Blog: How XML Encryption can be done using web services security in SAP NetWeaver XI
    /people/aparna.chaganti2/blog/2007/01/23/how-xml-encryption-can-be-done-using-web-services-security-in-sap-netweaver-xi
    You may also use the SAP cryptographic toolkit available from SAP market place for signing encrypting. See i.e. http://help.sap.com/saphelp_nw04/helpdata/en/4f/65c3b32107964996a56e4165077e24/frameset.htm
    Decryption of Message after processing by File adapter
    https://www.sdn.sap.com/sdn/collaboration.sdn?contenttype=url&content=https%3A//forums.sdn.sap.com/thread.jspa%3FforumID%3D44%26threadID%3D37512
    Ensure the Confidentiality of Your SOAP Message Content: XML Encryption Using Web Services Security in SAP NetWeaver Exchange Infrastructure
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0650f56-7587-2910-7c99-e1b6ffbe4d50
    Digital Signatures in SAP Applications
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40f6fee6-9316-2a10-d2a9-954d4df7dd33
    Best Practices for Digital Signatures
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/55ba9790-0201-0010-aa98-ce8f51ea93cd
    Thanks
    Swarup
    Edited by: Swarup Sawant on Apr 4, 2008 2:02 PM

  • Mapping - encrypted file

    Hi all,
    I need to send an encrypted file through XI to R/3 back end. The problem is that I also need to do some mapping in XI. Does anyone know if that is possible with an encrypted file?
    Thanks!

    Hi
    reffer the below mentioned link . this would give you some idea about XML encryption .
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0650f56-7587-2910-7c99-e1b6ffbe4d50
    It also depends, how the external system is accessed. The file adapter and jms adapter do not care about the structure, so you can pass the data unchanged.
    For other adapter (for example SOAP), it might be useful to change the binaries into base64 code (like mail clients do). This weblog of Felix Reuben might give an idea about that:
    Copy a file with same filename using XI
    Regard's
    Chetan Ahuja

  • WS-Security - Single element encryption ?

    Hi Guys,
    The credit card data is sensitive and we have messages going through XI which has CVV code the 3 digit code and since XI logs this, we are planning to use single element encryption (XML encryption) in the web service security.
    Customer asked that we can disable the logging only for this particular field, which is not possible in XI and thats the reason we are thinking to go for single element encryption. we have configured soap adapters on both the sender and receiver side.
    any suggestions how to acheive this or any different ideas would be really appreciated
    Thanks,
    Srini

    Hi Srinivas,
    You can go for SOAP adapter for your requirement.
    To add......if u wantt to check out the details of SOAP adapter.......
    SOAP Adapter: SOAP Adapter converts the SOAP messages into SAP XI message format that is SOAP with header attachments. This in an area many needs to really concentrate as it is heart of the ESA literature going forward.
    Refer Testing XI exposed Web-Services:
    /people/siva.maranani/blog/2005/03/01/testing-xi-exposed-web-services
    and Invoking XI Webservices:
    /people/siva.maranani/blog/2005/09/03/invoke-webservices-using-sapxi
    RFC to WebService - A Complete Walkthrough - Part 1
    /people/shabarish.vijayakumar/blog/2006/03/23/rfc--xi--webservice--a-complete-walkthrough-part-1
    and RFC -> XI -> WebService - A Complete Walkthrough -Part 2.
    /people/shabarish.vijayakumar/blog/2006/03/28/rfc--xi--webservice--a-complete-walkthrough-part-2
    You can down load a sample SOAP Client tool from SAP SOAP Client Tool.
    https://www.sdn.sap.com/irj/sdn/downloads
    Please refer How to Set Up a Web Service-Related Scenario with SAP XI for delving more deep.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/befdeb90-0201-0010-059b-f222711d10c0
    Reward points if this helps
    Regards
    Vani.

  • OWSM: How to encrypt payload and SOAP header?

    Hi,
    Anybody know how I can encrypt the payload and the SOAP header via OWSM? I can only find references on how to do it using SSL. The reason for using OWSM/WS-Security was to move away from using transport based encryption (SSL).
    Regards Pete

    http://download.oracle.com/docs/cd/E10291_01/doc.1013/e10299/policy_steps.htm#sthref612
    if you look at the topic :XML Encrypt
    you will see you can encrypt every part of the xml
    Encrypted Content
    Part of the SOAP envelope to be encrypted. Valid values are: BODY, HEADERS, ENVELOPE, and XPATH. The default is BODY.

  • XML deserialize and decrypting encoding problem. Please help me

    This is my first topic here, so at first I'd like to say "Hi" everyone and apologise for my bad english ;)
    I have just finished my new application about signing/checking and encrypting/decrypting XML files. I use Apache XML Security packages to do this.
    Everything works fine, instead of one...
    I'm Polish and sometimes I have to encrypt or decrypt XML which includes polish letters like: '&#261;' , '&#281;', '&#322;' and some others... If I encrypt such file, it succeeds. The problem is when I try to decrypt such an encrypted file. I recieve an error like :
    "[Fatal Error] :2:7: An invalid XML character (Unicode: 0x19) was found in the element content o
    f the document.
    gov.mf.common.exceptions.SenderException: E_SENDER_DECRYPTION
    at gov.mf.common.xml.encryption.EncryptTool.decrypt(Unknown Source)
    at gov.mf.CERBER.TestCBR.main(Unknown Source)
    Caused by: org.apache.xml.security.encryption.XMLEncryptionException: An invalid XML character
    (Unicode: 0x19) was found in the element content of the document.
    Original Exception was org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x19)
    was found in the element content of the document.
    at org.apache.xml.security.encryption.XMLCipher$Serializer.deserialize(Unknown Source)
    at org.apache.xml.security.encryption.XMLCipher.decryptElement(Unknown Source)
    at org.apache.xml.security.encryption.XMLCipher.doFinal(Unknown Source)
    ... 2 more
    What's wrong? My XML document is UTF-8 encoded, with or without BOM. I wrote in in Notepad++ or any other editior which has UTF-8 encoding.
    I'm parsing my XML with DOM. There is an interesting line in an error above like: " at org.apache.xml.security.encryption.XMLCipher$Serializer.deserialize(Unknown Source)" , do you know that?
    Everything is fine when I try to encrypt/decrypt '�' or '&#324;', but things go wrong with '&#261;', '&#281;', '&#322;' and others... I also managed to encrypt and decrypt '&#322;' but unfortunately, after decryption '&#322;' turns into 'B'. It obviously an encoding problem, but how to fix it?
    I would be really thankfull if some of You guys would help me.
    Looking forward fo any answers.
    Matthew
    Message was edited by:
    matthew_pl

    Hi once again.
    I still don't havy any solution to my problem. I used Apache XML Security examples to encrypt/decrypt my XML document with Polish charaters but I also recieve the same error. What's wrong?
    Here is some code:
    ----- Parsing XML do Document ------
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         //Bardzo wazna linijka - bless TEK ;)
         factory.setNamespaceAware(true);
         DocumentBuilder builder;
         builder = factory.newDocumentBuilder();
         File f = new File(Const.FILE_IN_PATH + File.separator + Const.FILE_IN);     
         org.w3c.dom.Document doc = builder.parse(f);
    ---------- Encrypting & Decrypting XML document (whole class) -------------
    import java.io.*;
    import java.security.*;
    import javax.crypto.SecretKey;
    import javax.crypto.SecretKeyFactory;
    import javax.crypto.spec.DESedeKeySpec;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.apache.xml.security.keys.KeyInfo;
    import org.apache.xml.security.utils.EncryptionConstants;
    import org.apache.xml.security.encryption.XMLCipher;
    import org.apache.xml.security.encryption.EncryptedData;
    import org.apache.xml.security.encryption.EncryptedKey;
    public class EncryptTool
    private PublicKey publicKey;     
    private PrivateKey privateKey;
    static
    org.apache.xml.security.Init.init();
    public EncryptTool()
         publicKey = KeyStores.getCerberPublicKey();
         privateKey = KeyStores.getCerberPrivateKey();
    public Document encrypt(Document doc, String sufix)
    try
         byte[] passPhrase = "24 Bytes per DESede key!".getBytes("UTF-8");
         DESedeKeySpec keySpec = new DESedeKeySpec(passPhrase);
         SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede");
         SecretKey secretKey = keyFactory.generateSecret(keySpec);
         XMLCipher keyCipher = XMLCipher.getInstance(XMLCipher.RSA_v1dot5);
         keyCipher.init(XMLCipher.WRAP_MODE, publicKey);
         EncryptedKey encryptedKey = keyCipher.encryptKey(doc, secretKey);
              Element elementToEncrypt = (Element) doc.getDocumentElement();
              System.out.println("Szyrfuj&#281;: " + elementToEncrypt.getTextContent());
              XMLCipher xmlCipher = XMLCipher.getInstance(XMLCipher.TRIPLEDES);
              xmlCipher.init(XMLCipher.ENCRYPT_MODE, secretKey);
              EncryptedData encryptedDataElement = xmlCipher.getEncryptedData();
              KeyInfo keyInfo = new KeyInfo(doc);
              keyInfo.add(encryptedKey);
              encryptedDataElement.setKeyInfo(keyInfo);
              boolean encryptContentsOnly = true;
              xmlCipher.doFinal(doc, elementToEncrypt, encryptContentsOnly);
              // output the resulting document
              String [] parts = Const.FILE_IN.split("\\.");
              String saveAs = Const.FILE_OUT_PATH + File.separator + parts[0] + sufix + "." + parts[1];
              OutputStream os = new FileOutputStream(saveAs);
              XMLUtil.sameXMLtoFile(doc, os);
    } catch (Exception ex)
         throw new TestCBRException("E_CERBER_ENCRYPTION", ex);
    return doc;
    public void decrypt(Document doc, String sufix) throws SenderException
    try
              String namespaceURI = EncryptionConstants.EncryptionSpecNS;
         String localName = EncryptionConstants._TAG_ENCRYPTEDDATA;
         int ile = doc.getElementsByTagNameNS(namespaceURI, localName).getLength();
         if (ile == 0) throw new SenderException("E_SENDER_DECRYPTION_NEEDED");
         for(int i=0; i < ile; i++)
         Element encryptedDataElement = (Element) doc.getElementsByTagNameNS(namespaceURI, localName).item(0);
         XMLCipher xmlCipher = XMLCipher.getInstance();
         xmlCipher.init(XMLCipher.DECRYPT_MODE, null);
         xmlCipher.setKEK(privateKey);
         xmlCipher.doFinal(doc, encryptedDataElement);
                   String [] parts = Const.FILE_IN.split("\\.");
                   String saveAs = Const.FILE_OUT_PATH + parts[0] + sufix + "." + parts[1];
                   OutputStream os = new FileOutputStream(saveAs);
                        XMLUtil.saveXMLtoFile(doc, os);
    } catch (SenderException ex) {
         throw ex;
    } catch (Exception ex) {
         throw new SenderException("E_SENDER_DECRYPTION", ex);
    Please help me. I'm going into madness what's wrong with it...

  • Encrypt a file in PI using file adapter.

    Hi,
            I need to Encrypt a flat file and ftp it. Since the target server is a bank, the data after been placed there should be decrypted. How can i achieve this?

    Hi
    In case you are using a file adapter then you can use Operating system command after and before execution. in which before processing you can decrypt the file using some decrypting command line tool and after execution you can use command line command to delete the file. and after decryption and before deletion of file you can use file content conversion
    Or else you have to write a module processor for File adapter which will decrypt the message.
    These may help you
    How XML Encryption can be done using web services security in SAP NetWeaver XI
    How XML Encryption can be done using web services security in SAP NetWeaver XI
    How to achieve encryption in XI
    This thread is similar to your question and his question is solved. Please go through it.
    triggering encryption script with XI
    Hope this is usefull
    Thanks
    Saiyog
    Edited by: Saiyog Gonsalves on Jul 16, 2008 10:16 AM

  • Support for non-proprietary secure encrypt&sign format?

    Hi,
    I want to embed data in my application which I have encrypted and signed using strong cryptography, so that the application can verify the data (assuming the application itself doesn't get changed).
    Currently I construct three byte[] arrays:
    1.) DESede encrypted data
    2.) RSA encrypted DESede key
    3.) Signature of unencrypted data using the
    Signature signature = Signature.getInstance("SHA1withRSA")
    signature.initSign(rsaPrivateKey)
    signature.update(unencryptedData)
    I turn each of these three byte[]s into Strings using Base64Coder and then concatenate them ":" separated.
    While this works (I can decrypt and verify the data), the format in which I represent the encrypted and signed data (Base64 encoding and ":" separation) is not any widely used standard and also doesn't contain any metadata about the encryption algorithm used, as would e.g. a gnupg encrypted block.
    So I was wondering, why is there no static method in the JCE that just says
    String or byte[] encrypted = SomeClass.encryptAndSign(data, "RSAwithDESede")
    or something like that, which then encrypts and signs the data according to some standard format? E.g. such that I could then decrypt and verify the data with PGP/GnuPG/OpenSSL/... ?
    Is there any library that does this, and which preferrably provides a simple facade to the complexity of JCE?
    Any help is appreciated - thanks in advance!
    Tobias

    Other standards have addressed this problem. See XML Encryption (http://www.w3.org/Encryption/2001/) and XML Signature (http://www.w3.org/Signature/).
    XML Signature is now a standard component of J2SE 6.0 (http://java.sun.com/javase/6/docs/technotes/guides/security/xmldsig/XMLDigitalSignature.html)

Maybe you are looking for