Search in sources :

Example 6 with Registration

use of com.thoughtworks.go.security.Registration in project gocd by gocd.

the class SslInfrastructureService method register.

private void register(AgentAutoRegistrationProperties agentAutoRegistrationProperties) throws Exception {
    String hostName = SystemUtil.getLocalhostNameOrRandomNameIfNotFound();
    Registration keyEntry = Registration.createNullPrivateKeyEntry();
    while (!keyEntry.isValid()) {
        try {
            getTokenIfNecessary();
            keyEntry = remoteRegistrationRequester.requestRegistration(hostName, agentAutoRegistrationProperties);
        } catch (Exception e) {
            LOGGER.error("[Agent Registration] There was a problem registering with the go server.", e);
            throw e;
        }
        if ((!keyEntry.isValid())) {
            try {
                LOGGER.debug("[Agent Registration] Retrieved agent key from Go server is not valid.");
                Thread.sleep(REGISTER_RETRY_INTERVAL);
            } catch (InterruptedException e) {
            // Ok
            }
        }
    }
    LOGGER.info("[Agent Registration] Retrieved registration from Go server.");
    storeChainIntoAgentStore(keyEntry);
    agentAutoRegistrationProperties.scrubRegistrationProperties();
}
Also used : Registration(com.thoughtworks.go.security.Registration) IOException(java.io.IOException)

Aggregations

Registration (com.thoughtworks.go.security.Registration)6 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)2 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)1 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1 UpdateEnvironmentsCommand (com.thoughtworks.go.config.update.UpdateEnvironmentsCommand)1 UpdateResourceCommand (com.thoughtworks.go.config.update.UpdateResourceCommand)1 AgentInstance (com.thoughtworks.go.domain.AgentInstance)1 AllConfigErrors (com.thoughtworks.go.domain.AllConfigErrors)1 ConfigErrors (com.thoughtworks.go.domain.ConfigErrors)1 X509CertificateGenerator (com.thoughtworks.go.security.X509CertificateGenerator)1 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)1 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)1 FileNotFoundException (java.io.FileNotFoundException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HttpHeaders (org.springframework.http.HttpHeaders)1