use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class ConnectionValidatorFactory method createBasicAuthenticationValidator.
/**
* Returns new validator that checks that there is no connection other than the selected one
* with host and username provided by the observable values.
* @param pageModel
* @param usernameObservable
* @param urlObservable
* @return
*/
public static MultiValidator createBasicAuthenticationValidator(ConnectionWizardPageModel pageModel, IObservableValue usernameObservable, IObservableValue<?> urlObservable) {
return new MultiValidator() {
@Override
protected IStatus validate() {
String user1 = (String) usernameObservable.getValue();
String mHost = (String) urlObservable.getValue();
IConnection current = pageModel.getSelectedConnection();
for (Connection c : ConnectionsRegistrySingleton.getInstance().getAll(Connection.class)) {
if (c != current && IAuthorizationContext.AUTHSCHEME_BASIC.equals(c.getAuthScheme())) {
String host = c.getHost();
String user = c.getUsername();
if (host != null && host.equals(mHost) && user != null && user.equals(user1)) {
return ValidationStatus.error("Connection for the server with this username already exists.");
}
}
}
return ValidationStatus.ok();
}
};
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class ConnectionEditor method onSelectedConnectionChanged.
@Override
protected void onSelectedConnectionChanged(IObservableValue selectedConnection) {
IConnection conn = (IConnection) selectedConnection.getValue();
detailViewModel.setSelectedConnection(conn);
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class ConnectionValidatorFactory method createOAuthAuthenticationValidator.
/**
* Returns new validator that checks that there is no connection other than the selected one
* with host and token provided by the observable values.
* @param pageModel
* @param tokenObservable
* @param urlObservable
* @return
*/
public static MultiValidator createOAuthAuthenticationValidator(ConnectionWizardPageModel pageModel, IObservableValue tokenObservable, IObservableValue<?> urlObservable) {
return new MultiValidator() {
@Override
protected IStatus validate() {
String token1 = (String) tokenObservable.getValue();
String mHost = (String) urlObservable.getValue();
IConnection current = pageModel.getSelectedConnection();
for (Connection c : ConnectionsRegistrySingleton.getInstance().getAll(Connection.class)) {
if (c != current && IAuthorizationContext.AUTHSCHEME_OAUTH.equals(c.getAuthScheme())) {
String host = c.getHost();
String token = c.getToken();
if (host != null && host.equals(mHost) && token != null && token.equals(token1)) {
return ValidationStatus.error("Connection for the server with this token already exists.");
}
}
}
return ValidationStatus.ok();
}
};
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class BasicAuthenticationDetailView method setSelectedConnection.
@Override
public void setSelectedConnection(IConnection conn) {
if (conn instanceof Connection) {
Connection selectedConnection = (Connection) conn;
usernameObservable.setValue(selectedConnection.getUsername());
passwordObservable.setValue(selectedConnection.getPassword());
rememberPasswordObservable.setValue(selectedConnection.isRememberPassword());
} else if (conn instanceof NewConnectionMarker) {
usernameObservable.setValue(null);
passwordObservable.setValue(null);
}
}
use of org.jboss.tools.openshift.common.core.connection.IConnection in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithDeploymentConfigTest method shouldReturnConnection.
@Test
public void shouldReturnConnection() {
// given
// when
IConnection connection = model.getConnection();
// then
assertThat(connection).isEqualTo(this.connection);
}
Aggregations