mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 17:12:49 +00:00
rename enum constants (#10631)
This commit is contained in:
@@ -26,7 +26,7 @@ public class OAuth implements Authentication {
|
|||||||
|
|
||||||
private String tokenUrl;
|
private String tokenUrl;
|
||||||
private String absoluteTokenUrl;
|
private String absoluteTokenUrl;
|
||||||
private OAuthFlow flow = OAuthFlow.application;
|
private OAuthFlow flow = OAuthFlow.APPLICATION;
|
||||||
private OAuth20Service service;
|
private OAuth20Service service;
|
||||||
private DefaultApi20 authApi;
|
private DefaultApi20 authApi;
|
||||||
private String scope;
|
private String scope;
|
||||||
@@ -103,18 +103,18 @@ public class OAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
switch (flow) {
|
switch (flow) {
|
||||||
case password:
|
case PASSWORD:
|
||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
|
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
if (code != null) {
|
if (code != null) {
|
||||||
accessToken = service.getAccessToken(code);
|
accessToken = service.getAccessToken(code);
|
||||||
code = null;
|
code = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -159,14 +159,14 @@ public class OAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OAuth usePasswordFlow(String username, String password) {
|
public OAuth usePasswordFlow(String username, String password) {
|
||||||
this.flow = OAuthFlow.password;
|
this.flow = OAuthFlow.PASSWORD;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OAuth useAuthorizationCodeFlow(String code) {
|
public OAuth useAuthorizationCodeFlow(String code) {
|
||||||
this.flow = OAuthFlow.accessCode;
|
this.flow = OAuthFlow.ACCESS_CODE;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
package {{invokerPackage}}.auth;
|
package {{invokerPackage}}.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, implicit, password, application
|
ACCESS_CODE,
|
||||||
|
IMPLICIT,
|
||||||
|
PASSWORD,
|
||||||
|
APPLICATION
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class OAuth implements Authentication {
|
|||||||
|
|
||||||
private String tokenUrl;
|
private String tokenUrl;
|
||||||
private String absoluteTokenUrl;
|
private String absoluteTokenUrl;
|
||||||
private OAuthFlow flow = OAuthFlow.application;
|
private OAuthFlow flow = OAuthFlow.APPLICATION;
|
||||||
private OAuth20Service service;
|
private OAuth20Service service;
|
||||||
private DefaultApi20 authApi;
|
private DefaultApi20 authApi;
|
||||||
private String scope;
|
private String scope;
|
||||||
@@ -114,18 +114,18 @@ public class OAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
switch (flow) {
|
switch (flow) {
|
||||||
case password:
|
case PASSWORD:
|
||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
|
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
if (code != null) {
|
if (code != null) {
|
||||||
accessToken = service.getAccessToken(code);
|
accessToken = service.getAccessToken(code);
|
||||||
code = null;
|
code = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -170,14 +170,14 @@ public class OAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OAuth usePasswordFlow(String username, String password) {
|
public OAuth usePasswordFlow(String username, String password) {
|
||||||
this.flow = OAuthFlow.password;
|
this.flow = OAuthFlow.PASSWORD;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OAuth useAuthorizationCodeFlow(String code) {
|
public OAuth useAuthorizationCodeFlow(String code) {
|
||||||
this.flow = OAuthFlow.accessCode;
|
this.flow = OAuthFlow.ACCESS_CODE;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,12 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, implicit, password, application
|
ACCESS_CODE,
|
||||||
|
IMPLICIT,
|
||||||
|
PASSWORD,
|
||||||
|
APPLICATION
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class OAuth implements Authentication {
|
|||||||
|
|
||||||
private String tokenUrl;
|
private String tokenUrl;
|
||||||
private String absoluteTokenUrl;
|
private String absoluteTokenUrl;
|
||||||
private OAuthFlow flow = OAuthFlow.application;
|
private OAuthFlow flow = OAuthFlow.APPLICATION;
|
||||||
private OAuth20Service service;
|
private OAuth20Service service;
|
||||||
private DefaultApi20 authApi;
|
private DefaultApi20 authApi;
|
||||||
private String scope;
|
private String scope;
|
||||||
@@ -114,18 +114,18 @@ public class OAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
switch (flow) {
|
switch (flow) {
|
||||||
case password:
|
case PASSWORD:
|
||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
|
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
if (code != null) {
|
if (code != null) {
|
||||||
accessToken = service.getAccessToken(code);
|
accessToken = service.getAccessToken(code);
|
||||||
code = null;
|
code = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -170,14 +170,14 @@ public class OAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OAuth usePasswordFlow(String username, String password) {
|
public OAuth usePasswordFlow(String username, String password) {
|
||||||
this.flow = OAuthFlow.password;
|
this.flow = OAuthFlow.PASSWORD;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OAuth useAuthorizationCodeFlow(String code) {
|
public OAuth useAuthorizationCodeFlow(String code) {
|
||||||
this.flow = OAuthFlow.accessCode;
|
this.flow = OAuthFlow.ACCESS_CODE;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,12 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, implicit, password, application
|
ACCESS_CODE,
|
||||||
|
IMPLICIT,
|
||||||
|
PASSWORD,
|
||||||
|
APPLICATION
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class OAuth implements Authentication {
|
|||||||
|
|
||||||
private String tokenUrl;
|
private String tokenUrl;
|
||||||
private String absoluteTokenUrl;
|
private String absoluteTokenUrl;
|
||||||
private OAuthFlow flow = OAuthFlow.application;
|
private OAuthFlow flow = OAuthFlow.APPLICATION;
|
||||||
private OAuth20Service service;
|
private OAuth20Service service;
|
||||||
private DefaultApi20 authApi;
|
private DefaultApi20 authApi;
|
||||||
private String scope;
|
private String scope;
|
||||||
@@ -114,18 +114,18 @@ public class OAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
switch (flow) {
|
switch (flow) {
|
||||||
case password:
|
case PASSWORD:
|
||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
|
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case accessCode:
|
case ACCESS_CODE:
|
||||||
if (code != null) {
|
if (code != null) {
|
||||||
accessToken = service.getAccessToken(code);
|
accessToken = service.getAccessToken(code);
|
||||||
code = null;
|
code = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case application:
|
case APPLICATION:
|
||||||
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -170,14 +170,14 @@ public class OAuth implements Authentication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OAuth usePasswordFlow(String username, String password) {
|
public OAuth usePasswordFlow(String username, String password) {
|
||||||
this.flow = OAuthFlow.password;
|
this.flow = OAuthFlow.PASSWORD;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OAuth useAuthorizationCodeFlow(String code) {
|
public OAuth useAuthorizationCodeFlow(String code) {
|
||||||
this.flow = OAuthFlow.accessCode;
|
this.flow = OAuthFlow.ACCESS_CODE;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,12 @@
|
|||||||
|
|
||||||
package org.openapitools.client.auth;
|
package org.openapitools.client.auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OAuth flows that are supported by this client
|
||||||
|
*/
|
||||||
public enum OAuthFlow {
|
public enum OAuthFlow {
|
||||||
accessCode, implicit, password, application
|
ACCESS_CODE,
|
||||||
|
IMPLICIT,
|
||||||
|
PASSWORD,
|
||||||
|
APPLICATION
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user