Search in sources :

Example 1 with ValidateResultType

use of org.apache.cxf.xkms.model.xkms.ValidateResultType in project cxf by apache.

the class XKMSInvoker method checkCertificateValidity.

protected boolean checkCertificateValidity(X509Certificate cert, boolean directTrust) {
    try {
        ValidateRequestType validateRequestType = prepareValidateXKMSRequest(cert);
        if (directTrust) {
            validateRequestType.getQueryKeyBinding().getKeyUsage().add(KeyUsageEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SIGNATURE);
        }
        ValidateResultType validateResultType = xkmsConsumer.validate(validateRequestType);
        String id = cert.getSubjectDN().getName();
        CertificateValidationResult result = parseValidateXKMSResponse(validateResultType, id);
        if (!result.isValid()) {
            LOG.warn(String.format("Certificate %s is not valid: %s", cert.getSubjectDN(), result.getDescription()));
        }
        return result.isValid();
    } catch (RuntimeException e) {
        String msg = String.format("XKMS validate call fails for certificate: %s. Error: %s", cert.getSubjectDN(), e.getMessage());
        LOG.warn(msg, e);
        throw new XKMSValidateException(msg, e);
    }
}
Also used : XKMSValidateException(org.apache.cxf.xkms.exception.XKMSValidateException) ValidateResultType(org.apache.cxf.xkms.model.xkms.ValidateResultType) ValidateRequestType(org.apache.cxf.xkms.model.xkms.ValidateRequestType)

Example 2 with ValidateResultType

use of org.apache.cxf.xkms.model.xkms.ValidateResultType in project cxf by apache.

the class XKMSService method validate.

@Override
public ValidateResultType validate(ValidateRequestType request) {
    ValidateResultType response = XKMSResponseFactory.createResponse(request, new ValidateResultType());
    try {
        validateRequest(request);
        // Create basic response
        KeyBindingType binding = createKeyBinding(response);
        // Validate request
        for (Validator validator : validators) {
            StatusType status = validator.validate(request);
            addValidationReasons(binding, status);
        }
        resolveValidationStatus(binding);
        return response;
    } catch (Exception e) {
        return handleException("recover", e, response);
    }
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType) ValidateResultType(org.apache.cxf.xkms.model.xkms.ValidateResultType) KeyBindingType(org.apache.cxf.xkms.model.xkms.KeyBindingType) UnverifiedKeyBindingType(org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType) Validator(org.apache.cxf.xkms.handlers.Validator)

Aggregations

ValidateResultType (org.apache.cxf.xkms.model.xkms.ValidateResultType)2 XKMSValidateException (org.apache.cxf.xkms.exception.XKMSValidateException)1 Validator (org.apache.cxf.xkms.handlers.Validator)1 KeyBindingType (org.apache.cxf.xkms.model.xkms.KeyBindingType)1 StatusType (org.apache.cxf.xkms.model.xkms.StatusType)1 UnverifiedKeyBindingType (org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)1 ValidateRequestType (org.apache.cxf.xkms.model.xkms.ValidateRequestType)1