use of com.thoughtworks.go.security.X509CertificateGenerator in project gocd by gocd.
the class FakeGoServer method createX509Certificate.
private void createX509Certificate(File keystore, File truststore, File agentKeystore) {
final String principalDn = "ou=Cruise server webserver certificate, cn=" + getHostname();
X509CertificateGenerator generator = new X509CertificateGenerator();
generator.createAndStoreX509Certificates(keystore, truststore, agentKeystore, PASSWORD, principalDn);
}
use of com.thoughtworks.go.security.X509CertificateGenerator in project gocd by gocd.
the class GoSslSocketConnector method ensureX509Certificates.
private void ensureX509Certificates() {
String principalDn = "ou=Cruise server webserver certificate, cn=" + getHostname();
X509CertificateGenerator generator = new X509CertificateGenerator();
generator.createAndStoreX509Certificates(keystore, truststore, agentKeystore, password, principalDn);
}
use of com.thoughtworks.go.security.X509CertificateGenerator in project gocd by gocd.
the class X509AuthoritiesPopulatorTest method shouldNotReturnUserDetailsIfCertificateHasNoOu.
@Test
public void shouldNotReturnUserDetailsIfCertificateHasNoOu() {
X509Certificate agentCertificate = new X509CertificateGenerator().createCertificateWithDn("CN=hostname").getFirstCertificate();
try {
populator.getUserDetails(agentCertificate);
Assert.fail("Oh dear. You should have thrown an exception, silly!");
} catch (BadCredentialsException ignored) {
}
}
use of com.thoughtworks.go.security.X509CertificateGenerator in project gocd by gocd.
the class AgentCertificateMother method agentCertificate.
public static Registration agentCertificate() {
File tempKeystoreFile = TestFileUtil.createUniqueTempFile(authorityKeystorePath);
X509CertificateGenerator certificateGenerator = new X509CertificateGenerator();
certificateGenerator.createAndStoreCACertificates(tempKeystoreFile);
return certificateGenerator.createAgentCertificate(tempKeystoreFile, "blah");
}
use of com.thoughtworks.go.security.X509CertificateGenerator in project gocd by gocd.
the class X509AuthoritiesPopulatorTest method shouldReturnUserDetailsWithCorrectAuthorityIfAgentCertificateHasOu.
@Test
public void shouldReturnUserDetailsWithCorrectAuthorityIfAgentCertificateHasOu() {
X509Certificate agentCertificate = new X509CertificateGenerator().createCertificateWithDn("CN=hostname, OU=agent").getFirstCertificate();
UserDetails userDetails = populator.getUserDetails(agentCertificate);
GrantedAuthority[] actual = userDetails.getAuthorities();
GrantedAuthority expected = new GrantedAuthorityImpl(ROLE_AGENT);
assertThat(actual.length, is(1));
assertThat(actual[0], is(expected));
}
Aggregations