Search in sources :

Example 1 with CertificateAuthorityService

use of org.cloudfoundry.credhub.data.CertificateAuthorityService in project credhub by cloudfoundry-incubator.

the class CertificateGeneratorTest method beforeEach.

@Before
public void beforeEach() throws Exception {
    TestHelper.getBouncyCastleProvider();
    keyGenerator = mock(LibcryptoRsaKeyPairGenerator.class);
    signedCertificateGenerator = mock(SignedCertificateGenerator.class);
    certificateAuthorityService = mock(CertificateAuthorityService.class);
    permissionCheckingService = mock(PermissionCheckingService.class);
    userContext = mock(UserContext.class);
    subject = new CertificateGenerator(keyGenerator, signedCertificateGenerator, certificateAuthorityService);
    when(permissionCheckingService.hasPermission(anyString(), anyString(), any())).thenReturn(true);
    fakeKeyPairGenerator = new FakeKeyPairGenerator();
    rootCaDn = new X500Name("O=foo,ST=bar,C=root");
    signeeDn = new X500Name("O=foo,ST=bar,C=mars");
    rootCaKeyPair = fakeKeyPairGenerator.generate();
    X509CertificateHolder caX509CertHolder = makeCert(rootCaKeyPair, rootCaKeyPair.getPrivate(), rootCaDn, rootCaDn, true);
    rootCaX509Certificate = new JcaX509CertificateConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME).getCertificate(caX509CertHolder);
    rootCa = new CertificateCredentialValue(null, CertificateFormatter.pemOf(rootCaX509Certificate), CertificateFormatter.pemOf(rootCaKeyPair.getPrivate()), null);
    generationParameters = new CertificateGenerationRequestParameters();
    generationParameters.setOrganization("foo");
    generationParameters.setState("bar");
    generationParameters.setCaName("my-ca-name");
    generationParameters.setCountry("mars");
    generationParameters.setDuration(365);
    inputParameters = new CertificateGenerationParameters(generationParameters);
}
Also used : UserContext(org.cloudfoundry.credhub.auth.UserContext) CertificateAuthorityService(org.cloudfoundry.credhub.data.CertificateAuthorityService) X500Name(org.bouncycastle.asn1.x500.X500Name) CertificateGenerationRequestParameters(org.cloudfoundry.credhub.request.CertificateGenerationRequestParameters) PermissionCheckingService(org.cloudfoundry.credhub.service.PermissionCheckingService) CertificateGenerationParameters(org.cloudfoundry.credhub.domain.CertificateGenerationParameters) JcaX509CertificateConverter(org.bouncycastle.cert.jcajce.JcaX509CertificateConverter) CertificateCredentialValue(org.cloudfoundry.credhub.credential.CertificateCredentialValue) X509CertificateHolder(org.bouncycastle.cert.X509CertificateHolder) Before(org.junit.Before)

Example 2 with CertificateAuthorityService

use of org.cloudfoundry.credhub.data.CertificateAuthorityService in project credhub by cloudfoundry-incubator.

the class SetHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    TestHelper.getBouncyCastleProvider();
    credentialService = mock(PermissionedCredentialService.class);
    certificateAuthorityService = mock(CertificateAuthorityService.class);
    permissionService = mock(PermissionService.class);
    userContext = new UserContext();
    UserContextHolder userContextHolder = new UserContextHolder();
    userContextHolder.setUserContext(userContext);
    subject = new SetHandler(credentialService, permissionService, certificateAuthorityService, userContextHolder);
    generationParameters = new StringGenerationParameters();
    accessControlEntries = new ArrayList<>();
    credentialVersion = mock(PasswordCredentialVersion.class);
    when(credentialService.save(anyObject(), anyObject(), anyObject(), anyList())).thenReturn(credentialVersion);
}
Also used : PermissionService(org.cloudfoundry.credhub.service.PermissionService) PermissionedCredentialService(org.cloudfoundry.credhub.service.PermissionedCredentialService) UserContext(org.cloudfoundry.credhub.auth.UserContext) UserContextHolder(org.cloudfoundry.credhub.auth.UserContextHolder) CertificateAuthorityService(org.cloudfoundry.credhub.data.CertificateAuthorityService) PasswordCredentialVersion(org.cloudfoundry.credhub.domain.PasswordCredentialVersion) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Before(org.junit.Before)

Aggregations

UserContext (org.cloudfoundry.credhub.auth.UserContext)2 CertificateAuthorityService (org.cloudfoundry.credhub.data.CertificateAuthorityService)2 Before (org.junit.Before)2 X500Name (org.bouncycastle.asn1.x500.X500Name)1 X509CertificateHolder (org.bouncycastle.cert.X509CertificateHolder)1 JcaX509CertificateConverter (org.bouncycastle.cert.jcajce.JcaX509CertificateConverter)1 UserContextHolder (org.cloudfoundry.credhub.auth.UserContextHolder)1 CertificateCredentialValue (org.cloudfoundry.credhub.credential.CertificateCredentialValue)1 CertificateGenerationParameters (org.cloudfoundry.credhub.domain.CertificateGenerationParameters)1 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)1 CertificateGenerationRequestParameters (org.cloudfoundry.credhub.request.CertificateGenerationRequestParameters)1 StringGenerationParameters (org.cloudfoundry.credhub.request.StringGenerationParameters)1 PermissionCheckingService (org.cloudfoundry.credhub.service.PermissionCheckingService)1 PermissionService (org.cloudfoundry.credhub.service.PermissionService)1 PermissionedCredentialService (org.cloudfoundry.credhub.service.PermissionedCredentialService)1