Search in sources :

Example 1 with KeyBindingType

use of org.apache.cxf.xkms.model.xkms.KeyBindingType 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 2 with KeyBindingType

use of org.apache.cxf.xkms.model.xkms.KeyBindingType 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 3 with KeyBindingType

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

the class X509Register method register.

@Override
public RegisterResultType register(RegisterRequestType request, RegisterResultType response) {
    try {
        PrototypeKeyBindingType binding = request.getPrototypeKeyBinding();
        X509Utils.assertElementNotNull(binding, PrototypeKeyBindingType.class);
        KeyInfoType keyInfo = binding.getKeyInfo();
        X509Utils.assertElementNotNull(binding, KeyInfoType.class);
        List<UseKeyWithType> useKeyWithList = binding.getUseKeyWith();
        if (useKeyWithList == null || useKeyWithList.size() != 1) {
            throw new IllegalArgumentException("Exactly one useKeyWith element is supported");
        // TODO standard requires support for multiple useKeyWith attributes
        }
        UseKeyWithType useKeyWith = useKeyWithList.get(0);
        List<X509Certificate> certList = getCertsFromKeyInfo(keyInfo);
        if (certList.size() != 1) {
            throw new IllegalArgumentException("Must provide one X509Certificate");
        }
        X509Certificate cert = certList.get(0);
        certRepo.saveCertificate(cert, useKeyWith);
        KeyBindingType responseBinding = prepareResponseBinding(binding);
        response.getKeyBinding().add(responseBinding);
        return response;
    } catch (CertificateException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : PrototypeKeyBindingType(org.apache.cxf.xkms.model.xkms.PrototypeKeyBindingType) UseKeyWithType(org.apache.cxf.xkms.model.xkms.UseKeyWithType) CertificateException(java.security.cert.CertificateException) PrototypeKeyBindingType(org.apache.cxf.xkms.model.xkms.PrototypeKeyBindingType) KeyBindingType(org.apache.cxf.xkms.model.xkms.KeyBindingType) X509Certificate(java.security.cert.X509Certificate) KeyInfoType(org.apache.cxf.xkms.model.xmldsig.KeyInfoType)

Example 4 with KeyBindingType

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

KeyBindingType (org.apache.cxf.xkms.model.xkms.KeyBindingType)4 StatusType (org.apache.cxf.xkms.model.xkms.StatusType)3 PrototypeKeyBindingType (org.apache.cxf.xkms.model.xkms.PrototypeKeyBindingType)2 UnverifiedKeyBindingType (org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)2 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1 Validator (org.apache.cxf.xkms.handlers.Validator)1 UseKeyWithType (org.apache.cxf.xkms.model.xkms.UseKeyWithType)1 ValidateResultType (org.apache.cxf.xkms.model.xkms.ValidateResultType)1 KeyInfoType (org.apache.cxf.xkms.model.xmldsig.KeyInfoType)1