Search in sources :

Example 16 with StatusType

use of org.apache.cxf.xkms.model.xkms.StatusType 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)

Example 17 with StatusType

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

the class XKMSService method createKeyBinding.

// TODO refactoring into factory class?
public static KeyBindingType createKeyBinding(ValidateResultType result) {
    KeyBindingType binding = new KeyBindingType();
    binding.setId(XKMSResponseFactory.generateUniqueID());
    result.getKeyBinding().add(binding);
    StatusType status = new StatusType();
    binding.setStatus(status);
    return binding;
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType) KeyBindingType(org.apache.cxf.xkms.model.xkms.KeyBindingType) UnverifiedKeyBindingType(org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)

Example 18 with StatusType

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

the class XKMSService method resolveValidationStatus.

/**
 * http://www.w3.org/TR/xkms2/#XKMS_2_0_Section_4_1 [206]
 *
 * If no (or indeterminate) reasons are present total status is INDETERMINATE.
 * If no invalid and indeterminate reasons are present status is VALID.
 * If invalid reasons are present status is INVALID.
 *
 * @param binding KeyBinding to check validation reasons for
 */
private void resolveValidationStatus(KeyBindingType binding) {
    StatusType status = binding.getStatus();
    status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INDETERMINATE);
    if (!status.getValidReason().isEmpty() && status.getIndeterminateReason().isEmpty()) {
        status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID);
    }
    if (!status.getInvalidReason().isEmpty()) {
        status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID);
        // Only return invalid reasons
        status.getValidReason().clear();
    }
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType)

Example 19 with StatusType

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

the class XKMSService method addValidationReasons.

private void addValidationReasons(KeyBindingType binding, StatusType status) {
    StatusType resultStatus = binding.getStatus();
    resultStatus.getValidReason().addAll(status.getValidReason());
    resultStatus.getInvalidReason().addAll(status.getInvalidReason());
    resultStatus.getIndeterminateReason().addAll(status.getIndeterminateReason());
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType)

Example 20 with StatusType

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

the class X509Register method prepareResponseBinding.

private KeyBindingType prepareResponseBinding(PrototypeKeyBindingType binding) {
    KeyBindingType responseBinding = new KeyBindingType();
    responseBinding.setKeyInfo(binding.getKeyInfo());
    StatusType status = new StatusType();
    status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID);
    responseBinding.setStatus(status);
    return responseBinding;
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType) PrototypeKeyBindingType(org.apache.cxf.xkms.model.xkms.PrototypeKeyBindingType) KeyBindingType(org.apache.cxf.xkms.model.xkms.KeyBindingType)

Aggregations

StatusType (org.apache.cxf.xkms.model.xkms.StatusType)24 Test (org.junit.Test)15 X509Certificate (java.security.cert.X509Certificate)12 BasicIntegrationTest (org.apache.cxf.xkms.itests.BasicIntegrationTest)9 ValidateRequestType (org.apache.cxf.xkms.model.xkms.ValidateRequestType)9 KeyBindingType (org.apache.cxf.xkms.model.xkms.KeyBindingType)3 UnverifiedKeyBindingType (org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)2 XKMSException (org.apache.cxf.xkms.exception.XKMSException)1 Validator (org.apache.cxf.xkms.handlers.Validator)1 KeyUsageEnum (org.apache.cxf.xkms.model.xkms.KeyUsageEnum)1 PrototypeKeyBindingType (org.apache.cxf.xkms.model.xkms.PrototypeKeyBindingType)1 ValidateResultType (org.apache.cxf.xkms.model.xkms.ValidateResultType)1