use of ee.ria.xroad.common.certificateprofile.CertificateProfileInfoProvider in project X-Road by nordic-institute.
the class FiVRKCertificateProfileInfoProviderTest method providerReturnsCorrectImplementations.
/**
* Tests whether provider returns correct implementation as expected.
*/
@Test
public void providerReturnsCorrectImplementations() {
CertificateProfileInfoProvider provider = provider();
assertTrue("Must return instance of DefaultAuthCertificateProfileInfo", provider.getAuthCertProfile(new AuthCertificateProfileInfoParameters(SecurityServerId.create("XX", "foo", "bar", "server"), "foo")) instanceof FiVRKAuthCertificateProfileInfo);
assertTrue("Must return instance of DefaultSignCertificateProfileInfo", provider.getSignCertProfile(new SignCertificateProfileInfoParameters(SecurityServerId.create("XX", "foo", "bar", "server"), ClientId.create("XX", "foo", "bar"), "foo")) instanceof FiVRKSignCertificateProfileInfo);
}
use of ee.ria.xroad.common.certificateprofile.CertificateProfileInfoProvider in project X-Road by nordic-institute.
the class FoCertificateProfileInfoProviderTest method providerReturnsCorrectImplementations.
/**
* Tests whether provider returns correct implementation as expected.
*/
@Test
public void providerReturnsCorrectImplementations() {
CertificateProfileInfoProvider provider = newProvider();
assertTrue("Must return instance of FoAuthCertificateProfileInfo", provider.getAuthCertProfile(new AuthCertificateProfileInfoParameters(SecurityServerId.create("XX", "foo", "bar", "server"), "foo")) instanceof FoAuthCertificateProfileInfo);
assertTrue("Must return instance of FoSignCertificateProfileInfo", provider.getSignCertProfile(new SignCertificateProfileInfoParameters(SecurityServerId.create("XX", "CLASS", "OWNER", "server"), ClientId.create("XX", "CLASS", "CLIENT"), "client")) instanceof FoSignCertificateProfileInfo);
}
use of ee.ria.xroad.common.certificateprofile.CertificateProfileInfoProvider in project X-Road by nordic-institute.
the class EjbcaCertificateProfileInfoProviderTest method providerReturnsCorrectImplementations.
/**
* Tests whether provider returns correct implementation as expected.
*/
@Test
public void providerReturnsCorrectImplementations() {
CertificateProfileInfoProvider provider = provider();
assertTrue("Must return instance of DefaultAuthCertificateProfileInfo", provider.getAuthCertProfile(new AuthCertificateProfileInfoParameters(SecurityServerId.create("XX", "foo", "bar", "server"), "foo")) instanceof EjbcaAuthCertificateProfileInfo);
assertTrue("Must return instance of DefaultSignCertificateProfileInfo", provider.getSignCertProfile(new SignCertificateProfileInfoParameters(ClientId.create("XX", "foo", "bar"), "foo")) instanceof EjbcaSignCertificateProfileInfo);
}
use of ee.ria.xroad.common.certificateprofile.CertificateProfileInfoProvider in project X-Road by nordic-institute.
the class CertificateAuthorityService method getCertificateProfile.
/**
* Return correct CertificateProfileInfo for given parameters
* @param caName name of the CA
* @param keyUsageInfo key usage
* @param memberId member when key usage = signing, ignored otherwise
* @return CertificateProfileInfo
* @throws CertificateAuthorityNotFoundException if matching CA was not found
* @throws CertificateProfileInstantiationException if instantiation of certificate profile failed
* @throws WrongKeyUsageException if attempted to read signing profile from authenticationOnly ca
* @throws ClientNotFoundException if client with memberId was not found
*/
public CertificateProfileInfo getCertificateProfile(String caName, KeyUsageInfo keyUsageInfo, ClientId memberId, boolean isNewMember) throws CertificateAuthorityNotFoundException, CertificateProfileInstantiationException, WrongKeyUsageException, ClientNotFoundException {
ApprovedCAInfo caInfo = getCertificateAuthorityInfo(caName);
if (Boolean.TRUE.equals(caInfo.getAuthenticationOnly()) && KeyUsageInfo.SIGNING == keyUsageInfo) {
throw new WrongKeyUsageException();
}
if (keyUsageInfo == KeyUsageInfo.SIGNING && !isNewMember) {
// validate that the member exists or has a subsystem on this server - except when adding a new client
if (!clientService.getLocalClientMemberIds().contains(memberId)) {
throw new ClientNotFoundException("client with id " + memberId + ", or subsystem for it, not found");
}
}
CertificateProfileInfoProvider provider = null;
try {
provider = new GetCertificateProfile(caInfo.getCertificateProfileInfo()).instance();
} catch (Exception e) {
throw new CertificateProfileInstantiationException(e);
}
SecurityServerId serverId = currentSecurityServerId.getServerId();
if (KeyUsageInfo.AUTHENTICATION == keyUsageInfo) {
String ownerName = globalConfFacade.getMemberName(serverId.getOwner());
AuthCertificateProfileInfoParameters params = new AuthCertificateProfileInfoParameters(serverId, ownerName);
return provider.getAuthCertProfile(params);
} else if (KeyUsageInfo.SIGNING == keyUsageInfo) {
String memberName = globalConfFacade.getMemberName(memberId);
SignCertificateProfileInfoParameters params = new SignCertificateProfileInfoParameters(serverId, memberId, memberName);
return provider.getSignCertProfile(params);
} else {
throw new IllegalArgumentException();
}
}
Aggregations