Java.security.InvalidKeyException IOException  algid parse error

Hi
i am trying to encrypt message using private key (RSA), when i try to get the private key, for the given key spec, I get error (java.security.InvalidKeyException: IOException : algid parse error, not a sequence
below is he code snippet, error occurs at line no 4
KeyFactory keyFactory;
keyFactory = KeyFactory.getInstance(RSA);
PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(encryptionKeyBytes);
privKey = (RSAPrivateKey) keyFactory.generatePrivate(privSpec);
cf = Cipher.getInstance(RSA);
cf.init(Cipher.ENCRYPT_MODE, privKey);
let me know if i am missing something, the key is provide by 3rd party,
Thanks in advance

Hi,
glennlasrado wrote:
Its a valid private key, the same key is used by PHP client and it works,This may be due to PHP handling different key formats for you where your Java code is trying to decode a specific key format. You should try decoding the DER encoded key to see what format it is in.
Here is an example CRT private key from Java. You could pass this through a DER dump tool to see the tags if you are not familiar with DER encoding.
<pre>
30 820155
02 01 00
30 0D
06 09 2A864886F70D010101
05 00
04 82013F
30 82013B
02 01 00
02 41 00917ACA34E71863DDD2A6E9FF52850D88EB2EFF7BA936FF079ECBA0576B412388D12E76C31C09C136A041A7145043470606B7E4CC045BD343739181E1C380DB81
02 03 010001
02 40 7EFFEE9E1850167E8372EB3BD55209EAC945120B66417889B27A98D337F2798D9118564F1B4DB704A0BB2B589F8491D3B4AEA74512031AAEFB3BAB34C5AA0341
02 21 00F2B6B08C77C9100C914BD43E71D514CE52DC9CAF431C679D4274C58E2B0D6205
02 21 0099717E9F6020C0428FF8F002BA29BF339C4AB2F777860FE92D40933ADFBEE04D
02 21 00CF2088D9D6FF86EAB2B3FB94AEA020F9524D62894EC456C82586717139DC59E1
02 20 60E97DBFCB46E427262763EF5504E8EDFFD86E103E3D3DEF57D56127DE090041
02 21 008AEC6D299EAAF5378EEFAAF0043093A47CC0EE336745033225E071EE2393F172
</pre>
Your key file may look like this (the inner sequence of the above):
<pre>
30 82013B
02 01 00
02 41 00917ACA34E71863DDD2A6E9FF52850D88EB2EFF7BA936FF079ECBA0576B412388D12E76C31C09C136A041A7145043470606B7E4CC045BD343739181E1C380DB81
02 03 010001
02 40 7EFFEE9E1850167E8372EB3BD55209EAC945120B66417889B27A98D337F2798D9118564F1B4DB704A0BB2B589F8491D3B4AEA74512031AAEFB3BAB34C5AA0341
02 21 00F2B6B08C77C9100C914BD43E71D514CE52DC9CAF431C679D4274C58E2B0D6205
02 21 0099717E9F6020C0428FF8F002BA29BF339C4AB2F777860FE92D40933ADFBEE04D
02 21 00CF2088D9D6FF86EAB2B3FB94AEA020F9524D62894EC456C82586717139DC59E1
02 20 60E97DBFCB46E427262763EF5504E8EDFFD86E103E3D3DEF57D56127DE090041
02 21 008AEC6D299EAAF5378EEFAAF0043093A47CC0EE336745033225E071EE2393F172
</pre>
These are just the Hex string representations of the key formatted for your readability. There are several Eclipse plugins that can help you view DER encoded streams.
Cheers,
Shane
Edited by: safarmer on Oct 11, 2010 4:55 PM

Similar Messages

  • Java.security.InvalidKeyException: Illegal key size

    Hi,
    I have developed an adf application using jdeveloper 11g which hosts weblogic 10.3.3.0.
    My adf application has to connect to an external application for credit card validation.
    To achieve this i am using a HTTPURLConnection and passing the external address and attributes that has to be written to it.
    The external application which i am trying to connect is secured starts with https://..
    I get an error as soon i am trying to open the "connection.getOutputStream()".
    Following is the error i am getting
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "CN=T-TeleSec GlobalRoot Class 3,OU=T-Systems Trust Center,O=T-Systems Enterprise Services GmbH,C=DE". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "CN=T-TeleSec GlobalRoot Class 2,OU=T-Systems Trust Center,O=T-Systems Enterprise Services GmbH,C=DE". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "CN=GlobalSign,O=GlobalSign,OU=GlobalSign Root CA - R3". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "OU=Security Communication RootCA2,O=SECOM Trust Systems CO.\,LTD.,C=JP". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "CN=KEYNECTIS ROOT CA,OU=ROOT,O=KEYNECTIS,C=FR". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    java.security.InvalidKeyException: Illegal key size
         at javax.crypto.Cipher.a(DashoA13*..)
         at javax.crypto.Cipher.init(DashoA13*..)
         at javax.crypto.Cipher.init(DashoA13*..)
         at com.certicom.tls.provider.Cipher.init(Unknown Source)
         at com.certicom.tls.ciphersuite.SecurityParameters.createWriteCipher(Unknown Source)
         at com.certicom.tls.record.handshake.HandshakeHandler.changeCipherSpec(Unknown Source)
         at com.certicom.tls.record.handshake.ClientStateReceivedCertificate.handle(Unknown Source)
         at com.certicom.tls.record.handshake.HandshakeHandler.handleHandshakeMessage(Unknown Source)
         at com.certicom.tls.record.handshake.HandshakeHandler.handleHandshakeMessages(Unknown Source)
         at com.certicom.tls.record.MessageInterpreter.interpretContent(Unknown Source)
         at com.certicom.tls.record.MessageInterpreter.decryptMessage(Unknown Source)
         at com.certicom.tls.record.ReadHandler.processRecord(Unknown Source)
         at com.certicom.tls.record.ReadHandler.readRecord(Unknown Source)
         at com.certicom.tls.record.ReadHandler.readUntilHandshakeComplete(Unknown Source)
         at com.certicom.tls.interfaceimpl.TLSConnectionImpl.completeHandshake(Unknown Source)
         at com.certicom.tls.record.WriteHandler.write(Unknown Source)
         at com.certicom.io.OutputSSLIOStreamWrapper.write(Unknown Source)
         at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)
         at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:124)The code i am using to connect to the external website is as follows.
        URL url;  
        HttpURLConnection connection = null; 
        try {    
          //Create connection  
          url = new URL(targetURL); 
          connection = (HttpURLConnection)url.openConnection();   
          connection.setRequestMethod("POST");
          connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
         connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
          connection.setRequestProperty("Content-Language", "en-US");  
          connection.setUseCaches (false); 
           connection.setDoOutput(true); 
           DataOutputStream wr = new DataOutputStream (      
               connection.getOutputStream ());
                wr.writeBytes (urlParameters);  
                wr.flush ();  
          wr.close ();   
                //Get Response   
          InputStream is = connection.getInputStream();  
          System.out.println("after getting input stream");
        BufferedReader rd = new BufferedReader(new InputStreamReader(is));  
          System.out.println("after BUffered reader");
        String line;  
        StringBuffer response = new StringBuffer();  
          System.out.println("after String buffer");
        while((line = rd.readLine()) != null) {     
          response.append(line);   
          response.append('\r');  
          }      rd.close();  
        return response.toString();
        } catch (Exception e) { 
          e.printStackTrace();   
          return null; 
          } finally { 
          if(connection != null) {      
            connection.disconnect();  
        }I am currently totally clueless , i dont understand what steps should i take. Is this error due to some keystore stuff??
    I even tried to replace the policy files in jre as per some blogs but it still does not work.
    I have very limited knowledge of the security issues with weblogic , i will really appreciate if i can get any links or any help in this matter.
    Thanks in advance
    ash

    The messages prior to the exception are very significant:
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "CN=T-TeleSec GlobalRoot Class 3,OU=T-Systems Trust Center,O=T-Systems Enterprise Services GmbH,C=DE". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "CN=T-TeleSec GlobalRoot Class 2,OU=T-Systems Trust Center,O=T-Systems Enterprise Services GmbH,C=DE". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "CN=GlobalSign,O=GlobalSign,OU=GlobalSign Root CA - R3". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "OU=Security Communication RootCA2,O=SECOM Trust Systems CO.\,LTD.,C=JP". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    <Oct 8, 2010 10:32:54 AM CDT> <Notice> <Security> <BEA-090898> <Ignoring the trusted CA certificate "CN=KEYNECTIS ROOT CA,OU=ROOT,O=KEYNECTIS,C=FR". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
    java.security.InvalidKeyException: Illegal key size
    So there are at least 4 certificates in your server's truststore that are causing issues.
    Is your weblogic server using CustomIdentityAndStandardTrust? If so, the the keystore is the $JAVA_HOME/jre/lib/security/cacerts
    You should familiarize yourself with keytool ( in $JAVA_HOME/bin ) and consider removing entries from your trust store unless you absolutely need them and are willing to trust any cert signed by them. There's been a thread about some newer Certificate Authorities ( CAs ) that were included as part of a recent java upgrade which have caused similar "unknown OID" issues.
    For your specific endpoint, you can use your browser to invoke the services' wsdl; this will cause your browser to fetch the certificate from that server
    You can then see what CA is used to sign it. Then see whether that CA is in your truststore.
    There is also a thread with a very simple class to test the SSL handshake:
    Re: Use Server Cert in Managed server not working

  • Java.security.InvalidKeyException:Elgamal

    I am trying to encrypt and decrypt Elgaman but I am getting error ofElGamal: Exception: java.security.InvalidKeyException: Illegal key size or default parameters
    java.security.InvalidKeyException: Illegal key size or default parameters
         at javax.crypto.Cipher.a(DashoA13*..)
         at javax.crypto.Cipher.init(DashoA13*..)
         at org.students.RSA2.testGP(RSA2.java:71)
         at org.students.RSA2.performTest(RSA2.java:277)
         at org.bouncycastle.util.test.SimpleTest.perform(Unknown Source)
         at org.bouncycastle.util.test.SimpleTest.runTest(Unknown Source)
         at org.bouncycastle.util.test.SimpleTest.runTest(Unknown Source)
         at org.students.RSA2.main(RSA2.java:291)
    i installed the JDK 5.0 Update 22 and download the jce from
    http://www.oracle.com/technetwork/java/javase/downloads/index-jdk5-jsp-142662.html and installed in
    C:\Program Files\Java\jdk1.5.0_22\jre\lib\security
    but It give me same error .Please help me. Thanks in advance
    Edited by: user11357554 on Apr 17, 2011 2:06 PM
    Edited by: EJP on 18/04/2011 11:41: added code tags. Please use them.
    Edited by: user11357554 on Apr 22, 2011 9:47 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    user11357554 wrote:
    i installed the JDK 5.0 Update 22 and download the jce from
    http://www.oracle.com/technetwork/java/javase/downloads/index-jdk5-jsp-142662.html and installed in
    C:\Program Files\Java\jdk1.5.0_22\jre\lib\securityI don't think you can have followed the 'unlimited strength' installation instructions. You need to unzip the 'unlimited strength' file and copy the content of it's jce subdirectory directly to the C:\Program Files\Java\jdk1.5.0_22\jre\lib\security directory.
    P.S. Why are you using JDK1.5?
    P.S-1. When you convert a String to/from bytes ALWAYS specify the character encoding since the default character encoding is very likely to be different for different OS, OS variants and Java variants.
    P.S-2. Never use String as a container for binary data and ciphertext IS binary data.

  • Java.security.InvalidKeyException: Unsupported key type: SunPKCS11-MyPKCS11

    I am having a very strange issue with my CAC card. I wrote a small Java program to login into ProjectForge.mil webservice
    ICollabNetSoap m_sfSoap = (ICollabNetSoap)
    ClientSoapStubFactory.getSoapStub(ICollabNetSoap.class, "https://project.forge.mil/");
    String sessionId = m_sfSoap.login("", "");
    After entering CAC PIN, it is throwing exception saying that "javax.net.ssl.SSLHandshakeException: Received fatal alert: unsupported_certificate".
    More specific exception is:
    Caused by: java.security.InvalidKeyException: Unsupported key type: SunPKCS11-MyPKCS11 RSA private key, 2048 bits (id 39632224, token object, sensitive, unextractable)
    Note: I have asked three of my co-workers to run the same program using their CAC's and seems to be working fine.
    Only the difference between their CACs and mine is CA(Certificate Authority Value. Their's is 24 and where as mine is 25). It looks like JVM was not able to understand the private key of my CAC.
    On the other note, my CAC cworks fine with web service client application that was written in .Net.
    I am using Jdk-1.6.0_26 and I have already downloaded and installed latest jce .jar files.
    Any help is greatly appreciated
    Here are the exception details:
    =======================================
    [java] Tue Aug 02 17:07:54 MST 2011 URL assignment worked
    [java] Tue Aug 02 17:07:54 MST 2011 Trying login...
    [java] Exception in thread "main" AxisFault
    [java] faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    [java] faultSubcode:
    [java] faultString: javax.net.ssl.SSLHandshakeException: Received fatal alert: unsupported_certificate
    [java] faultActor:
    [java] faultNode:
    [java] faultDetail:
    [java] {http://xml.apache.org/axis/}stackTrace:javax.net.ssl.SSLHandshakeException: Received fatal alert: unsupported_certificate
    [java] at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
    [java] at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1720)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149)
    [java] at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186)
    [java] at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
    [java] at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
    [java] at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
    [java] at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    [java] at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    [java] at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    [java] at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    [java] at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    [java] at org.apache.axis.client.Call.invoke(Call.java:2767)
    [java] at org.apache.axis.client.Call.invoke(Call.java:2443)
    [java] at org.apache.axis.client.Call.invoke(Call.java:2366)
    [java] at org.apache.axis.client.Call.invoke(Call.java:1812)
    [java] at com.collabnet.ce.soap50.webservices.cemain.CollabNetSoapStub.login(CollabNetSoapStub.java:115)
    [java] at com.collab.examples.LoginTF.main(LoginTF.java:30)
    [java] {http://xml.apache.org/axis/}hostname:GDYL8420N5B
    [java] javax.net.ssl.SSLHandshakeException: Received fatal alert: unsupported_certificate
    [java] at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    [java] at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
    [java] at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    [java] at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    [java] at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    [java] at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
    [java] at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    [java] at org.apache.axis.client.Call.invoke(Call.java:2767)
    [java] at org.apache.axis.client.Call.invoke(Call.java:2443)
    [java] at org.apache.axis.client.Call.invoke(Call.java:2366)
    [java] at org.apache.axis.client.Call.invoke(Call.java:1812)
    [java] at com.collabnet.ce.soap50.webservices.cemain.CollabNetSoapStub.login(CollabNetSoapStub.java:115)
    [java] at com.collab.examples.LoginTF.main(LoginTF.java:30)
    [java] Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: unsupported_certificate
    [java] at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
    [java] at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1720)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165)
    [java] at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149)
    [java] at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:186)
    [java] at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
    [java] at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
    [java] at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
    [java] ... 11 more
    [java] Java Result: 1
    ==================================================================
    I have captured more specific exception which says
    Caused by: java.security.InvalidKeyException: Unsupported key type: SunPKCS11-MyPKCS11 RSA private key, 2048 bits (id 39632224, token object, sensitive, unextractable)

    Thanks, I have installed OpenSSL.
    Here is the PEM copy of my certificate
    ==================================================
    -----BEGIN CERTIFICATE-----
    MIIElTCCA32gAwIBAgIDG5RgMA0GCSqGSIb3DQEBBQUAMFcxCzAJBgNVBAYTAlVT
    MRgwFgYDVQQKEw9VLlMuIEdvdmVybm1lbnQxDDAKBgNVBAsTA0RvRDEMMAoGA1UE
    CxMDUEtJMRIwEAYDVQQDEwlET0QgQ0EtMjUwHhcNMTEwMzI1MDAwMDAwWhcNMTIw
    NTI4MjM1OTU5WjCBjDELMAkGA1UEBhMCVVMxGDAWBgNVBAoTD1UuUy4gR292ZXJu
    bWVudDEMMAoGA1UECxMDRG9EMQwwCgYDVQQLEwNQS0kxEzARBgNVBAsTCkNPTlRS
    QUNUT1IxMjAwBgNVBAMTKVlBUlJBUFVSRUREWS5TT01BU0VLSEFSQS5SRUREWS4x
    Mzg2Nzc5MDM4MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArPjzB0Lk
    FAMegXbka3944sAm2jq7qKGnpIYhL82/gAj7zJzAPJsoE66L9spiEoDfh0osy2pO
    wqH/0NfQdGjgIGjDG2OrKhTxYXBqKZk2p7V84H4RK5duB8JU7B7R7uY+U9RkyiNd
    YuSycGXKULGa5eow/OCCI3iN8A+4NjpvswKhw3WvWhDow4xl1x6E6I89RhscU78z
    D6VtamidLK8mCWDihplmSFtCCCK5RsUjv/KuZcASAHe3Tb7di2Fb68liS5Yhf5v7
    SrezRYHbHpAZMOImy74t1UzcGkHFkE5kO4SPbAcVyhMwzE3aZNubXl5biQCEmxqh
    80HvckcQj+b5TwIDAQABo4IBMjCCAS4wHwYDVR0jBBgwFoAULgtl+dZl3kujJXWk
    oS6FIUBzuQowNQYDVR0fBC4wLDAqoCigJoYkaHR0cDovL2NybC5kaXNhLm1pbC9j
    cmwvRE9EQ0FfMjUuY3JsMA4GA1UdDwEB/wQEAwIGwDAjBgNVHSAEHDAaMAsGCWCG
    SAFlAgELCTALBglghkgBZQIBCxMwHQYDVR0OBBYEFFhzyfk4PpY2JzyrNAH+ka4n
    MDLRMGMGCCsGAQUFBwEBBFcwVTAxBggrBgEFBQcwAoYlaHR0cDovL2NybC5kaXNh
    Lm1pbC9zaWduL0RPRENBXzI1LmNlcjAgBggrBgEFBQcwAYYUaHR0cDovL29jc3Au
    ZGlzYS5taWwwGwYDVR0JBBQwEjAQBggrBgEFBQcJBDEEEwJVUzANBgkqhkiG9w0B
    AQUFAAOCAQEATpknlaaGiKZRNL+8YNgVy2kQDEFgdg/O4tB7NBRq3PiyUodnpOur
    2WbML+ViDMv7IxKEKUGnOgpc9CRNCR3+NERmaeVShlQwfF/3PjZ/DWiSuSMD79qC
    Y+tom4AkV69kLKl/O07Ql+jYh+Uy1x+MGWm46QsdOU5kwXHvPrgBI+5IpOrhXAW9
    DmOfTbdpmQvQHBC8nnLscrolQutLQtOIN60mRZmJG1x762sGNQsFgO8fTOus+C8v
    rlGafWRi/BJxlQCB3qb5nvI1TI68DLlqvgvX8IR7fpL/tq222PDAorpGf23YpSQt
    9x1xD5aZLkgYIICa6/L1Yus9FjtCR6eHug==
    -----END CERTIFICATE-----
    =======================================================

  • Java.security.ProviderException: unable to parse algorithm params.

    java.security.ProviderException: unable to parse algorithm params.
    Anyone any idea how to get around this problem? Is it something to do with the java.security file?

    i may or may not be very helpful depending on your setup.
    1. when you say "this works fine for sun plugins, but not for the MS JVM", what do you mean? where is the Sun VM used (client or server side) and where is the MS VM used (client or server side)?
    2. how are you obtaining the binary key encoding (that is then BASE64-encoded)? i assume you are calling java.security.Key.getEncoded. are you getting a standard PKCS8Encoding for a private key? you can check via Key.getFormat. make sure if you are switching between VM's, that both VM's are encoding the key in a format that you expect. in particular, if they both claim to export into PKCS8, then make sure the encoded bytes are identical.
    3. how are you re-constituting the key? are you using the java.security.spec.KeySpec APIs? i believe these were added in J2SE 1.2, which means i don't believe they are available in the MS VM (which is only 1.1.X-compliant if i recall correctly).
    based on all of the above, i don't think the java.security file is the culprit - but perhaps incompatible key encodings between different vendor VM's.

  • Java.security.InvalidKeyException: Wrong key size

    Hi,
    I am getting this InvalidKeyException can someone help me what is that I am missing here.
    Thanks
    here is the code I am working on
    platform- Win2000, JCE1.2.1
    String message = "SSO test message";
    String ssoKey =new String( "newtestKey");
    Security.addProvider(new com.sun.crypto.provider.SunJCE());
    byte [] keyByte = ssoKey.getBytes();
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DESede");
    DESedeKeySpec desKeySpec = new DESedeKeySpec(keyByte);
    SecretKey secretKey = keyFactory.generateSecret(desKeySpec);

    Stupid question. If you have taken some informations about the cipher you're using, then you would be able to get the answer on your own.
    The DESede use a 192 bits key, That give us 24 as size in byte. This size give us a key of 24 characters. You only use 10 characters, so don't be surprised of having such error.
    I just add some idea : the random generation of a key is the most secure, and if a manual generation is needed, using the ASCII table as base is already better than the limited characters of the keyboard.
    Next time, take a book about cipher before trying to play with them.

  • Got java.lang.IllegalStateException: IOException: "utf-8"

    Can someone please help me with this? I got a java.lang.IllegalStateException: IOException: "utf-8" error when calling web service. The exception is like the following:
    javax.xml.ws.soap.SOAPFaultException: java.lang.IllegalStateException: IOException: "utf-8"
    at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:196)
    at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:122)
    at com.sun.xml.ws.client.dispatch.DispatchImpl.doInvoke(DispatchImpl.java:196)
    at com.sun.xml.ws.client.dispatch.DispatchImpl.invoke(DispatchImpl.java:215)
    at oracle.sysman.connector.common.ConnectorServiceSoapWrapper.sendRequestBase(ConnectorServiceSoapWrapper.java:202)
    ConnectorServiceSoapWrapper is my class and in sendRequestBase() method I had the following statement to invoke the web service.
    Dispatch<SOAPMessage> dispatch = service.createDispatch(null, SOAPMessage.class, Service.Mode.MESSAGE);
    SOAPMessage responseMsg = dispatch.invoke(msg);
    dispatch object is an instance of javax.xml.ws.Dispatch and service is an instance of javax.xml.ws.Service. It looks like the error is thrown out before the web service is called. Does anyone have any idea what's happening here?
    My java version is
    java version "1.6.0_14"
    Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
    Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
    Thanks!

    I was reading the source code of com.sun.xml.ws.client.dispatch.DispatchImpl
    http://www.docjar.com/html/api/com/sun/xml/ws/client/dispatch/DispatchImpl.java.html
    And the following piece of the code is part of the stack trace.
    +195 } catch(Throwable e){+
    +196 // it could be a RuntimeException resulting due to some internal bug or+
    +197 // its some other exception resulting from user error, wrap it in+
    +198 // WebServiceException+
    +199 throw new WebServiceException(e);+
    +200 }+
    Anyone has any hint? Thanks!

  • Getting Error: java.lang.IllegalArgumentException: can't parse argument 0

    HI All,
    I am implementing the Message Pool in NWDS.
    I have two InputFields: Firstname and Lastname.
    and i have a method name: CheckMandatory which takes one argument as String.
    I have implemented this Method in the StartView. Now when i am leaving this fields empty and pressing the Go Button.
    Then i am getting the Following Error:
       java.lang.IllegalArgumentException: can't parse argument number 0
    So pls help me out......
    Regards,
    Dhruv Shah

    Hi,
    THis is the Stack Trace:
    java.lang.IllegalArgumentException: can't parse argument number  0
         at java.text.MessageFormat.makeFormat(MessageFormat.java:1323)
         at java.text.MessageFormat.applyPattern(MessageFormat.java:447)
         at java.text.MessageFormat.<init>(MessageFormat.java:347)
         at java.text.MessageFormat.format(MessageFormat.java:800)
         at com.sap.tc.webdynpro.services.datatypes.core.DataTypeFormatter.format(DataTypeFormatter.java:80)
         at com.sap.tc.webdynpro.progmodel.controller.MessageItem.getMessage(MessageItem.java:211)
         at com.sap.tc.webdynpro.clientimpl.html.uielib.standard.uradapter.InputFieldAdapter$DataTip.setMessage(InputFieldAdapter.java:1156)
         at com.sap.tc.webdynpro.clientimpl.html.uielib.standard.uradapter.InputFieldAdapter.getAssociatedAdapters(InputFieldAdapter.java:1323)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:299)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.MatrixLayoutRenderer.renderMatrixLayoutCellFragment(MatrixLayoutRenderer.java:729)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.MatrixLayoutRenderer.renderMatrixLayoutRowFragment(MatrixLayoutRenderer.java:346)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.MatrixLayoutRenderer.renderMatrixLayoutFragment(MatrixLayoutRenderer.java:302)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.MatrixLayoutRenderer.render(MatrixLayoutRenderer.java:71)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.renderScrollContainerFragment(ScrollContainerRenderer.java:516)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.ie6.ScrollContainerRenderer.render(ScrollContainerRenderer.java:61)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.UiWindowRenderer.render(UiWindowRenderer.java:45)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:294)
         at com.sap.tc.webdynpro.clientimpl.html.renderer.uielements.base.AbstractRenderManager.render(AbstractRenderManager.java:102)
         at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendHtml(HtmlClient.java:555)
         at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendResponse(HtmlClient.java:346)
         at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.sendResponse(HtmlClient.java:255)
         at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.retrieveData(HtmlClient.java:157)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:425)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:248)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:160)
    Regards,
    Dhruv Shah

  • Applet Error:java.security.AccessControlException: access denied

    Hi,
    I just successful deploy an business component project to oralce 8.1.6 as an EJB Session bean, and
    the test of application module is successful. In the same workspace, I create an new project with
    an applet(which contains only an grid control)as a client of the business component. Everything works
    fine within the Applet viewer, however, when I trying to load the applet in IE5.5 I got the following
    error message in java console:
    Java(TM) Plug-in
    Using JRE version 1.2.1
    User home directory = D:\Documents and Settings\ERic
    Proxy Configuration: no proxy
    JAR cache enabled.
    Failed to query environment: 'access denied (java.util.PropertyPermission jbo.debugoutput read)'
    Diagnostics: Silencing all diagnostic output (use -Djbo.debugoutput=console to see it)
    Failed to query environment: 'access denied (java.util.PropertyPermission jbo.logging.show.timing read)'
    Failed to query environment: 'access denied (java.util.PropertyPermission jbo.logging.show.function read)'
    Failed to query environment: 'access denied (java.util.PropertyPermission jbo.logging.show.level read)'
    Failed to query environment: 'access denied (java.util.PropertyPermission jbo.logging.show.linecount read)'
    Failed to query environment: 'access denied (java.util.PropertyPermission jbo.logging.trace.threshold read)'
    Failed to query environment: 'access denied (java.util.PropertyPermission jbo.jdbc.driver.verbose read)'
    java.lang.ExceptionInInitializerError: java.security.AccessControlException: access denied (java.util.PropertyPermission org.omg.CORBA.ORBClass read)
    at java.security.AccessControlContext.checkPermission(Compiled Code)
    at oracle.aurora.jndi.orb_dep.Orb.<clinit>(Orb.java:24)
    at oracle.aurora.jndi.sess_iiop.sess_iiopURLContext.<clinit>(sess_iiopURLContext.java:9)
    at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:588)
    at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:537)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:274)
    at javax.naming.InitialContext.lookup(InitialContext.java:349)
    at oracle.jbo.client.remote.ejb.aurora.AuroraEJBAmHomeImpl.connectToService(AuroraEJBAmHomeImpl.java:179)
    at oracle.jbo.client.remote.ejb.aurora.AuroraEJBAmHomeImpl.createSession(AuroraEJBAmHomeImpl.java:152)
    at oracle.jbo.client.remote.ejb.aurora.AuroraEJBAmHomeImpl.initRemoteHome(AuroraEJBAmHomeImpl.java:123)
    at oracle.jbo.client.remote.ejb.aurora.AuroraEJBAmHomeImpl.<init>(AuroraEJBAmHomeImpl.java:59)
    at oracle.jbo.client.remote.ejb.aurora.AuroraEJBInitialContext.createJboHome(AuroraEJBInitialContext.java:47)
    at oracle.jbo.common.JboInitialContext.lookup(JboInitialContext.java:72)
    at javax.naming.InitialContext.lookup(InitialContext.java:349)
    at oracle.dacf.dataset.SessionInfo._createAppModule(SessionInfo.java:2330)
    at oracle.dacf.dataset.SessionInfo.connect(SessionInfo.java:1799)
    at oracle.dacf.dataset.SessionInfo.openProducerObject(SessionInfo.java:1848)
    at oracle.dacf.dataset.ProducerObject.open(ProducerObject.java:94)
    at oracle.dacf.dataset.SessionInfo.publishSession(SessionInfo.java:1305)
    at oracle.dacf.dataset.SessionInfo.publishSession(SessionInfo.java:1287)
    at broadcastapplet.myBroadCastApplet.init(myBroadCastApplet.java:70)
    at sun.applet.AppletPanel.run(Compiled Code)
    at java.lang.Thread.run(Thread.java:479)
    The Oracle 8.1.6 runs on Win2000, I put the JAR & related zip files in the same machine's IIS webserver.
    Is anyone can help?
    ERic

    Hi Shaji,
    Are you calling a webservice from within an Xacute Query for your applet?  On first glance, it looks like a web service call is being rejected due to security permissions.  If you have a webservice call (or HTTP post/get), can you test it separately with the same credentials as the webpage is using?
    Regards,
    Mike

  • Error in weblogic7.0 :java.security.NoSuchAlgorithmException:

    Hi All
    thanks in advance.
    i am facing a peculiar problem while using SunJce provider
    i have some classes to encrypt& decrypt some information using
    DeffieHellman protocol.
    Problem 1
    while i am running those classes in command prompts
    some time it gives me correct results where as other time during decryption i am unable to get the plaintext (i am getting some junk character),where as some time it gives me Badpadding exception
    I am using JDK1.3 which comes with weblogic and jce1.2.2
    for classpath and path setting
    set path=D:\bea\jdk131_03\bin
    set classpath=%classpath%; D:\bea\jdk131_03\jre\lib\ext\ jce1_2_2.jar
    set classpath=%classpath%; D:\bea\jdk131_03\jre\lib\ext\sunjce_provider.jar
    set classpath=%classpath%; D:\bea\jdk131_03\jre\lib\ext\local_policy.jar
    set classpath=%classpath%; D:\bea\jdk131_03\jre\ext\US_export_policy.jar
    my BEA_HOME=d\bea and JAVA_HOME=D:\bea\jdk131_03\jre
    Problem 2
    While i am using those classes in servlet and jsp which are deployed in weblogic 7
    Some time i am getting correct results
    but as i stop and start the weblogic server ,i am getting .NoSuchAlgorithmException.
    So mainly i am having two classes DiffieHellmanKeyGeneRation and DHEncryptDecrypt given below
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import javax.crypto.interfaces.*;
    import com.sun.crypto.provider.SunJCE;
    public class DiffieHellmanKeyGeneRation {
    PublicKey alicePubKey=null;
         PublicKey bobPubKey=null;
         KeyAgreement aliceKeyAgree =null;
         KeyAgreement bobKeyAgree =null;
    * DiffieHellmanKeyGeneRation() constructor -Set the mode and call run method to generate Keypairs
    * and assigns it to the instance variables .
    * @param nil
    * @returns nil
    public DiffieHellmanKeyGeneRation(){
         try {
    String mode = "GENERATE_DH_PARAMS";
                   run(mode);
    } catch (Exception e) {
    System.err.println("Error: " + e);
    System.exit(1);
    * getAlicePubKey() -Return the Instance Variable alicePubKey
    * @param nil
    * @returns PublicKey
    public PublicKey getAlicePubKey()
    return alicePubKey;
    * getBobPubKey() -Return the Instance Variable bobPubKey
    * @param nil
    * @returns PublicKey
    public PublicKey getBobPubKey()
    return bobPubKey;
    * getAliceKeyAgree() -Return the Instance Variable aliceKeyAgree
    * @param nil
    * @returns KeyAgreement
         public KeyAgreement getAliceKeyAgree()
    return aliceKeyAgree;
    * getBobKeyAgree() -Return the Instance Variable bobKeyAgree
    * @param nil
    * @returns KeyAgreement
    public KeyAgreement getBobKeyAgree()
    return bobKeyAgree;
    *run() method -Generate Algorithm instance,KeySpec,and keypair
    * and assigns it to the instance variables .
    * @param String
    * @returns nil
    private void run(String mode) throws Exception {
    DHParameterSpec dhSkipParamSpec=null;
    // System.out.println("Creating Diffie-Hellman parameters (takes VERY long) ...");
    AlgorithmParameterGenerator paramGen=AlgorithmParameterGenerator.getInstance("DH");
    paramGen.init(512);
    AlgorithmParameters params = paramGen.generateParameters();
    dhSkipParamSpec = (DHParameterSpec)params.getParameterSpec(DHParameterSpec.class);
    * Alice creates her own DH key pair, using the DH parameters from
    * above
    // System.out.println("ALICE: Generate DH keypair ...");
    KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH");
    aliceKpairGen.initialize(dhSkipParamSpec);
    KeyPair aliceKpair = aliceKpairGen.generateKeyPair();
    // Alice creates and initializes her DH KeyAgreement object
    // System.out.println("ALICE: Initialization ...");
    aliceKeyAgree = KeyAgreement.getInstance("DH");
    aliceKeyAgree.init(aliceKpair.getPrivate());
    // Alice encodes her public key, and sends it over to Bob.
    byte[] alicePubKeyEnc = aliceKpair.getPublic().getEncoded();
    * Let's turn over to Bob. Bob has received Alice's public key
    * in encoded format.
    * He instantiates a DH public key from the encoded key material.
    KeyFactory bobKeyFac = KeyFactory.getInstance("DH");
    X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(alicePubKeyEnc);
    alicePubKey = bobKeyFac.generatePublic(x509KeySpec);
    * Bob gets the DH parameters associated with Alice's public key.
    * He must use the same parameters when he generates his own key
    * pair.
    DHParameterSpec dhParamSpec = ((DHPublicKey)alicePubKey).getParams();
    // Bob creates his own DH key pair
    // System.out.println("BOB: Generate DH keypair ...");
    KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH");
    bobKpairGen.initialize(dhParamSpec);
    KeyPair bobKpair = bobKpairGen.generateKeyPair();
    // Bob creates and initializes his DH KeyAgreement object
    // System.out.println("BOB: Initialization ...");
    bobKeyAgree = KeyAgreement.getInstance("DH");
    bobKeyAgree.init(bobKpair.getPrivate());
    // Bob encodes his public key, and sends it over to Alice.
    byte[] bobPubKeyEnc = bobKpair.getPublic().getEncoded();
    * Alice uses Bob's public key for the first (and only) phase
    * of her version of the DH
    * protocol.
    * Before she can do so, she has to instanticate a DH public key
    * from Bob's encoded key material.
    KeyFactory aliceKeyFac = KeyFactory.getInstance("DH");
    x509KeySpec = new X509EncodedKeySpec(bobPubKeyEnc);
    bobPubKey = aliceKeyFac.generatePublic(x509KeySpec);
    2)
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import javax.crypto.interfaces.*;
    import sun.misc.*;
    import com.sun.crypto.provider.SunJCE;
    public class DHEncryptDecrypt {
    PublicKey alicePubKey=null;
         PublicKey bobPubKey=null;
         KeyAgreement aliceKeyAgree =null;
         KeyAgreement bobKeyAgree =null;
         SecretKey bobDesKey = null;
         SecretKey aliceDesKey =null;
    * DHEncryptDecrypt constructor -it intancetiate DiffieHellmanKeyGeneRation object to get Public key of both party and Shared Secrete
    * and assigns it to the instance variables .
    * @param nil
    * @returns nil
         public DHEncryptDecrypt()
              try{
              init();
         }catch(Exception e){e.printStackTrace();}
    * init() -it DiffieHellmanKeyGeneRation object to get Public key of both party and Shared Secrete
    * and assigns it to the instance variable ds.
    * @param nil
    * @returns nil
    private void init() throws Exception
         System.out.println("Initialising...");
                   DiffieHellmanKeyGeneRation dhPubKey=new DiffieHellmanKeyGeneRation();
                   alicePubKey=dhPubKey.getAlicePubKey();
                   bobPubKey=dhPubKey.getBobPubKey();
    aliceKeyAgree=dhPubKey.getAliceKeyAgree();
                   bobKeyAgree=dhPubKey.getBobKeyAgree();
    //System.out.println("ALICE: Execute PHASE1 ...");
    aliceKeyAgree.doPhase(bobPubKey, true);
         * Bob uses Alice's public key for the first (and only) phase
         * of his version of the DH
         * protocol.
    // System.out.println("BOB: Execute PHASE1 ...");
    bobKeyAgree.doPhase(alicePubKey, true);
    * At this stage, both Alice and Bob have completed the DH key
    * agreement protocol.
    * Both generate the (same) shared secret.
    byte[] aliceSharedSecret = aliceKeyAgree.generateSecret();
    int aliceLen = aliceSharedSecret.length;
    byte[] bobSharedSecret = new byte[aliceLen];
    int bobLen;
    /* try {
    // show example of what happens if you
    // provide an output buffer that is too short
    bobLen = bobKeyAgree.generateSecret(bobSharedSecret, 1);
    } catch (ShortBufferException e) {
    System.out.println(e.getMessage());
    // provide output buffer of required size
    bobLen = bobKeyAgree.generateSecret(bobSharedSecret, 0);
              if (!java.util.Arrays.equals(aliceSharedSecret, bobSharedSecret))
    throw new Exception("Shared secrets differ");
    //System.out.println("Shared secrets are the same");
    // System.out.println("Return shared secret as SecretKey object ...");
    // Bob
    // Note: The call to bobKeyAgree.generateSecret above reset the key
    // agreement object, so we call doPhase again prior to another
    // generateSecret call
    bobKeyAgree.doPhase(alicePubKey, true);
    bobDesKey = bobKeyAgree.generateSecret("DES");
    // Alice
    // Note: The call to aliceKeyAgree.generateSecret above reset the key
    // agreement object, so we call doPhase again prior to another
    // generateSecret call
    aliceKeyAgree.doPhase(bobPubKey, true);
    aliceDesKey = aliceKeyAgree.generateSecret("DES");
    * encrypt() - Alice encrypts, using DES in ECB mode
    * and assigns it to the instance variable ds.
    * @param String
    * @returns String
              public String encrypt(String ClearText) throws Exception
         String CipherText=null;
                   try{
                   // byte[] iv = {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF,(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};
              Cipher aliceCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
         aliceCipher.init(Cipher.ENCRYPT_MODE, aliceDesKey);
                   byte[] cleartext = ClearText.getBytes();
                   //System.out.println("cleartext Array:"+ cleartext.size);
                   byte[] ciphertext = aliceCipher.doFinal(cleartext);
    // BASE64Encoder b64e = new BASE64Encoder();
                   //CipherText = b64e.encode(ciphertext);
                   CipherText = new String(ciphertext);
                   }catch(Exception e){e.printStackTrace();}
         return CipherText;
    * encrypt() - Bob Decrypts, using DES in ECB mode
    * and assigns it to the instance variable ds.
    * @param String
    * @returns String
    public String decrypt(String CipherText) throws Exception
    String Recovered=null;
         try{
              // byte[] iv = {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF,(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF};
    // System.out.println("Length of String is:"+CipherText.length());
                   Cipher bobCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
              bobCipher.init(Cipher.DECRYPT_MODE, bobDesKey);
                   byte[] CipherTextBytes=CipherText.getBytes();
    byte[] recovered = bobCipher.doFinal(CipherTextBytes);
                   Recovered=new String(recovered);
              // System.out.println("Decryption:"+Recovered+"length:="+Recovered.length());
    }catch(Exception e){e.printStackTrace();}
         return Recovered;
    and i am using following logic to encrypt and decrypt
    String MyPlainText ="sm_user=residential&csol_account=383784";
    //String MyPlainText ="This is my message";
         System.out.println("\nPlain Text:="+MyPlainText+"\n\n");
    try{
         DHEncryptDecrypt ed=new DHEncryptDecrypt();
    String CipherText=(ed.encrypt(MyPlainText));
                   BASE64Encoder b64e = new BASE64Encoder();
                   String CipherText1 = b64e.encode(CipherText.getBytes());
    System.out.println("\n\nUserInfo="+CipherText1);
         String DecryptedMessage=ed.decrypt(CipherText);
    System.out.println("\n\nDecrypedMessage=:"+DecryptedMessage);
         }catch(Exception e){e.printStackTrace();}
    and my java.security file in D:\ bea\jdk131_03\jre\lib\security
    is changed to add the provider as
    # List of providers and their preference orders (see above):
    security.provider.1=sun.security.provider.Sun
    security.provider.2=com.sun.crypto.provider.SunJCE
    security.provider.3=com.sun.rsajca.Provider
    # Class to instantiate as the system Policy. This is the name of the class
    # that will be used as the Policy object.
    policy.provider=sun.security.provider.PolicyFile
    Pls help me to resolve the magic shown by these classes.....some time right and some time worng
    mainly i need help in
    Badpadding Exception and NosuchAlogorithm exception in weblogic
    Thanks
    And regards
    Arati

    replace all calls of getBytes() and new String(text) with the versions where you can state a charset: getBytes(charset), new String(text, charset). i use "iso-8859-1" as the charset.
    this should at least fix your "Badpadding exception" problem (it did fix it for me).

  • Parse errors while creating a Web service from Java class!

    Can anybody tell me please, is it possible to create a Web Service from java class where the input from user is required ?
    I have the following program, which is successfully compiled, but when I'm trying to make a web service in JDeveloper, the following error occurs:
    "Validation failed.
    The implementation class primePackage.isPrime ofport type MyWebService contains parse errors."
    import java.io.*;
    import java.util.*;
    class isPrime
    public static void main (String args[])
    Scanner reader = new Scanner(System.in);
    int n;
    System.out.println ("Enter a number you want to know is it prime or not");
    n=reader.nextInt();
    if (isPrime(n))
    System.out.println ("True");
    else
    System.out.println ("False");
    static boolean isPrime (int n)
    int i=2;
    while (i<=n-1)
    if (n%i==0)
    return false;
    i++;
    return true;
    }

    Hi,
    Can anybody tell me please, is it possible to create
    a Web Service from java class where the input from
    user is required ?Yes, the parameters of your method will be mapped in WSDL.
    But i've some considerations about your code.
    I suggest you change the name of isPrime do Prime, its a good code convention to put the name of class starting with Upper case. and isn't good the name of class equals to name of method.
    I suggest you to change the "static boolean isPrime (int n)" to "public boolean isPrime(int n)" to publish a method as a WebService method it's must be public and not static. After this change try to generate your Web Service.
    Regards.

  • Java Security Error while Launching the Application through JNLP

    Hi!,
    I have a problem in launching my Application through JNLP. It is giving the Error dialog as "Unable to lauch application" with the dialog title as "Java Security Error".
    I don't know why this problem is coming but when I have reset my profile on my system & then I tried to launch the same application & I got success.
    Can anyone suggest me what was the problem?
    Pradeep Gupta

    hi,
    usually it is the web dynpro launch system that is causing the issue, OR there is a misconfiguration in the backend like the tasks are set up with com.sap/esslea in the backend and the xml file is referencing sap.com <SWITCH>/esslea and the dynpro is showing this as not deployed.
    Regards
    Sharanya Rajagopal

  • Mail Receiver Error:  java.lang.IllegalArgumentException: can't parse argum

    Hi everybody,
    I get the error in mail receiver CC:
    java.lang.IllegalArgumentException: can't parse argument number
    My Payload looks like this:
    <?xml version="1.0" encoding="utf-8" ?>
    - <ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">
      <Subject>The subject</Subject>
      <From>mailadress</From>
      <To>mailadress</To>
      <Content_Type>multipart/mixed; boundary="AaBb--984dfgeSSd3532"</Content_Type>
    - <Content_Description>
      <attachment filename="Filename.txt">content_of_attachment</attachment>
      </Content_Description>
      <Content_Disposition>attachment</Content_Disposition>
      <Content>Constant</Content>
      </ns1:Mail>
    Any ideas?
    Regards
    Mario

    Hi Mario..
    Go thru this thread for it.
    Error Catagory : XI_J2EE_ADAPTER_MAIL
    Regards

  • Parse Error in Java

    I am very new to java and I have a piece of code which is written in javascript which i want to replicate in java basically it validates the structure of and XML Dom passed into it.
    function XMLParseError(XMLIsland, XMLName)
    if (XMLIsland.parseError.errorCode != 0)
    alert('XML Parse Error with ' + XMLName + '\n\nreason: ' +
    XMLIsland.parseError.reason +
    '\nline: ' + XMLIsland.parseError.line +
    '\npos: ' + XMLIsland.parseError.linepos +
    '\nsrcText:' + XMLIsland.parseError.srcText +
    '\nurl: ' + XMLIsland.parseError.url);
    in java i have
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    factory.setIgnoringComments(true); // We want to ignore comments
    // Now use the factory to create a DOM parser
    DocumentBuilder parser = factory.newDocumentBuilder();
    //final xml is an xml string
    xmldoc = parser.parse(new InputSource(new StringReader(finalXML)));
    if i want to catch the errors and print them to the screen similar to the javascript program how do i do this.....

    Create a class which extends the DefaultHandler(DefaultHanlder impleents the ErrorHandler interface)
    Set the ErrorHandler on the DocumentBuilder.
    builder.setErrorHandler(errorHandler);

  • Fail to Configure Java Security Module. JPS-10902:Enrollment Server Error.

    I am unable to configure my Java Security Module Client in Controlled Mode. Everytime, I attempt to run the config command, I get an JPS-10902:Enrollment Server Error.
    Note that, while I run the configure Client command, the OES Administration Server is running on the same machine listening at 7002 with the default username password "weblogic/welcome1" (tested to work as expected on the Server console).
    Any help on this issue is appreciated. Below are the values in the smconfig.prp file, the command at the console and the error message.
    Values in the smconfig.java.controlled.prp:
    ==========================
    oracle.security.jps.runtime.pd.client.policyDistributionMode=controlled-push
    oracle.security.jps.runtime.pd.client.RegistrationServerHost=localhost [I also tried using my hostname]
    oracle.security.jps.runtime.pd.client.RegistrationServerPort=7002
    oracle.security.jps.runtime.pd.client.sm_name=MySM_Java
    # >>>>>>>>>>>>OPTIONAL PARAMETERS<<<<<<<<<<<<<<<<<
    # ------------ Only for Java SM, WS SM, and RMI SM in controlled-push mode --------------------
    # port to listen for policy distribution. Picked automatically by SM config tool if not specified
    #Port value set by Premal. It a random number
    oracle.security.jps.runtime.pd.client.DistributionServicePort=
    oracle.security.jps.runtime.pd.client.sm_type=java
    The Config command issued at the console:
    ===========================
    C:\Oracle\Middleware\oes_client\oessm\bin>config.cmd -smConfigId MySM_Java -prpFileName C:\Oracle\Middleware\oes_client\oessm\SMConfigTool\smconfig.java.controlled.prp
    The resulting error message:
    ======================
    C:\Oracle\Middleware\oes_client\oessm\bin>config.cmd -smConfigId MySM_Java -prpFileName C:\Oracle\Middleware\oes_clien
    t\oessm\SMConfigTool\smconfig.java.controlled.prp
    Configuring for Controlled Policy Distribution Mode
    Security Module configuration is created at: C:\Oracle\MIDDLE~1\OES_CL~1\oes_sm_instances\MySM_Java_3
    Enter password for key stores:
    Enter password for key stores again:
    Passwords are saved in credential store.
    Keystores are initialized successfully.
    Please enter a value for OES Admin Server User name:weblogic
    Please enter a value for OES Admin Server Password:
    Please re-enter a value for OES Admin Server Password:
    oracle.security.jps.service.policystore.PolicyStoreException: JPS-10902: Enrollment server error.
    at oracle.security.oes.enroll.EnrollmentClient.readFromSocket(EnrollmentClient.java:236)
    at oracle.security.oes.enroll.EnrollmentClient.enroll(EnrollmentClient.java:166)
    at oracle.security.oes.enroll.EnrollmentClient.main(EnrollmentClient.java:491)
    at oracle.security.oes.tools.EnrollmentTool.doEnroll(EnrollmentTool.java:103)
    at oracle.security.oes.tools.SMConfigTool.doEnrollment(SMConfigTool.java:610)
    at oracle.security.oes.tools.SMConfigTool.run(SMConfigTool.java:381)
    at oracle.security.oes.tools.SMConfigTool.main(SMConfigTool.java:346)
    JPS-10902: Enrollment server error.
    Enrollment is not proceeded successfully.

    Hi,
    Perhaps oracle.oes.admin.enroll, oracle.oes.admin.psl.ssl are not successfully deployed to the admin server or both are not in active state.
    Please try to redeploy the oracle.oes.admin.enroll, oracle.oes.admin.psl.ssl to the admin server, and make sure these two are active state. Then the SM couls be configured without issues hopefully.
    Thanks,
    Cris

Maybe you are looking for

  • ORDERS Inbound EDI1 Condition type not getting updated

    Hi Experts,         As per the client requirement, during ORDERS Inbound process we need to capture the "Customer expected Price" in EDI1 Condition type in the sales order. So we maintained the details in the E1EDP01 in field VPREI. But during ORDERS

  • Tracking down mysterious reloads

    Hi, we have a client/server application using TopLink. Our data is some huge graph that is completely loaded into TopLink's instance cache at server startup. This takes a while and is perfectly ok as long as the clients get good response times afterw

  • Fms doesnt work when i give my external ip

    hi, i installed FMS 2 and find it very easy to record and publish video steam, it all works fine on my local computer. when i open the ports 1935 in my router and open the fire wall to it i am still unable to contact to the server from the web, i ins

  • Trouble Accessing my Wireless Network

    I have the older BEFW 11s4; it is hooked up to our Cable modem. We can see and connect to the router, but cannot get access to teh internet. Any suggestions or guidance to fix such an issue would be apprecaited. Thank you John Edmonton

  • My regular FTP site suddenly times out - after onl...

    Hi Not sure if this is the right forum but due to some problems I found myself unable to pay the monthly bill by the due date. After some time going round in circles with the famous auomated menus I managed to find a real person and explained the pro