rename enum constants (#10631)

This commit is contained in:
William Cheng
2021-10-22 09:26:48 +08:00
committed by GitHub
parent e85c67edc7
commit 681578d1b5
8 changed files with 52 additions and 28 deletions

View File

@@ -37,7 +37,7 @@ public class OAuth implements Authentication {
private String tokenUrl;
private String absoluteTokenUrl;
private OAuthFlow flow = OAuthFlow.application;
private OAuthFlow flow = OAuthFlow.APPLICATION;
private OAuth20Service service;
private DefaultApi20 authApi;
private String scope;
@@ -114,18 +114,18 @@ public class OAuth implements Authentication {
}
try {
switch (flow) {
case password:
case PASSWORD:
if (username != null && password != null) {
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
}
break;
case accessCode:
case ACCESS_CODE:
if (code != null) {
accessToken = service.getAccessToken(code);
code = null;
}
break;
case application:
case APPLICATION:
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
break;
default:
@@ -170,14 +170,14 @@ public class OAuth implements Authentication {
}
public OAuth usePasswordFlow(String username, String password) {
this.flow = OAuthFlow.password;
this.flow = OAuthFlow.PASSWORD;
this.username = username;
this.password = password;
return this;
}
public OAuth useAuthorizationCodeFlow(String code) {
this.flow = OAuthFlow.accessCode;
this.flow = OAuthFlow.ACCESS_CODE;
this.code = code;
return this;
}

View File

@@ -13,6 +13,12 @@
package org.openapitools.client.auth;
/**
* OAuth flows that are supported by this client
*/
public enum OAuthFlow {
accessCode, implicit, password, application
ACCESS_CODE,
IMPLICIT,
PASSWORD,
APPLICATION
}