Search in sources :

Example 1 with UnverifiedKeyBindingType

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

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

the class X509Utils method getUnverifiedKeyBinding.

public static UnverifiedKeyBindingType getUnverifiedKeyBinding(X509Certificate cert) throws CertificateEncodingException {
    UnverifiedKeyBindingType unverifiedKeyBinding = new UnverifiedKeyBindingType();
    unverifiedKeyBinding.setKeyInfo(getKeyInfo(cert));
    return unverifiedKeyBinding;
}
Also used : UnverifiedKeyBindingType(org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)

Example 3 with UnverifiedKeyBindingType

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

the class X509LocatorTest method locate.

@Test
public void locate() throws CertificateException {
    CertificateRepo certRepo = EasyMock.createMock(CertificateRepo.class);
    EasyMock.expect(certRepo.findBySubjectDn(EasyMock.eq("alice"))).andReturn(getAliceCert());
    EasyMock.replay(certRepo);
    X509Locator locator = new X509Locator(certRepo);
    LocateRequestType request = prepareLocateXKMSRequest();
    UnverifiedKeyBindingType result = locator.locate(request);
    Assert.assertNotNull(result.getKeyInfo());
}
Also used : CertificateRepo(org.apache.cxf.xkms.x509.repo.CertificateRepo) LocateRequestType(org.apache.cxf.xkms.model.xkms.LocateRequestType) UnverifiedKeyBindingType(org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType) Test(org.junit.Test)

Example 4 with UnverifiedKeyBindingType

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

Example 5 with UnverifiedKeyBindingType

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

the class X509Locator method locate.

@Override
public UnverifiedKeyBindingType locate(LocateRequestType request) {
    List<UseKeyWithType> keyIDs = parse(request);
    X509Certificate cert;
    try {
        cert = findCertificate(keyIDs);
        if (cert == null) {
            return null;
        }
        UnverifiedKeyBindingType result = new UnverifiedKeyBindingType();
        result.setKeyInfo(X509Utils.getKeyInfo(cert));
        return result;
    } catch (CertificateEncodingException e) {
        throw new XKMSCertificateException("Cannot encode certificate: " + e.getMessage(), e);
    } catch (CertificateException e1) {
        throw new XKMSCertificateException(e1.getMessage(), e1);
    }
}
Also used : XKMSCertificateException(org.apache.cxf.xkms.exception.XKMSCertificateException) UseKeyWithType(org.apache.cxf.xkms.model.xkms.UseKeyWithType) CertificateEncodingException(java.security.cert.CertificateEncodingException) XKMSCertificateException(org.apache.cxf.xkms.exception.XKMSCertificateException) CertificateException(java.security.cert.CertificateException) X509Certificate(java.security.cert.X509Certificate) UnverifiedKeyBindingType(org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)

Aggregations

UnverifiedKeyBindingType (org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)5 LocateResultType (org.apache.cxf.xkms.model.xkms.LocateResultType)2 CertificateEncodingException (java.security.cert.CertificateEncodingException)1 CertificateException (java.security.cert.CertificateException)1 X509Certificate (java.security.cert.X509Certificate)1 XKMSCertificateException (org.apache.cxf.xkms.exception.XKMSCertificateException)1 Locator (org.apache.cxf.xkms.handlers.Locator)1 LocateRequestType (org.apache.cxf.xkms.model.xkms.LocateRequestType)1 UseKeyWithType (org.apache.cxf.xkms.model.xkms.UseKeyWithType)1 KeyInfoType (org.apache.cxf.xkms.model.xmldsig.KeyInfoType)1 CertificateRepo (org.apache.cxf.xkms.x509.repo.CertificateRepo)1 Test (org.junit.Test)1