* @see org.jboss.dna.graph.connectors.RepositorySource#getConnection()
*/
public RepositoryConnection getConnection() throws RepositorySourceException {
if (getName() == null) {
I18n msg = FederationI18n.propertyIsRequired;
throw new RepositorySourceException(getName(), msg.text("name"));
}
if (getRepositoryContext() == null) {
I18n msg = FederationI18n.propertyIsRequired;
throw new RepositorySourceException(getName(), msg.text("repository context"));
}
if (getUsername() != null && getSecurityDomain() == null) {
I18n msg = FederationI18n.propertyIsRequired;
throw new RepositorySourceException(getName(), msg.text("security domain"));
}
// Find the repository ...
FederatedRepository repository = getRepository();
// Authenticate the user ...
String username = this.username;
Object credentials = this.password;
RepositoryConnection connection = repository.createConnection(this, username, credentials);
if (connection == null) {
I18n msg = FederationI18n.unableToAuthenticateConnectionToFederatedRepository;
throw new RepositorySourceException(msg.text(this.repositoryName, username));
}
// Return the new connection ...
return connection;
}