use of ee.ria.xroad.signer.protocol.dto.CertRequestInfo 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.CertRequestInfo in project X-Road by nordic-institute.
the class TokenCertificateService method getPossibleActionsForCsr.
/**
* Return possible actions for one csr
* Key not found exceptions are wrapped as RuntimeExceptions
* since them happening is considered to be internal error.
* @throws CertificateNotFoundException
*/
public EnumSet<PossibleActionEnum> getPossibleActionsForCsr(String csrId) throws CsrNotFoundException {
TokenInfoAndKeyId tokenInfoAndKeyId = null;
try {
tokenInfoAndKeyId = tokenService.getTokenAndKeyIdForCertificateRequestId(csrId);
} catch (KeyNotFoundException e) {
throw new RuntimeException("internal error", e);
}
TokenInfo tokenInfo = tokenInfoAndKeyId.getTokenInfo();
KeyInfo keyInfo = tokenInfoAndKeyId.getKeyInfo();
CertRequestInfo certRequestInfo = getCsr(keyInfo, csrId);
EnumSet<PossibleActionEnum> possibleActions = possibleActionsRuleEngine.getPossibleCsrActions(tokenInfo);
return possibleActions;
}
use of ee.ria.xroad.signer.protocol.dto.CertRequestInfo in project X-Road by nordic-institute.
the class KeyConverterTest method convert.
@Test
public void convert() throws Exception {
List<CertificateInfo> certs = new ArrayList<>();
certs.add(new CertificateTestUtils.CertificateInfoBuilder().build());
List<CertRequestInfo> csrs = new ArrayList<>();
csrs.add(new CertRequestInfo("id", ClientId.create("a", "b", "c"), "sujbect-name"));
KeyInfo info = new KeyInfo(true, KeyUsageInfo.SIGNING, "friendly-name", "id", "label", "public-key", certs, csrs, "sign-mechanism-name");
Key key = keyConverter.convert(info);
assertEquals(true, key.getAvailable());
assertNotNull(key.getCertificates());
assertEquals(1, key.getCertificates().size());
assertNotNull(key.getCertificateSigningRequests());
assertEquals(1, key.getCertificateSigningRequests().size());
assertEquals("id", key.getId());
assertEquals("label", key.getLabel());
assertEquals("friendly-name", key.getName());
assertEquals(true, key.getSavedToConfiguration());
assertEquals(KeyUsageType.SIGNING, key.getUsage());
}
use of ee.ria.xroad.signer.protocol.dto.CertRequestInfo in project X-Road by nordic-institute.
the class CertificateInfoSensorTest method createTestKeyInfo.
private KeyInfo createTestKeyInfo(CertificateInfo caInfo) {
KeyInfo keyInfo = new KeyInfo(true, null, "friendlyName", "id", "label", "publickey", new ArrayList<CertificateInfo>(), new ArrayList<CertRequestInfo>(), "mechanismName");
keyInfo.getCerts().add(caInfo);
return keyInfo;
}
use of ee.ria.xroad.signer.protocol.dto.CertRequestInfo in project X-Road by nordic-institute.
the class TokenManager method getCertRequestInfo.
/**
* @param keyId the key id
* @param memberId the member id
* @return the certificate request info or null if not found
*/
public static synchronized CertRequestInfo getCertRequestInfo(String keyId, ClientId memberId) {
log.trace("getCertRequestInfo({}, {})", keyId, memberId);
Key key = findKey(keyId);
return key.getCertRequests().stream().filter(c -> key.getUsage() == KeyUsageInfo.AUTHENTICATION || memberId.equals(c.getMemberId())).map(c -> c.toDTO()).findFirst().orElse(null);
}
Aggregations