Search in sources :

Example 1 with IAuthorizationDetails

use of com.openshift.restclient.authorization.IAuthorizationDetails in project jbosstools-openshift by jbosstools.

the class OAuthDetailView method createAuthDetailsJob.

protected Job createAuthDetailsJob(Shell shell) {
    Job job = new AuthDetailsJob(pageModel.getHost());
    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(final IJobChangeEvent event) {
            if (event.getJob() instanceof AuthDetailsJob) {
                shell.getDisplay().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        AuthDetailsJob job = (AuthDetailsJob) event.getJob();
                        final IAuthorizationDetails details = job.getDetails();
                        if (details != null) {
                            // TODO fix this to handle other authschemes
                            if (IAuthorizationContext.AUTHSCHEME_BASIC.equals(details.getScheme())) {
                                MessageDialog.openError(shell, "Authorization Information", NLS.bind("This server utilizes {0} authorization protocol", details.getScheme()));
                                authSchemeObservable.setValue(details.getScheme());
                            } else {
                                OAuthDialog dialog = new OAuthDialog(shell, details.getRequestTokenLink());
                                dialog.open();
                                String token = dialog.getToken();
                                if (StringUtils.isNotBlank(token)) {
                                    tokenObservable.setValue(token);
                                }
                            }
                        }
                    }
                });
            }
        }
    });
    return job;
}
Also used : JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Job(org.eclipse.core.runtime.jobs.Job) IAuthorizationDetails(com.openshift.restclient.authorization.IAuthorizationDetails)

Aggregations

IAuthorizationDetails (com.openshift.restclient.authorization.IAuthorizationDetails)1 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 Job (org.eclipse.core.runtime.jobs.Job)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1