Search in sources :

Example 1 with UnauthorizedException

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

the class Connection method isAuthorized.

/**
 * Computes authorization state of connection. May be a long running operation.
 * @return
 */
public boolean isAuthorized(IProgressMonitor monitor) {
    try {
        IAuthorizationContext context = client.getAuthorizationContext();
        boolean result = context.isAuthorized();
        if (result) {
            // being true, promises that connect will go smoothly.
            return connect();
        }
        return result;
    } catch (UnauthorizedException e) {
        return false;
    }
}
Also used : IAuthorizationContext(com.openshift.restclient.authorization.IAuthorizationContext) UnauthorizedException(com.openshift.restclient.authorization.UnauthorizedException)

Aggregations

IAuthorizationContext (com.openshift.restclient.authorization.IAuthorizationContext)1 UnauthorizedException (com.openshift.restclient.authorization.UnauthorizedException)1