Search in sources :

Example 1 with LocateResultType

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

the class XKMSService method locate.

@Override
public LocateResultType locate(LocateRequestType request) {
    LocateResultType response = XKMSResponseFactory.createResponse(request, new LocateResultType());
    try {
        validateRequest(request);
        // Search
        for (Locator locator : locators) {
            UnverifiedKeyBindingType keyBinding = locator.locate(request);
            if (keyBinding != null) {
                response.getUnverifiedKeyBinding().add(keyBinding);
                return response;
            }
        }
        // No matches found
        response.setResultMinor(ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_NO_MATCH.value());
        return response;
    } catch (Exception e) {
        return handleException("locate", e, response);
    }
}
Also used : Locator(org.apache.cxf.xkms.handlers.Locator) LocateResultType(org.apache.cxf.xkms.model.xkms.LocateResultType) UnverifiedKeyBindingType(org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)

Example 2 with LocateResultType

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

the class X509Utils method createResponse.

LocateResultType createResponse(LocateRequestType request) {
    LocateResultType ret = new LocateResultType();
    ret.setId(UUID.randomUUID().toString());
    ret.setRequestId(request.getId());
    ret.setService("http://services.sopera.org/xkms/v2.0");
    return ret;
}
Also used : LocateResultType(org.apache.cxf.xkms.model.xkms.LocateResultType)

Example 3 with LocateResultType

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

the class XKMSInvoker method getCertificate.

public X509Certificate getCertificate(List<X509AppId> ids) {
    try {
        LocateRequestType locateRequestType = prepareLocateXKMSRequest(ids);
        LocateResultType locateResultType = xkmsConsumer.locate(locateRequestType);
        return parseLocateXKMSResponse(locateResultType, ids);
    } catch (RuntimeException e) {
        String msg = String.format("XKMS locate call fails for certificate: %s. Error: %s", ids, e.getMessage());
        LOG.warn(msg, e);
        throw new XKMSLocateException(msg, e);
    }
}
Also used : XKMSLocateException(org.apache.cxf.xkms.exception.XKMSLocateException) LocateResultType(org.apache.cxf.xkms.model.xkms.LocateResultType) LocateRequestType(org.apache.cxf.xkms.model.xkms.LocateRequestType)

Example 4 with LocateResultType

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

the class XKMSServiceTest method locateCertificate.

private void locateCertificate(LocateRequestType request, QueryKeyBindingType queryKeyBindingType, UseKeyWithType useKeyWithType) {
    queryKeyBindingType.getUseKeyWith().add(useKeyWithType);
    request.setQueryKeyBinding(queryKeyBindingType);
    LocateResultType result = xkmsService.locate(request);
    assertSuccess(result);
    List<UnverifiedKeyBindingType> keyBinding = result.getUnverifiedKeyBinding();
    Assert.assertEquals(1, keyBinding.size());
    KeyInfoType keyInfo = keyBinding.get(0).getKeyInfo();
    Assert.assertNotNull(keyInfo);
}
Also used : LocateResultType(org.apache.cxf.xkms.model.xkms.LocateResultType) UnverifiedKeyBindingType(org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType) KeyInfoType(org.apache.cxf.xkms.model.xmldsig.KeyInfoType)

Aggregations

LocateResultType (org.apache.cxf.xkms.model.xkms.LocateResultType)4 UnverifiedKeyBindingType (org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)2 XKMSLocateException (org.apache.cxf.xkms.exception.XKMSLocateException)1 Locator (org.apache.cxf.xkms.handlers.Locator)1 LocateRequestType (org.apache.cxf.xkms.model.xkms.LocateRequestType)1 KeyInfoType (org.apache.cxf.xkms.model.xmldsig.KeyInfoType)1