if(!manager.isSameMachine()) {
manager.setAuthentication(username, password);
}
return manager;
} catch (IOException e) {
throw (DeploymentManagerCreationException)new DeploymentManagerCreationException(e.getMessage()).initCause(e);
} catch (SecurityException e) {
throw (AuthenticationFailedException) new AuthenticationFailedException("Invalid login.").initCause(e);
}
} else if(params.getProtocol().equals("inVM")) {
return new LocalDeploymentManager(KernelRegistry.getKernel(params.getHost()));
} else {
throw new DeploymentManagerCreationException("Invalid URI: " + uri);
}
} catch (RuntimeException e) {
// some DeploymentManagerFactories suppress unchecked exceptions - log and rethrow
log.error(e.getMessage(), e);
throw e;