当前位置: 首页>>代码示例>>Java>>正文


Java CertificateException类代码示例

本文整理汇总了Java中javax.security.cert.CertificateException的典型用法代码示例。如果您正苦于以下问题:Java CertificateException类的具体用法?Java CertificateException怎么用?Java CertificateException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CertificateException类属于javax.security.cert包,在下文中一共展示了CertificateException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: signRequest

import javax.security.cert.CertificateException; //导入依赖的package包/类
@Test
public void signRequest() throws JAXBException, ParserConfigurationException, CertificateException, KeyException, MarshalException, NoSuchAlgorithmException, SOAPException, XPathExpressionException, XMLSignatureException, InvalidAlgorithmParameterException, java.security.cert.CertificateException, NoSuchProviderException, KeyStoreException, IOException, UnrecoverableKeyException {
	Serializable payload = createRequest();

	SOAPMessage signedRequest = sign(
			marshall(
					payload,
					getMarshaller(payload.getClass())
			),
			getClient()
	);

	System.out.println("============ SIGNED SOAP MESSAGE ================");
	signedRequest.writeTo(System.out);
	System.out.println("\n=================================================");
}
 
开发者ID:AlnaSoftware,项目名称:eSaskaita,代码行数:17,代码来源:AbstractSignatureHelper.java

示例2: BasicSSLSessionInfo

import javax.security.cert.CertificateException; //导入依赖的package包/类
/**
 *
 * @param sessionId The SSL session ID
 * @param cypherSuite The cypher suite name
 * @param certificate A string representation of the client certificate
 * @throws java.security.cert.CertificateException If the client cert could not be decoded
 * @throws CertificateException If the client cert could not be decoded
 */
public BasicSSLSessionInfo(byte[] sessionId, String cypherSuite, String certificate) throws java.security.cert.CertificateException, CertificateException {
    this.sessionId = sessionId;
    this.cypherSuite = cypherSuite;

    if (certificate != null) {
        java.security.cert.CertificateFactory cf = java.security.cert.CertificateFactory.getInstance("X.509");
        byte[] certificateBytes = certificate.getBytes(US_ASCII);
        ByteArrayInputStream stream = new ByteArrayInputStream(certificateBytes);
        peerCertificate = cf.generateCertificate(stream);
        this.certificate = X509Certificate.getInstance(certificateBytes);
    } else {
        this.peerCertificate = null;
        this.certificate = null;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:BasicSSLSessionInfo.java

示例3: checkCertificates

import javax.security.cert.CertificateException; //导入依赖的package包/类
/**
 * Checks whether any active users' certificates are beyond the expiration threshold.
 */
@TransactionAttribute
public void checkCertificates() {

    List<UserAuthentication> auths = userAuthDao.findAll();

    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, configuration.getCertificateCheckThreshold());
    Date cutoff = cal.getTime();

    for (UserAuthentication auth : auths) {
        if (auth.getActive() && auth.getCertificate() != null) {
            try {
                X509Certificate certificate = X509Certificate
                        .getInstance(Base64.decodeBase64(auth.getCertificate()));
                if (cutoff.after(certificate.getNotAfter())) {
                    notifyExpirationCheckFail(auth.getUser().getUsername());
                }
            } catch (CertificateException e) {
                logger.warn("Certificate could not be read", e);
            }
        }
    }
}
 
开发者ID:psnc-dl,项目名称:darceo,代码行数:27,代码来源:CertificateChecker.java

示例4: getPeerCertificateChain

import javax.security.cert.CertificateException; //导入依赖的package包/类
@Override
public X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException {
    // these are lazy created to reduce memory overhead
    X509Certificate[] c = x509PeerCerts;
    if (c == null) {
        if (SSL.isInInit(ssl) != 0) {
            throw new SSLPeerUnverifiedException("peer not verified");
        }
        byte[][] chain = SSL.getPeerCertChain(ssl);
        if (chain == null) {
            throw new SSLPeerUnverifiedException("peer not verified");
        }
        X509Certificate[] peerCerts = new X509Certificate[chain.length];
        for (int i = 0; i < peerCerts.length; i++) {
            try {
                peerCerts[i] = X509Certificate.getInstance(chain[i]);
            } catch (CertificateException e) {
                throw new IllegalStateException(e);
            }
        }
        c = x509PeerCerts = peerCerts;
    }
    return c;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:25,代码来源:OpenSslEngine.java

示例5: confirmRegister

import javax.security.cert.CertificateException; //导入依赖的package包/类
@GET
@Path("register/confirm/{validationKey}")
public Response confirmRegister(@PathParam("validationKey") String validationKey, @Context HttpServletRequest req) {
  JsonResponse res = new JsonResponse();
  try {
    clusterController.validateRequest(validationKey, req, ClusterController.OP_TYPE.REGISTER);
  } catch (IOException | InterruptedException | CertificateException ex) {
    LOGGER.log(Level.SEVERE, null, ex);
    res.setStatusCode(Response.Status.BAD_REQUEST.getStatusCode());
    res.setSuccessMessage("Could not validate registration.");
    return Response.ok().entity(res).build();
  }
  res.setStatusCode(Response.Status.OK.getStatusCode());
  res.setSuccessMessage("Cluster registration validated.");
  return Response.ok().entity(res).build();
}
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:17,代码来源:Cluster.java

示例6: confirmUnregister

import javax.security.cert.CertificateException; //导入依赖的package包/类
@GET
@Path("unregister/confirm/{validationKey}")
public Response confirmUnregister(@PathParam("validationKey") String validationKey, @Context HttpServletRequest req) {
  JsonResponse res = new JsonResponse();
  try {
    clusterController.validateRequest(validationKey, req, ClusterController.OP_TYPE.UNREGISTER);
  } catch (IOException | InterruptedException | CertificateException ex) {
    LOGGER.log(Level.SEVERE, null, ex);
    res.setStatusCode(Response.Status.BAD_REQUEST.getStatusCode());
    res.setSuccessMessage("Could not validate unregistration.");
    return Response.ok().entity(res).build();
  }
  res.setStatusCode(Response.Status.OK.getStatusCode());
  res.setSuccessMessage("Cluster unregistration validated.");
  return Response.ok().entity(res).build();
}
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:17,代码来源:Cluster.java

示例7: parse

import javax.security.cert.CertificateException; //导入依赖的package包/类
public CertificateMeta parse() throws IOException, CertificateException {
  X509Certificate certificate = X509Certificate.getInstance(Utils.toByteArray(in));
  CertificateMeta.Builder builder = CertificateMeta.newCertificateMeta();
  byte[] bytes = certificate.getEncoded();
  String certMd5 = md5Digest(bytes);
  String publicKeyString = byteToHexString(bytes);
  String certBase64Md5 = md5Digest(publicKeyString);
  builder.data(bytes);
  builder.certBase64Md5(certBase64Md5);
  builder.certMd5(certMd5);
  builder.startDate(certificate.getNotBefore());
  builder.endDate(certificate.getNotAfter());
  builder.signAlgorithm(certificate.getSigAlgName());
  builder.signAlgorithmOID(certificate.getSigAlgOID());
  return builder.build();
}
 
开发者ID:jaredrummler,项目名称:APKParser,代码行数:17,代码来源:CertificateParser.java

示例8: parseCertificate

import javax.security.cert.CertificateException; //导入依赖的package包/类
private void parseCertificate() throws IOException, CertificateException {
  ZipEntry entry = null;
  Enumeration<? extends ZipEntry> enu = zipFile.entries();
  while (enu.hasMoreElements()) {
    ZipEntry ne = enu.nextElement();
    if (ne.isDirectory()) {
      continue;
    }
    if (ne.getName().toUpperCase().endsWith(".RSA") ||
        ne.getName().toUpperCase().endsWith(".DSA")) {
      entry = ne;
      break;
    }
  }
  if (entry == null) {
    throw new ParserException("ApkParser certificate not found");
  }
  InputStream in = zipFile.getInputStream(entry);
  CertificateParser parser = new CertificateParser(in);
  certificate = parser.parse();
  in.close();
}
 
开发者ID:jaredrummler,项目名称:APKParser,代码行数:23,代码来源:ApkParser.java

示例9: shouldFailWithInValidKeyAlias

import javax.security.cert.CertificateException; //导入依赖的package包/类
/**
 * Scenario:
 *   - Select invalid key alias (no such key).
 *   - Negotiation will fail
 * @throws CertificateException the certificate exception
 * @throws IOException the IO exception
 */
@Test
public void shouldFailWithInValidKeyAlias() throws CertificateException, IOException  {
    config.put(TLSOptions.TLS_TRUSTSTORE, getResourcePath("2waytest/basic_mutual_auth_2/gateway_ts.jks"));
    config.put(TLSOptions.TLS_TRUSTSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYSTORE, getResourcePath("2waytest/basic_mutual_auth_2/gateway_ks.jks"));
    config.put(TLSOptions.TLS_KEYSTOREPASSWORD, "password");
    config.put(TLSOptions.TLS_KEYPASSWORD, "password");
    config.put(TLSOptions.TLS_ALLOWANYHOST, "true");
    config.put(TLSOptions.TLS_ALLOWSELFSIGNED, "false");
    // No such key exists in the keystore
    config.put(TLSOptions.TLS_KEYALIASES, "xxx");

    HttpConnectorFactory factory = new HttpConnectorFactory(config);
    IApiConnector connector = factory.createConnector(request, api, RequiredAuthType.MTLS, false);
    IApiConnection connection = connector.connect(request,
            new IAsyncResultHandler<IApiConnectionResponse>() {

                @Override
                public void handle(IAsyncResult<IApiConnectionResponse> result) {
                    Assert.assertTrue(result.isError());
                }
            });

            connection.end();
}
 
开发者ID:apiman,项目名称:apiman,代码行数:33,代码来源:BasicMutualAuthTest.java

示例10: encryptAssertion

import javax.security.cert.CertificateException; //导入依赖的package包/类
private EncryptedAssertion encryptAssertion(final Assertion assertion) throws KeyStoreException, NoSuchAlgorithmException, CertificateException,
		IOException, SecurityException, EncryptionException, java.security.cert.CertificateException, NoSuchProviderException {
	Credential keyEncryptionCredential = MockIDPSPMetadata.getSpCredentials();

	EncryptionParameters encParams = new EncryptionParameters();
	encParams.setAlgorithm(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES128);

	KeyEncryptionParameters kekParams = new KeyEncryptionParameters();
	kekParams.setEncryptionCredential(keyEncryptionCredential);
	kekParams.setAlgorithm(EncryptionConstants.ALGO_ID_KEYTRANSPORT_RSA15);
	/*KeyInfoGeneratorFactory kigf = Configuration.getGlobalSecurityConfiguration().getKeyInfoGeneratorManager().getDefaultManager()
			.getFactory(keyEncryptionCredential);
	
	kekParams.setKeyInfoGenerator(kigf.newInstance());*/

	Encrypter samlEncrypter = new Encrypter(encParams, kekParams);
	samlEncrypter.setKeyPlacement(KeyPlacement.INLINE);

	return samlEncrypter.encrypt(assertion);

}
 
开发者ID:rasmusson,项目名称:MockIDP,代码行数:22,代码来源:MockIDPArtifactResolve.java

示例11: getIDPKeyFromKeystore

import javax.security.cert.CertificateException; //导入依赖的package包/类
private X509Credential getIDPKeyFromKeystore() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, SecurityException,
		java.security.cert.CertificateException {
	KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
	InputStream inputStream = MockIDPArtifactResolve.class.getResourceAsStream("/keystore-idp.jks");
	keystore.load(inputStream, "changeit".toCharArray());
	inputStream.close();

	Map<String, String> passwordMap = new HashMap<String, String>();
	passwordMap.put("test", "changeit");
	KeyStoreCredentialResolver resolver = new KeyStoreCredentialResolver(keystore, passwordMap);

	Criteria criteria = new EntityIDCriteria("test");
	CriteriaSet criteriaSet = new CriteriaSet(criteria);

	return (X509Credential)resolver.resolveSingle(criteriaSet);
}
 
开发者ID:rasmusson,项目名称:MockIDP,代码行数:17,代码来源:MockIDPArtifactResolve.java

示例12: getSSLContext

import javax.security.cert.CertificateException; //导入依赖的package包/类
private static SSLContext getSSLContext(File truststoreFile, String truststorePass) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException, UnrecoverableKeyException, KeyManagementException {
    SSLContext ctx;
    FileInputStream tsf = null;
    ctx = null;
    try {
        try {
            ctx = SSLContext.getInstance("SSL");
            tsf = new FileInputStream(truststoreFile);
            KeyStore ts = KeyStore.getInstance("JKS");
            ts.load(tsf, truststorePass.toCharArray());
            TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            tmf.init(ts);
            ctx.init(null, tmf.getTrustManagers(), new SecureRandom());
        }
        catch (Exception e) {
            logger.error("Problem encountered getting SSL Context " + e.getMessage(), e);
            if (tsf != null) {
                tsf.close();
            }
        }
    }
    finally {
        if (tsf != null) {
            tsf.close();
        }
    }
    return ctx;
}
 
开发者ID:bcolas,项目名称:pentaho-cassandra-plugin,代码行数:29,代码来源:CassandraConnection.java

示例13: decodeX509CertificateChain

import javax.security.cert.CertificateException; //导入依赖的package包/类
static X509Certificate[] decodeX509CertificateChain(byte[][] certChain)
        throws java.security.cert.CertificateException {
    CertificateFactory certificateFactory = getCertificateFactory();
    int numCerts = certChain.length;
    X509Certificate[] decodedCerts = new X509Certificate[numCerts];
    for (int i = 0; i < numCerts; i++) {
        decodedCerts[i] = decodeX509Certificate(certificateFactory, certChain[i]);
    }
    return decodedCerts;
}
 
开发者ID:google,项目名称:conscrypt,代码行数:11,代码来源:SSLUtils.java

示例14: getCertificateFactory

import javax.security.cert.CertificateException; //导入依赖的package包/类
private static CertificateFactory getCertificateFactory() {
    try {
        return CertificateFactory.getInstance("X.509");
    } catch (java.security.cert.CertificateException e) {
        return null;
    }
}
 
开发者ID:google,项目名称:conscrypt,代码行数:8,代码来源:SSLUtils.java

示例15: decodeX509Certificate

import javax.security.cert.CertificateException; //导入依赖的package包/类
private static X509Certificate decodeX509Certificate(CertificateFactory certificateFactory,
        byte[] bytes) throws java.security.cert.CertificateException {
    if (certificateFactory != null) {
        return (X509Certificate) certificateFactory.generateCertificate(
                new ByteArrayInputStream(bytes));
    }
    return OpenSSLX509Certificate.fromX509Der(bytes);
}
 
开发者ID:google,项目名称:conscrypt,代码行数:9,代码来源:SSLUtils.java


注:本文中的javax.security.cert.CertificateException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。