use of ee.ria.xroad.signer.protocol.dto.CertificateInfo in project X-Road by nordic-institute.
the class ClientServiceIntegrationTest method createComplexSignCertList.
/**
* local sign certificates for local clients:
* - FI:GOV:M1 has a sign cert "cert1" with ocsp status GOOD
* - FI:GOV:M1 has a sign cert "cert2" with ocsp status REVOKED
* ---> FI:GOV:M1 has both GOOD and REVOKED certs
* - FI:GOV:M2 has a sign cert "cert3" with ocsp status UNKNOWN
* - FI:DUMMY:M2 has a sign cert "cert4" with ocsp status REVOKED
* - DUMMY:PRO:M2 does not have any sign certs
*
* local sign certificates for global-only clients (not local clients of this SS):
* - EE:PRO:M1 has a sign cert "cert5" with ocsp status GOOD
* - EE:PRO:M2 has a sign cert "cert6" with ocsp status REVOKED
* - EE:PRO:M3 does not have any sign certs
*/
private List<CertificateInfo> createComplexSignCertList() {
// FI:GOV:M1 has a sign cert "cert1" with ocsp status GOOD
ClientId clientIdFiGovM1 = ClientId.create("FI", "GOV", "M1");
CertificateInfo cert1 = new CertificateTestUtils.CertificateInfoBuilder().clientId(clientIdFiGovM1).build();
// FI:GOV:M1 has a sign cert "cert2" with ocsp status REVOKED
CertificateInfo cert2 = new CertificateTestUtils.CertificateInfoBuilder().clientId(clientIdFiGovM1).ocspStatus(new RevokedStatus(new Date(), CRLReason.certificateHold)).build();
// FI:GOV:M2 has a sign cert "cert3" with ocsp status UNKNOWN
CertificateInfo cert3 = new CertificateTestUtils.CertificateInfoBuilder().clientId(ClientId.create("FI", "GOV", "M2")).ocspStatus(new UnknownStatus()).build();
// FI:DUMMY:M2 has a sign cert "cert4" with ocsp status REVOKED
CertificateInfo cert4 = new CertificateTestUtils.CertificateInfoBuilder().clientId(ClientId.create("FI", "DUMMY", "M2")).ocspStatus(new RevokedStatus(new Date(), CRLReason.certificateHold)).build();
// DUMMY:PRO:M2 does not have any sign certs
// EE:PRO:M1 has a sign cert "cert5" with ocsp status GOOD
CertificateInfo cert5 = new CertificateTestUtils.CertificateInfoBuilder().clientId(ClientId.create("EE", "PRO", "M1")).build();
// EE:PRO:M2 has a sign cert "cert6" with ocsp status REVOKED
CertificateInfo cert6 = new CertificateTestUtils.CertificateInfoBuilder().clientId(ClientId.create("EE", "PRO", "M2")).ocspStatus(new RevokedStatus(new Date(), CRLReason.certificateHold)).build();
return Arrays.asList(cert1, cert2, cert3, cert4, cert5, cert6);
}
use of ee.ria.xroad.signer.protocol.dto.CertificateInfo in project X-Road by nordic-institute.
the class OrphanRemovalServiceTest method isOrphanKey.
@Test
public void isOrphanKey() {
ClientId orphanMember = TestUtils.getClientId("FI:GOV:ORPHAN");
ClientId orphanSubsystemDeleted = TestUtils.getClientId("FI:GOV:ORPHAN:DELETED");
ClientId orphanSubsystemAlive = TestUtils.getClientId("FI:GOV:ORPHAN:ALIVE");
ClientId aliveMember = TestUtils.getClientId("FI:GOV:ALIVE");
CertificateInfo orphanMemberCert = new CertificateTestUtils.CertificateInfoBuilder().clientId(orphanMember).build();
CertRequestInfo orphanMemberCsr = new CertificateTestUtils.CertRequestInfoBuilder().clientId(orphanMember).build();
CertificateInfo orphanSubstemAliveCert = new CertificateTestUtils.CertificateInfoBuilder().clientId(orphanSubsystemAlive).build();
CertificateInfo aliveMemberCert = new CertificateTestUtils.CertificateInfoBuilder().clientId(aliveMember).build();
assertTrue(orphanRemovalService.isOrphanKey(new TokenTestUtils.KeyInfoBuilder().cert(orphanMemberCert).build(), orphanSubsystemDeleted));
assertFalse(orphanRemovalService.isOrphanKey(new TokenTestUtils.KeyInfoBuilder().cert(orphanMemberCert).build(), aliveMember));
assertTrue(orphanRemovalService.isOrphanKey(new TokenTestUtils.KeyInfoBuilder().csr(orphanMemberCsr).build(), orphanSubsystemDeleted));
assertFalse(orphanRemovalService.isOrphanKey(new TokenTestUtils.KeyInfoBuilder().build(), orphanSubsystemDeleted));
assertTrue(orphanRemovalService.isOrphanKey(new TokenTestUtils.KeyInfoBuilder().cert(orphanMemberCert).cert(orphanSubstemAliveCert).csr(orphanMemberCsr).build(), orphanSubsystemDeleted));
assertFalse(orphanRemovalService.isOrphanKey(new TokenTestUtils.KeyInfoBuilder().cert(orphanMemberCert).cert(orphanSubstemAliveCert).cert(aliveMemberCert).csr(orphanMemberCsr).build(), orphanSubsystemDeleted));
assertFalse(orphanRemovalService.isOrphanKey(new TokenTestUtils.KeyInfoBuilder().keyUsageInfo(KeyUsageInfo.AUTHENTICATION).cert(new CertificateTestUtils.CertificateInfoBuilder().clientId(null).build()).build(), orphanSubsystemDeleted));
}
use of ee.ria.xroad.signer.protocol.dto.CertificateInfo in project X-Road by nordic-institute.
the class PossibleActionsRuleEngineTest method createTestToken.
/**
* Create a specific token-key combination
*/
private TokenInfo createTestToken(boolean tokenSaved, boolean tokenReadOnly, boolean tokenActive, boolean keyNotSupported) {
CertificateInfo cert = new CertificateTestUtils.CertificateInfoBuilder().savedToConfiguration(tokenSaved).build();
String tokenId;
KeyUsageInfo usage;
if (keyNotSupported) {
tokenId = PossibleActionsRuleEngine.SOFTWARE_TOKEN_ID + 1;
usage = KeyUsageInfo.AUTHENTICATION;
} else {
tokenId = PossibleActionsRuleEngine.SOFTWARE_TOKEN_ID;
usage = KeyUsageInfo.AUTHENTICATION;
}
KeyInfo key = new TokenTestUtils.KeyInfoBuilder().keyUsageInfo(usage).cert(cert).build();
TokenInfo tokenInfo = new TokenTestUtils.TokenInfoBuilder().readOnly(tokenReadOnly).active(tokenActive).key(key).id(tokenId).build();
return tokenInfo;
}
use of ee.ria.xroad.signer.protocol.dto.CertificateInfo in project X-Road by nordic-institute.
the class ClientUtilsTest method hasValidLocalSignCertTest.
@Test
public void hasValidLocalSignCertTest() throws Exception {
// Valid sign cert found
ClientId clientId = ClientId.create("FI", "GOV", "M1");
assertTrue(ClientUtils.hasValidLocalSignCert(clientId, createCertificateInfoList()));
// No valid sign cert found
CertificateTestUtils.CertificateInfoBuilder certBuilder = new CertificateTestUtils.CertificateInfoBuilder();
certBuilder.ocspStatus(new UnknownStatus());
CertificateInfo cert = certBuilder.build();
assertFalse(ClientUtils.hasValidLocalSignCert(clientId, Collections.singletonList(cert)));
// Null ocsp response status – should return false
CertificateInfo nullCert = certBuilder.clientId(clientId).build();
ReflectionTestUtils.setField(nullCert, "ocspBytes", null);
assertFalse(ClientUtils.hasValidLocalSignCert(clientId, Collections.singletonList(nullCert)));
// No valid sign cert for the client
clientId = ClientId.create("FI", "GOV", "M2");
assertFalse(ClientUtils.hasValidLocalSignCert(clientId, createCertificateInfoList()));
}
use of ee.ria.xroad.signer.protocol.dto.CertificateInfo in project X-Road by nordic-institute.
the class ClientUtilsTest method createCertificateInfoList.
private List<CertificateInfo> createCertificateInfoList() {
List<CertificateInfo> certificateInfos = new ArrayList<>();
CertificateTestUtils.CertificateInfoBuilder certificateInfoBuilder = new CertificateTestUtils.CertificateInfoBuilder();
// Create cert with good ocsp response status
ClientId clientId1 = ClientId.create("FI", "GOV", "M1");
certificateInfoBuilder.clientId(clientId1);
CertificateInfo cert1 = certificateInfoBuilder.build();
// Create cert with revoked ocsp response status
certificateInfoBuilder.ocspStatus(new RevokedStatus(new Date(), CRLReason.certificateHold));
CertificateInfo cert2 = certificateInfoBuilder.build();
// Create cert with unknown ocsp response status
certificateInfoBuilder.ocspStatus(new UnknownStatus());
CertificateInfo cert3 = certificateInfoBuilder.build();
certificateInfos.addAll(Arrays.asList(cert2, cert3, cert1));
return certificateInfos;
}
Aggregations