Java Code Examples for java.security.cert.CertificateEncodingException#getMessage()

The following examples show how to use java.security.cert.CertificateEncodingException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpResponseCache.java    From cordova-amazon-fireos with Apache License 2.0 6 votes vote down vote up
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
  if (certificates == null) {
    writer.write("-1\n");
    return;
  }
  try {
    writer.write(Integer.toString(certificates.length) + '\n');
    for (Certificate certificate : certificates) {
      byte[] bytes = certificate.getEncoded();
      String line = Base64.encode(bytes);
      writer.write(line + '\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 2
Source File: HttpResponseCache.java    From bluemix-parking-meter with MIT License 6 votes vote down vote up
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
  if (certificates == null) {
    writer.write("-1\n");
    return;
  }
  try {
    writer.write(Integer.toString(certificates.length) + '\n');
    for (Certificate certificate : certificates) {
      byte[] bytes = certificate.getEncoded();
      String line = Base64.encode(bytes);
      writer.write(line + '\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 3
Source File: HttpResponseCache.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
    if (certificates == null) {
        writer.write("-1\n");
        return;
    }
    try {
        writer.write(Integer.toString(certificates.length) + '\n');
        for (Certificate certificate : certificates) {
            byte[] bytes = certificate.getEncoded();
            String line = Base64.encode(bytes);
            writer.write(line + '\n');
        }
    } catch (CertificateEncodingException e) {
        throw new IOException(e.getMessage());
    }
}
 
Example 4
Source File: HttpResponseCache.java    From crosswalk-cordova-android with Apache License 2.0 6 votes vote down vote up
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
  if (certificates == null) {
    writer.write("-1\n");
    return;
  }
  try {
    writer.write(Integer.toString(certificates.length) + '\n');
    for (Certificate certificate : certificates) {
      byte[] bytes = certificate.getEncoded();
      String line = Base64.encode(bytes);
      writer.write(line + '\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 5
Source File: HttpResponseCache.java    From wildfly-samples with MIT License 6 votes vote down vote up
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
  if (certificates == null) {
    writer.write("-1\n");
    return;
  }
  try {
    writer.write(Integer.toString(certificates.length) + '\n');
    for (Certificate certificate : certificates) {
      byte[] bytes = certificate.getEncoded();
      String line = Base64.encode(bytes);
      writer.write(line + '\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 6
Source File: AbstractOcspRequestor.java    From xipki with Apache License 2.0 6 votes vote down vote up
@Override
public OCSPResp ask(X509Cert issuerCert, X509Cert[] certs,
    URL responderUrl, RequestOptions requestOptions, ReqRespDebug debug)
    throws OcspResponseException, OcspRequestorException {
  Args.notNull(issuerCert, "issuerCert");
  Args.notNull(certs, "certs");
  Args.positive(certs.length, "certs.length");

  BigInteger[] serialNumbers = new BigInteger[certs.length];
  for (int i = 0; i < certs.length; i++) {
    X509Cert cert = certs[i];
    try {
      if (!X509Util.issues(issuerCert, cert)) {
        throw new IllegalArgumentException(
            "cert at index " + i + " and issuerCert do not match");
      }
    } catch (CertificateEncodingException ex) {
      throw new OcspRequestorException(ex.getMessage(), ex);
    }
    serialNumbers[i] = cert.getSerialNumber();
  }

  return ask(issuerCert, serialNumbers, responderUrl, requestOptions, debug);
}
 
Example 7
Source File: HttpResponseCache.java    From phonegap-plugin-loading-spinner with Apache License 2.0 6 votes vote down vote up
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
  if (certificates == null) {
    writer.write("-1\n");
    return;
  }
  try {
    writer.write(Integer.toString(certificates.length) + '\n');
    for (Certificate certificate : certificates) {
      byte[] bytes = certificate.getEncoded();
      String line = Base64.encode(bytes);
      writer.write(line + '\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 8
Source File: ResponseCacheMiddleware.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
    if (certificates == null) {
        writer.write("-1\n");
        return;
    }
    try {
        writer.write(Integer.toString(certificates.length) + '\n');
        for (Certificate certificate : certificates) {
            byte[] bytes = certificate.getEncoded();
            String line = Base64.encodeToString(bytes, Base64.DEFAULT);
            writer.write(line + '\n');
        }
    } catch (CertificateEncodingException e) {
        throw new IOException(e.getMessage());
    }
}
 
Example 9
Source File: SSLContextManager.java    From PADListener with GNU General Public License v2.0 6 votes vote down vote up
public String getFingerPrint(Certificate cert) throws KeyStoreException {
    if (!(cert instanceof X509Certificate)) return null;
    StringBuffer buff = new StringBuffer();
    X509Certificate x509 = (X509Certificate) cert;
    try {
        String fingerprint = Encoding.hashMD5(cert.getEncoded());
        for (int i=0; i<fingerprint.length(); i+=2) {
            buff.append(fingerprint.substring(i, i+1)).append(":");
        }
        buff.deleteCharAt(buff.length()-1);
    } catch (CertificateEncodingException e) {
        throw new KeyStoreException(e.getMessage());
    }
    String dn = x509.getSubjectDN().getName();
    _logger.info("Fingerprint is " + buff.toString().toUpperCase());
    return buff.toString().toUpperCase() + " " + dn;
}
 
Example 10
Source File: HttpResponseCache.java    From reader with MIT License 6 votes vote down vote up
private void writeCertArray(Writer writer, Certificate[] certificates) throws IOException {
  if (certificates == null) {
    writer.write("-1\n");
    return;
  }
  try {
    writer.write(Integer.toString(certificates.length) + '\n');
    for (Certificate certificate : certificates) {
      byte[] bytes = certificate.getEncoded();
      String line = Base64.encode(bytes);
      writer.write(line + '\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 11
Source File: X509Locator.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public UnverifiedKeyBindingType locate(LocateRequestType request) {
    List<UseKeyWithType> keyIDs = parse(request);
    X509Certificate cert;
    try {
        cert = findCertificate(keyIDs);
        if (cert == null) {
            return null;
        }
        UnverifiedKeyBindingType result = new UnverifiedKeyBindingType();
        result.setKeyInfo(X509Utils.getKeyInfo(cert));
        return result;
    } catch (CertificateEncodingException e) {
        throw new XKMSCertificateException("Cannot encode certificate: " + e.getMessage(), e);
    } catch (CertificateException e1) {
        throw new XKMSCertificateException(e1.getMessage(), e1);
    }
}
 
Example 12
Source File: AbstractOcspRequestor.java    From xipki with Apache License 2.0 6 votes vote down vote up
@Override
public OCSPResp ask(X509Cert issuerCert, X509Cert cert,
    URL responderUrl, RequestOptions requestOptions, ReqRespDebug debug)
    throws OcspResponseException, OcspRequestorException {
  Args.notNull(issuerCert, "issuerCert");
  Args.notNull(cert, "cert");

  try {
    if (!X509Util.issues(issuerCert, cert)) {
      throw new IllegalArgumentException("cert and issuerCert do not match");
    }
  } catch (CertificateEncodingException ex) {
    throw new OcspRequestorException(ex.getMessage(), ex);
  }

  return ask(issuerCert, new BigInteger[]{cert.getSerialNumber()}, responderUrl,
      requestOptions, debug);
}
 
Example 13
Source File: User.java    From ebics-java-client with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public byte[] getE002Certificate() throws EbicsException {
  try {
    return e002Certificate.getEncoded();
  } catch (CertificateEncodingException e) {
    throw new EbicsException(e.getMessage());
  }
}
 
Example 14
Source File: User.java    From ebics-java-client with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public byte[] getX002Certificate() throws EbicsException {
  try {
    return x002Certificate.getEncoded();
  } catch (CertificateEncodingException e) {
    throw new EbicsException(e.getMessage());
  }
}
 
Example 15
Source File: Cache.java    From styT with Apache License 2.0 5 votes vote down vote up
private void writeCertList(BufferedSink sink, List<Certificate> certificates)
    throws IOException {
  try {
    sink.writeDecimalLong(certificates.size())
        .writeByte('\n');
    for (int i = 0, size = certificates.size(); i < size; i++) {
      byte[] bytes = certificates.get(i).getEncoded();
      String line = ByteString.of(bytes).base64();
      sink.writeUtf8(line)
          .writeByte('\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 16
Source File: Cache.java    From AndroidProjects with MIT License 5 votes vote down vote up
private void writeCertList(BufferedSink sink, List<Certificate> certificates)
    throws IOException {
  try {
    sink.writeDecimalLong(certificates.size())
        .writeByte('\n');
    for (int i = 0, size = certificates.size(); i < size; i++) {
      byte[] bytes = certificates.get(i).getEncoded();
      String line = ByteString.of(bytes).base64();
      sink.writeUtf8(line)
          .writeByte('\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 17
Source File: ResponseHeaderRecord.java    From apollo-android with MIT License 5 votes vote down vote up
private void writeCertList(BufferedSink sink, List<Certificate> certificates)
    throws IOException {
  try {
    sink.writeDecimalLong(certificates.size())
        .writeByte('\n');
    for (int i = 0, size = certificates.size(); i < size; i++) {
      byte[] bytes = certificates.get(i).getEncoded();
      String line = ByteString.of(bytes).base64();
      sink.writeUtf8(line)
          .writeByte('\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 18
Source File: CertificateEncodingExceptionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Test for <code>CertificateEncodingException(Throwable)</code>
 * constructor Assertion: constructs CertificateEncodingException when
 * <code>cause</code> is not null
 */
public void testCertificateEncodingException05() {
    CertificateEncodingException tE = new CertificateEncodingException(
            tCause);
    if (tE.getMessage() != null) {
        String toS = tCause.toString();
        String getM = tE.getMessage();
        assertTrue("getMessage() should contain ".concat(toS), (getM
                .indexOf(toS) != -1));
    }
    assertNotNull("getCause() must not return null", tE.getCause());
    assertEquals("getCause() must return ".concat(tCause.toString()), tE
            .getCause(), tCause);
}
 
Example 19
Source File: ResponseHeaderRecord.java    From mobile-buy-sdk-android with MIT License 5 votes vote down vote up
private void writeCertList(BufferedSink sink, List<Certificate> certificates)
    throws IOException {
  try {
    sink.writeDecimalLong(certificates.size())
        .writeByte('\n');
    for (int i = 0, size = certificates.size(); i < size; i++) {
      byte[] bytes = certificates.get(i).getEncoded();
      String line = ByteString.of(bytes).base64();
      sink.writeUtf8(line)
          .writeByte('\n');
    }
  } catch (CertificateEncodingException e) {
    throw new IOException(e.getMessage());
  }
}
 
Example 20
Source File: STSServiceImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private Document generateToken(String requestTemplate, boolean sign, Credential headerCred, Credential hokCred, SAMLNameIdentifier nameIdentifier, String authmethod, List<SAMLAttribute> attributes, List<SAMLAttributeDesignator> designators, int validity) throws TechnicalConnectorException {
   try {
      String request = ConnectorXmlUtils.flatten(requestTemplate);
      request = this.processDefaultFields(request, validity, nameIdentifier);
      request = this.processHolderOfKeyCredentials(hokCred, request);
      request = StringUtils.replace(request, "${authenticationMethod}", authmethod);
      Element payload = ConnectorXmlUtils.toElement(request.getBytes(Charsets.UTF_8));
      Document doc = payload.getOwnerDocument();
      this.addDesignators(designators, doc);
      this.processAttributes(attributes, doc);
      boolean alwaysSign = Boolean.parseBoolean(ConfigFactory.getConfigValidator().getProperty("be.ehealth.technicalconnector.service.sts.always.sign.inner.request"));
      if (sign && (!headerCred.getCertificate().equals(hokCred.getCertificate()) || alwaysSign)) {
         try {
            String keyinfoType = ConfigFactory.getConfigValidator().getProperty("be.ehealth.technicalconnector.service.sts.keyinfo", "x509");
            if ("publickey".equalsIgnoreCase(keyinfoType)) {
               this.signRequest(doc.getDocumentElement(), hokCred.getPrivateKey(), hokCred.getPublicKey());
            } else {
               this.signRequest(doc.getDocumentElement(), hokCred.getPrivateKey(), hokCred.getCertificate());
            }
         } catch (Exception var15) {
            throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE, new Object[]{"XML signature error: " + var15.getMessage(), var15});
         }
      }

      return doc;
   } catch (CertificateEncodingException var16) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_CRYPTO, var16, new Object[]{var16.getMessage()});
   }
}