本文整理汇总了Java中sun.security.validator.ValidatorException类的典型用法代码示例。如果您正苦于以下问题:Java ValidatorException类的具体用法?Java ValidatorException怎么用?Java ValidatorException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidatorException类属于sun.security.validator包,在下文中一共展示了ValidatorException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkClientValidationFailure
import sun.security.validator.ValidatorException; //导入依赖的package包/类
/**
* Checks a validation failure to see if it failed for the reason we think
* it should. This comes in as an SSLException of some sort, but it
* encapsulates a ValidatorException which in turn encapsulates the
* CertPathValidatorException we are interested in.
*
* @param e the exception thrown at the top level
* @param reason the underlying CertPathValidatorException BasicReason
* we are expecting it to have.
*
* @return true if the reason matches up, false otherwise.
*/
static boolean checkClientValidationFailure(Exception e,
BasicReason reason) {
boolean result = false;
if (e instanceof SSLException) {
Throwable valExc = e.getCause();
if (valExc instanceof sun.security.validator.ValidatorException) {
Throwable cause = valExc.getCause();
if (cause instanceof CertPathValidatorException) {
CertPathValidatorException cpve =
(CertPathValidatorException)cause;
if (cpve.getReason() == reason) {
result = true;
}
}
}
}
return result;
}
示例2: checkTrustClient
import sun.security.validator.ValidatorException; //导入依赖的package包/类
/**
* Check if client is trusted (no support for custom here, only system/user)
* @param chain certificate chain
* @param authType type of authentification
* @param hostName hostnem
* @throws java.security.cert.CertificateException if certificate is wrong
*/
public void checkTrustClient(X509Certificate[] chain, String authType,
String hostName)
throws CertificateException {
boolean trusted = false;
ValidatorException savedException = null;
for (X509TrustManager clientTrustManager : clientTrustManagers) {
try {
clientTrustManager.checkClientTrusted(chain, authType);
trusted = true;
break;
}catch (ValidatorException caex) {
savedException = caex;
}
}
if (trusted) {
return;
}
throw savedException;
}
示例3: isExplicitlyTrusted
import sun.security.validator.ValidatorException; //导入依赖的package包/类
/**
* Return if the user explicitly trusted this i.e. in userTrustManager or temporarilyTrusted
*/
private boolean isExplicitlyTrusted(X509Certificate[] chain, String authType) {
boolean explicitlyTrusted = false;
for (X509TrustManager certTrustManager : certTrustManagers) {
try {
certTrustManager.checkServerTrusted(chain, authType);
explicitlyTrusted = true;
break;
}catch (ValidatorException uex) {
if (temporarilyTrusted.contains(chain[0])) {
explicitlyTrusted = true;
break;
}
}catch (CertificateException ce) {
// not explicitly trusted
}
}
return explicitlyTrusted;
}
示例4: validateCertChain
import sun.security.validator.ValidatorException; //导入依赖的package包/类
void validateCertChain(List<? extends Certificate> certs) throws Exception {
try {
Validator.getInstance(Validator.TYPE_PKIX,
Validator.VAR_CODE_SIGNING,
pkixParameters)
.validate(certs.toArray(new X509Certificate[certs.size()]));
} catch (Exception e) {
if (debug) {
e.printStackTrace();
}
if (e instanceof ValidatorException) {
// Throw cause if it's CertPathValidatorException,
if (e.getCause() != null &&
e.getCause() instanceof CertPathValidatorException) {
e = (Exception) e.getCause();
Throwable t = e.getCause();
if ((t instanceof CertificateExpiredException &&
hasExpiredCert) ||
(t instanceof CertificateNotYetValidException &&
notYetValidCert)) {
// we already have hasExpiredCert and notYetValidCert
return;
}
}
if (e instanceof ValidatorException) {
ValidatorException ve = (ValidatorException)e;
if (ve.getErrorType() == ValidatorException.T_EE_EXTENSIONS &&
(badKeyUsage || badExtendedKeyUsage || badNetscapeCertType)) {
// We already have badKeyUsage, badExtendedKeyUsage
// and badNetscapeCertType
return;
}
}
}
throw e;
}
}
示例5: isCertificateException
import sun.security.validator.ValidatorException; //导入依赖的package包/类
public static boolean isCertificateException(IOException e) {
return e.getCause() instanceof ValidatorException;
}