0

当我尝试生成代码时:

Certificate cert;

                InputStream path = new FileInputStream(TRUSTSTORE_LOCATION);
                KeyStore ks = KeyStore.getInstance("JKS");
                ks.load(path, TRUSTSTORE_PASS.toCharArray());

                // jak argument podaje sie certyfikat ktory jest zawarty w pliku trustory.jks
                cert = ks.getCertificate("xxxx");
                binarySecurityTokenElement.addTextNode(new BASE64Encoder().encode(cert.getEncoded()));
                //kpg = KeyPairGenerator.getInstance("DSA");
                kpg = KeyPairGenerator.getInstance("RSA");

输出是:

<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" 
                          Id="X509-7E20D88DE75F0EAADA137595678499810" 
                          ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3">
                                MIIDXDCCAkSgAwIBAgIEUFbpiDANBgkqhkiG9w0BAQUFADBwMQswCQYDVQQGEwJQTDEQMA4GA1UE&#13;
                                CBMHVW5rbm93bjENMAsGA1UEBxMETG9kejEVMBMGA1UEChMMQU1HLm5ldCBTLkEuMRUwEwYDVQQL&#13;
                        [...]

行尾是这个“ &#13;”,如何删除??

4

1 回答 1

1
Base64Converter base = new Base64Converter();
String encodeCertyficate = base.encode(cert.getEncoded());
encodeCertyficate = encodeCertyficate.replace("\r", "").replace("\n", "");
binarySecurityTokenElement.addTextNode(encodeCertyficate);
于 2013-08-20T09:53:38.827 回答