[jbosstools-issues] [JBoss JIRA] (JBIDE-19786) Connection wizard: cannot connect to console.stg.openshift.com

Andre Dietisheim (JIRA) issues at jboss.org
Mon May 11 10:50:19 EDT 2015


    [ https://issues.jboss.org/browse/JBIDE-19786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13066947#comment-13066947 ] 

Andre Dietisheim commented on JBIDE-19786:
------------------------------------------

In the code I see the connection trying the following:

{code:title=org.jboss.tools.openshift.core.connection.Connection}
	@Override
	public boolean connect() throws OpenShiftException {
		if (getToken() != null) {
			save();
			return true;
		} else if (authorize()) {
			save();
			return true;
		} else {
			return false;
		}
	}
{code}
There's no token yet so *#authorize()* is executed which fails:

{code:title=org.jboss.tools.openshift.core.connection.Connection}
	private boolean authorize() {
		IAuthorizationContext context = authorizer.getContext(client.getBaseURL().toString(), username, password);
		if (!context.isAuthorized() && credentialsPrompter != null) {
			credentialsPrompter.promptAndAuthenticate(this);
		} else {
			setToken(context.getToken());
		}
		return getToken() != null;
	}
{code}
*context.isAuthorized()* returns *false* but the credentialsPrompter is *null*, so *#setToken(context.getToken())* is executed which sets a *null* token.
*context.isAuthorized()* reaches out to the server and gets the following response:
{code}
HTTP/1.1 401 Unauthorized 
[Link: <https://api.stg.openshift.com/oauth/token/request>; rel="related", Warning: 199 OpenShift "You must obtain an API token by visiting https://api.stg.openshift.com/oauth/token/request", Date: Mon, 11 May 2015 14:32:58 GMT, Content-Length: 91, Content-Type: text/plain; charset=utf-8] 
ResponseEntityProxy{[Content-Type: text/plain; charset=utf-8,Content-Length: 91,Chunked: false]}
{code}

Back in 
{code:title=org.jboss.tools.openshift.internal.common.ui.connection.ConnectionWizardPageModel}
	public IStatus connect() {
		IStatus status = Status.OK_STATUS;
		try {
			this.connection = createConnection();
			if(connection != null) {
				if (connection.connect()) {
					wizardModel.setConnection(connection);
				} else {
					String message = String.format("Unable to connect to %s", connection.getHost());
					OpenShiftCommonUIActivator.log(message, null);
					status = StatusFactory.errorStatus(OpenShiftCommonUIActivator.PLUGIN_ID, message);
				}
			}
{code}
*connection.connect()* returns *false* causing the error message to be shown.

> Connection wizard: cannot connect to console.stg.openshift.com
> --------------------------------------------------------------
>
>                 Key: JBIDE-19786
>                 URL: https://issues.jboss.org/browse/JBIDE-19786
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: openshift
>    Affects Versions: 4.3.0.Beta1
>            Reporter: Andre Dietisheim
>         Attachments: unable-to-connect.png, webconsole.png
>
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the jbosstools-issues mailing list