List of usage examples for java.security.cert X509Certificate toString
public abstract String toString();
From source file:org.opendaylight.snbi.southplugin.DomainInfo.java
public static void main(String args[]) { System.out.println("Init Start .."); CertRegistrar.INSTANCE.init();/* ww w . ja v a2 s .c o m*/ System.out.println("Init END .."); System.out.println("Testing the API's . START"); org.bouncycastle.pkcs.PKCS10CertificationRequest certRequest = SNBICAInterfaces.INSTANCE .generateCSRRequest(new String[] { "My Name", "Ericsson", "101" }); System.out.println("Created the CSR " + certRequest.toString()); X509Certificate certificate = SNBICAInterfaces.INSTANCE.generateX509Certificate(certRequest, null); System.out.println("Created the Certificate " + certificate.toString()); HashMap<String, String> certInfo = SNBICAInterfaces.INSTANCE.getCertificateInfo(certificate); System.out.println("Certificate Values "); for (Map.Entry<String, String> entry : certInfo.entrySet()) { System.out.println(entry.getKey() + " = " + entry.getValue()); } String alias = SNBICAInterfaces.INSTANCE.saveCertificate(certificate); System.out.println("Saved the certificate with alias = " + alias); X509Certificate savedCert = SNBICAInterfaces.INSTANCE.getSavedCertificate(alias); System.out.println("Retreived the Certificate " + savedCert.toString()); HashMap<String, String> savedCertInfo = SNBICAInterfaces.INSTANCE.getCertificateInfo(certificate); System.out.println("Saved Certificate Values "); for (Map.Entry<String, String> entry : savedCertInfo.entrySet()) { System.out.println(entry.getKey() + " = " + entry.getValue()); } byte[] data = { 10, 20, 30 }; byte[] hashData = SNBICAInterfaces.INSTANCE.generateSignature(data, null, CertManagerConstants.CERT_ALGORITHM.SHA1withRSA.toString()); System.out.println("Hash code for data is " + data.toString()); byte[] data1 = { 10, 20, 30 }; byte[] data2 = { 10, 20, 30, 40 }; boolean dataSame1 = SNBICAInterfaces.INSTANCE.verifySignature(data1, hashData, null, CertManagerConstants.CERT_ALGORITHM.SHA1withRSA.toString()); System.out.println(" Data Same = " + dataSame1); boolean dataSame2 = SNBICAInterfaces.INSTANCE.verifySignature(data2, hashData, null, CertManagerConstants.CERT_ALGORITHM.SHA1withRSA.toString()); System.out.println(" Data Same = " + dataSame2); System.out.println("Testing the API's . END"); }
From source file:fi.vm.kapa.identification.shibboleth.extauthn.util.CertificateUtil.java
public static boolean checkSignature(String data, String signature, X509Certificate cert) { boolean result = false; try {// www . ja v a 2 s . com logger.debug("checkSignature: data={}, signature={}, cert={}", data, signature, cert.toString()); byte[] sigToVerify = Base64.getDecoder().decode(signature); Signature sig = Signature.getInstance("SHA256withRSA"); sig.initVerify(cert); sig.update(Base64.getDecoder().decode(data)); result = sig.verify(sigToVerify); } catch (Exception e) { logger.warn("checkSignature: Got exception " + e.getClass(), e); } return result; }
From source file:be.fedict.eid.applet.service.JSONServlet.java
private static JSONObject createCertJSONObject(X509Certificate certificate, SimpleDateFormat simpleDateFormat) throws CertificateEncodingException, IOException { JSONObject certJSONObject = new JSONObject(); certJSONObject.put("subject", certificate.getSubjectX500Principal().toString()); certJSONObject.put("issuer", certificate.getIssuerX500Principal().toString()); certJSONObject.put("serialNumber", certificate.getSerialNumber().toString()); certJSONObject.put("notBefore", certificate.getNotBefore().toString()); certJSONObject.put("notAfter", certificate.getNotAfter().toString()); certJSONObject.put("signatureAlgo", certificate.getSigAlgName()); certJSONObject.put("thumbprint", DigestUtils.shaHex(certificate.getEncoded())); certJSONObject.put("details", certificate.toString()); certJSONObject.put("pem", toPem(certificate)); return certJSONObject; }
From source file:ch.cyberduck.cli.TerminalCertificateStore.java
@Override public boolean display(final List<X509Certificate> certificates) { for (X509Certificate c : certificates) { console.printf("%n%s", c.toString()); }/*from w w w. ja v a2 s . co m*/ return true; }
From source file:com.jonbanjo.cupsprint.CertificateActivity.java
private void displayCert(final String alias) { X509Certificate cert; try {/*w w w .ja v a 2 s . co m*/ cert = (X509Certificate) trustStore.getCertificate(alias); } catch (KeyStoreException e) { showToast(e.toString()); return; } String certString = cert.toString(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Certificate").setMessage(certString) .setPositiveButton("Remove", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeCert(alias); } }).setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog dialog = builder.create(); dialog.show(); }
From source file:com.aaasec.sigserv.cssigapp.KeyStoreFactory.java
public X509Certificate generateV1Certificate(String subject, char[] ksPass, KeyStore keyStore) throws OperatorCreationException, IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException { KeyPair pair = generateKeyPair(); BigInteger certSerial = BigInteger.valueOf(System.currentTimeMillis()); X500Name issuerDN = new X500Name("CN=" + subject); X500Name subjectDN = new X500Name("CN=" + subject); Date notBefore = new Date(System.currentTimeMillis() - 10000); Date notAfter = new Date(System.currentTimeMillis() + 10000); PublicKey pubKey = (pair.getPublic()); X509v1CertificateBuilder certGen = new JcaX509v1CertificateBuilder(issuerDN, certSerial, notBefore, notAfter, subjectDN, pubKey); ContentSigner signer = new JcaContentSignerBuilder("SHA1withRSA").build(pair.getPrivate()); byte[] encoded = certGen.build(signer).getEncoded(); CertificateFactory fact = CertificateFactory.getInstance("X.509"); InputStream is = new ByteArrayInputStream(encoded); X509Certificate generateCertificate = (X509Certificate) fact.generateCertificate(is); is.close();/*from w w w . j a v a 2 s . c om*/ // set the CA cert as trusted root X509Certificate[] chain = new X509Certificate[] { generateCertificate }; addToKeyStore(pair, chain, K_NAME, keyStore, ksPass); String certStr = generateCertificate.toString(); return generateCertificate; }
From source file:com.brobwind.brodm.DeviceActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.device);// www. ja v a2 s. c o m startService(new Intent(this, NetworkService.class)); mKit = new Kit(); Intent intent = getIntent(); mIpAddr = intent.getStringExtra(STR_IP); mPort = intent.getIntExtra(STR_PORT, -1); SharedPreferences.Editor editor = getSharedPreferences(STR_PREF, MODE_PRIVATE).edit(); editor.putString(STR_IP, mIpAddr); editor.putInt(STR_PORT, mPort); editor.commit(); TextView statusTv = (TextView) findViewById(R.id.status); statusTv.setText(mIpAddr + ":" + mPort); // /privet/info mTryInfo = (Button) findViewById(R.id.try_info); mTryInfo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNetService.deviceInfo(mIpAddr, mPort, new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mInfo, msg, error)) return; int securePort = -1; try { JSONObject target = new JSONObject(msg); JSONObject endpoints = target.getJSONObject("endpoints"); securePort = endpoints.getInt("httpsPort"); } catch (JSONException e) { e.printStackTrace(); } mNetService.init(mIpAddr, mPort, securePort, new NetworkUtils.Callback() { @Override public void onCertAvailable(X509Certificate chains[], String authType) { final StringBuilder sb = new StringBuilder(); for (X509Certificate chain : chains) { sb.append(chain.toString()); } runOnUiThread(new Runnable() { @Override public void run() { mCert.setText(sb.toString()); } }); } }); runOnUiThread(new Runnable() { @Override public void run() { enableFuncs(mFuncInfo, null /*mFuncPairing*/); mInfo.setText(msg); } }); } }); } }); mInfo = (TextView) findViewById(R.id.info); // CERT: /privet/info mTryCert = (Button) findViewById(R.id.try_cert); mTryCert.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNetService.fetchCert("/privet/info", new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { Toast.makeText(DeviceActivity.this, "Web server certificate fetched!", Toast.LENGTH_SHORT) .show(); } }); } }); mCert = (TextView) findViewById(R.id.cert); // /privet/v3/pairing/start mTryPairingStart = (Button) findViewById(R.id.try_pairing_start); mTryPairingStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNetService.pairingStart("/privet/v3/pairing/start", new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mPairingStart, msg, error)) return; try { JSONObject target = new JSONObject(msg); String id = target.getString("sessionId"); String devCmt = target.getString("deviceCommitment"); mKit.create("hello", id, devCmt); } catch (JSONException e) { e.printStackTrace(); } runOnUiThread(new Runnable() { @Override public void run() { // enableFuncs(mFuncPairing, new Button[] { mTryAuth} ); mPairingStart.setText(msg); } }); } }); } }); mPairingStart = (TextView) findViewById(R.id.pairing_start); // /privet/v3/pairing/confirm mTryPairingConfirm = (Button) findViewById(R.id.try_pairing_confirm); mTryPairingConfirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNetService.pairingConfirm("/privet/v3/pairing/confirm", mKit.getId(), mKit.getCliCmt(), new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mPairingConfirm, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { // enableFuncs(new Button[] { mTryAuth }, null); mPairingConfirm.setText(msg); } }); } }); } }); mPairingConfirm = (TextView) findViewById(R.id.pairing_confirm); // /privet/v3/pairing/cancel mTryPairingCancel = (Button) findViewById(R.id.try_pairing_cancel); mTryPairingCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNetService.pairingCancel("/privet/v3/pairing/cancel", mKit.getId(), new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mPairingStart, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { mPairingCancel.setText(msg); } }); } }); } }); mPairingCancel = (TextView) findViewById(R.id.pairing_cancel); // /privet/v3/auth mTryAuth = (Button) findViewById(R.id.try_auth); mTryAuth.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNetService.startAuth("/privet/v3/auth", mKit.getId(), mKit.getAuthCode(), new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mPairingStart, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { mAuth.setText(msg); } }); try { JSONObject target = new JSONObject(msg); mAccessToken = target.getString("accessToken"); } catch (JSONException e) { e.printStackTrace(); } } }); } }); mAuth = (TextView) findViewById(R.id.auth); // /privet/v3/traits mTryTraits = (Button) findViewById(R.id.try_traits); mTryTraits.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNetService.showTraits("/privet/v3/traits", mAccessToken, new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mTraits, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { mTraits.setText(msg); } }); } }); } }); mTraits = (TextView) findViewById(R.id.traits); // /privet/v3/components mTryComponents = (Button) findViewById(R.id.try_components); mTryComponents.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mNetService.showComponents("/privet/v3/components", mAccessToken, new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mComponents, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { mComponents.setText(msg); } }); } }); } }); mComponents = (TextView) findViewById(R.id.components); // /privet/v3/state mTryState = (Button) findViewById(R.id.try_state); mTryState.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String cmd = "{}"; mNetService.showCommand("/privet/v3/state", mAccessToken, cmd, new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mCmdInfo, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { mCmdInfo.setText(msg); } }); } }); } }); // /privet/v3/commandDefs mTryCmdDefs = (Button) findViewById(R.id.try_cmd_defs); mTryCmdDefs.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String cmd = "{}"; mNetService.showCommand("/privet/v3/commandDefs", mAccessToken, cmd, new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mCmdInfo, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { mCmdInfo.setText(msg); } }); } }); } }); // /privet/v3/command/status mTryCmdStatus = (Button) findViewById(R.id.try_cmd_status); mTryCmdStatus.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String cmd = "{}"; mNetService.showCommand("/privet/v3/commands/status", mAccessToken, cmd, new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mCmdInfo, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { mCmdInfo.setText(msg); } }); } }); } }); // /privet/v3/command/list mTryCmdList = (Button) findViewById(R.id.try_cmd_list); mTryCmdList.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String cmd = "{}"; mNetService.showCommand("/privet/v3/commands/list", mAccessToken, cmd, new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mCmdInfo, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { mCmdInfo.setText(msg); } }); } }); } }); mCmdInfo = (TextView) findViewById(R.id.cmd_info); // /privet/v3/command/exectue mTryCmdExec = (Button) findViewById(R.id.try_cmd_exec); mTryCmdExec.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String cmd = ((CharSequence) mCmd.getText()).toString(); mNetService.showCommand("/privet/v3/commands/execute", mAccessToken, cmd, new NetworkUtils.OnMessage() { @Override public void onMessage(final String msg, String error) { if (notifyError(mCmdExec, msg, error)) return; runOnUiThread(new Runnable() { @Override public void run() { mCmdExec.setText(msg); } }); } }); } }); mCmd = (EditText) findViewById(R.id.cmd); mCmd.setText(/* "{\n" + " \"component\": \"_ledflasher\",\n" + " \"name\": \"_ledflasher.set\",\n" + " \"parameters\": {\n" + " \"led\": 2,\n" + " \"on\": true\n" + " }\n" + "}" */ "{\n" + " \"name\": \"_ledflasher.animate\",\n" + " \"parameters\": {\n" + " \"duration\": 0.2,\n" + " \"type\": \"marquee_left\"\n" + " }\n" + "}"); mCmdExec = (TextView) findViewById(R.id.cmd_exec); mFuncAll = new Button[] { mTryInfo, mTryCert, mTryPairingStart, mTryPairingConfirm, mTryPairingCancel, mTryAuth, mTryTraits, mTryComponents, mTryState, mTryCmdDefs, mTryCmdStatus, mTryCmdList, mTryCmdExec, }; mFuncInfo = new Button[] { mTryCert, mTryPairingStart, mTryPairingConfirm, mTryPairingCancel, mTryAuth, mTryTraits, mTryComponents, mTryState, mTryCmdDefs, mTryCmdStatus, mTryCmdList, mTryCmdExec, }; mFuncPairing = new Button[] { mTryPairingConfirm, mTryPairingCancel, mTryAuth }; }
From source file:org.ejbca.ui.web.RequestHelper.java
/** * Handles Firefox certificate request (KEYGEN), these are constructed as: <code> * SignedPublicKeyAndChallenge ::= SEQUENCE { publicKeyAndChallenge PublicKeyAndChallenge, * signatureAlgorithm AlgorithmIdentifier, signature BIT STRING }</code> PublicKey's * encoded-format has to be RSA X.509./* w w w . j av a 2 s .c om*/ * * @param signsession EJB session to signature bean. * @param reqBytes buffer holding te request from NS. * @param username username in EJBCA for authoriation. * @param password users password for authorization. * * @return byte[] containing DER-encoded certificate. * * @throws CesecoreException * @throws AuthorizationDeniedException * @throws EjbcaException * @throws CADoesntExistsException * @throws ObjectNotFoundException * @throws CertificateEncodingException * @throws NoSuchProviderException * @throws SignatureException * @throws NoSuchAlgorithmException * @throws InvalidKeyException */ public byte[] nsCertRequest(SignSessionLocal signsession, byte[] reqBytes, String username, String password) throws ObjectNotFoundException, CADoesntExistsException, EjbcaException, AuthorizationDeniedException, CesecoreException, CertificateEncodingException, InvalidKeyException, NoSuchAlgorithmException, SignatureException, NoSuchProviderException { byte[] buffer = Base64.decode(reqBytes); if (buffer == null) { return null; } ASN1InputStream in = new ASN1InputStream(new ByteArrayInputStream(buffer)); ASN1Sequence spkac; try { spkac = (ASN1Sequence) in.readObject(); in.close(); } catch (IOException e) { throw new IllegalStateException("Unexpected IOException was caught.", e); } NetscapeCertRequest nscr = new NetscapeCertRequest(spkac); // Verify POPO, we don't care about the challenge, it's not important. nscr.setChallenge("challenge"); if (nscr.verify("challenge") == false) { throw new SignRequestSignatureException( "Invalid signature in NetscapeCertRequest, popo-verification failed."); } if (log.isDebugEnabled()) { log.debug("POPO verification successful"); } X509Certificate cert = (X509Certificate) signsession.createCertificate(administrator, username, password, nscr.getPublicKey()); if (log.isDebugEnabled()) { log.debug("Created certificate for " + username); } if (debug != null) { debug.print("<h4>Generated certificate:</h4>"); debug.printInsertLineBreaks(cert.toString().getBytes()); } return cert.getEncoded(); /* ECA-2065: the <keygen> specification doesn't say anything about the * returned certificate. Originally EJBCA used a PKCS7 container but * this has proved to be incompatible with Safari and Chrome. ECA-2065 * changes returned data to just a DER-encoded certificate which has * been verified to work in Firefox, Chrome and Safari. The mime-type * remains application/x-x509-user-certificate. Below is the deleted * code: // Don't include certificate chain in the PKCS7 to Firefox byte[] pkcs7 = signsession.createPKCS7(administrator, cert, false); log.debug("Created certificate (PKCS7) for " + username); if (debug != null) { debug.print("<h4>Generated certificate:</h4>"); debug.printInsertLineBreaks(cert.toString().getBytes()); } return pkcs7; */ }
From source file:com.google.u2f.server.impl.U2FServerReferenceImpl.java
@Override public SecurityKeyData processRegistrationResponse(RegistrationResponse registrationResponse, long currentTimeInMillis) throws U2FException { Log.info(">> processRegistrationResponse"); String sessionId = registrationResponse.getSessionId(); String clientDataBase64 = registrationResponse.getClientData(); String rawRegistrationDataBase64 = registrationResponse.getRegistrationData(); Log.info(">> rawRegistrationDataBase64: " + rawRegistrationDataBase64); EnrollSessionData sessionData = dataStore.getEnrollSessionData(sessionId); if (sessionData == null) { throw new U2FException("Unknown session_id"); }//from ww w . java 2 s .c o m String appId = sessionData.getAppId(); String clientData = new String(Base64.decodeBase64(clientDataBase64)); byte[] rawRegistrationData = Base64.decodeBase64(rawRegistrationDataBase64); Log.info("-- Input --"); Log.info(" sessionId: " + sessionId); Log.info(" challenge: " + Hex.encodeHexString(sessionData.getChallenge())); Log.info(" accountName: " + sessionData.getAccountName()); Log.info(" clientData: " + clientData); Log.info(" rawRegistrationData: " + Hex.encodeHexString(rawRegistrationData)); RegisterResponse registerResponse = RawMessageCodec.decodeRegisterResponse(rawRegistrationData); byte[] userPublicKey = registerResponse.getUserPublicKey(); byte[] keyHandle = registerResponse.getKeyHandle(); X509Certificate attestationCertificate = registerResponse.getAttestationCertificate(); byte[] signature = registerResponse.getSignature(); List<Transports> transports = null; try { transports = U2fAttestation.Parse(attestationCertificate).getTransports(); } catch (CertificateParsingException e) { Log.warning("Could not parse transports extension " + e.getMessage()); } Log.info("-- Parsed rawRegistrationResponse --"); Log.info(" userPublicKey: " + Hex.encodeHexString(userPublicKey)); Log.info(" keyHandle: " + Hex.encodeHexString(keyHandle)); Log.info(" attestationCertificate: " + attestationCertificate.toString()); Log.info(" transports: " + transports); try { Log.info(" attestationCertificate bytes: " + Hex.encodeHexString(attestationCertificate.getEncoded())); } catch (CertificateEncodingException e) { throw new U2FException("Cannot encode certificate", e); } Log.info(" signature: " + Hex.encodeHexString(signature)); byte[] appIdSha256 = crypto.computeSha256(appId.getBytes()); byte[] clientDataSha256 = crypto.computeSha256(clientData.getBytes()); byte[] signedBytes = RawMessageCodec.encodeRegistrationSignedBytes(appIdSha256, clientDataSha256, keyHandle, userPublicKey); Set<X509Certificate> trustedCertificates = dataStore.getTrustedCertificates(); if (!trustedCertificates.contains(attestationCertificate)) { Log.warning("attestion cert is not trusted"); } verifyBrowserData(new JsonParser().parse(clientData), "navigator.id.finishEnrollment", sessionData); Log.info("Verifying signature of bytes " + Hex.encodeHexString(signedBytes)); if (!crypto.verifySignature(attestationCertificate, signedBytes, signature)) { throw new U2FException("Signature is invalid"); } // The first time we create the SecurityKeyData, we set the counter value to 0. // We don't actually know what the counter value of the real device is - but it will // be something bigger (or equal) to 0, so subsequent signatures will check out ok. SecurityKeyData securityKeyData = new SecurityKeyData(currentTimeInMillis, transports, keyHandle, userPublicKey, attestationCertificate, /* initial counter value */ 0); dataStore.addSecurityKeyData(sessionData.getAccountName(), securityKeyData); Log.info("<< processRegistrationResponse"); return securityKeyData; }
From source file:org.tolven.security.bean.DocProtectionBean.java
public String getDocumentSignaturesString(DocBase docBase, AccountUser activeAccountUser, PrivateKey userPrivateKey) { String select = "SELECT sig FROM DocumentSignature sig WHERE sig.docBase = :docBase"; Query query = em.createQuery(select); query.setParameter("docBase", docBase); List<DocumentSignature> documentSignatures = query.getResultList(); StringBuffer buff = new StringBuffer(); X509Certificate x509Certificate = null; for (DocumentSignature documentSignature : documentSignatures) { x509Certificate = CertificateHelper.getX509Certificate(documentSignature.getCertificate()); boolean verified = false; verified = verify(documentSignature, x509Certificate, activeAccountUser, userPrivateKey); if (verified) { buff.append(VERIFIED);/*from ww w . j ava 2 s. c om*/ } else { buff.append(VERIFICATION_FAILED); } buff.append("\nDate signed: "); buff.append(documentSignature.getTimestamp()); buff.append("\n -- Signature -- \n"); buff.append(new String(encodeBase64Chunked(documentSignature.getSignature()))); buff.append("\n -- End Signature --\n"); buff.append("\n"); buff.append("Signed by: "); buff.append(x509Certificate.toString()); buff.append("\n"); } return buff.toString(); }