parent
79ced94cc9
commit
5eacae1797
|
|
@ -142,12 +142,7 @@ public abstract class AbstractGithubPersonalAccessTokenFetcher
|
|||
new PersonalAccessTokenParams(
|
||||
scmServerUrl, tokenName, tokenId, oAuthToken.getToken(), null));
|
||||
if (valid.isEmpty()) {
|
||||
throw new ScmCommunicationException(
|
||||
"Unable to verify if current token is a valid GitHub token. Token's scm-url needs to be '"
|
||||
+ GithubApiClient.GITHUB_SAAS_ENDPOINT
|
||||
+ "' and was '"
|
||||
+ scmServerUrl
|
||||
+ "'");
|
||||
throw buildScmUnauthorizedException(cheSubject);
|
||||
} else if (!valid.get().first) {
|
||||
throw new ScmCommunicationException(
|
||||
"Current token doesn't have the necessary privileges. Please make sure Che app scopes are correct and containing at least: "
|
||||
|
|
@ -161,11 +156,7 @@ public abstract class AbstractGithubPersonalAccessTokenFetcher
|
|||
tokenId,
|
||||
oAuthToken.getToken());
|
||||
} catch (UnauthorizedException e) {
|
||||
throw new ScmUnauthorizedException(
|
||||
cheSubject.getUserName() + " is not authorized in " + providerName + " OAuth provider.",
|
||||
providerName,
|
||||
"2.0",
|
||||
getLocalAuthenticateUrl());
|
||||
throw buildScmUnauthorizedException(cheSubject);
|
||||
} catch (NotFoundException nfe) {
|
||||
throw new UnknownScmProviderException(nfe.getMessage(), scmServerUrl);
|
||||
} catch (ServerException | ForbiddenException | BadRequestException | ConflictException e) {
|
||||
|
|
@ -174,6 +165,17 @@ public abstract class AbstractGithubPersonalAccessTokenFetcher
|
|||
}
|
||||
}
|
||||
|
||||
private ScmUnauthorizedException buildScmUnauthorizedException(Subject cheSubject) {
|
||||
return new ScmUnauthorizedException(
|
||||
cheSubject.getUserName()
|
||||
+ " is not authorized in "
|
||||
+ this.providerName
|
||||
+ " OAuth provider.",
|
||||
this.providerName,
|
||||
"2.0",
|
||||
getLocalAuthenticateUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Optional<Boolean> isValid(PersonalAccessToken personalAccessToken) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue