forked from loafle/openapi-generator-original
[Java][jersey2] Add debugging to OAuth (#6757)
* add debugging to oauth * use fine instead
This commit is contained in:
parent
8b9c070e5d
commit
919b3b6bef
@ -461,7 +461,7 @@ public class ApiClient {
|
|||||||
public ApiClient setOauthCredentials(String clientId, String clientSecret) {
|
public ApiClient setOauthCredentials(String clientId, String clientSecret) {
|
||||||
for (Authentication auth : authentications.values()) {
|
for (Authentication auth : authentications.values()) {
|
||||||
if (auth instanceof OAuth) {
|
if (auth instanceof OAuth) {
|
||||||
((OAuth) auth).setCredentials(clientId, clientSecret);
|
((OAuth) auth).setCredentials(clientId, clientSecret, isDebugging());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ public class OAuth implements Authentication {
|
|||||||
|
|
||||||
public synchronized OAuth2AccessToken obtainAccessToken(String refreshToken) throws ApiException {
|
public synchronized OAuth2AccessToken obtainAccessToken(String refreshToken) throws ApiException {
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
|
log.log(Level.FINE, "service is null in obtainAccessToken.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -115,6 +116,9 @@ public class OAuth implements Authentication {
|
|||||||
break;
|
break;
|
||||||
case application:
|
case application:
|
||||||
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log.log(Level.SEVERE, "Invalid flow in obtainAccessToken: " + flow);
|
||||||
}
|
}
|
||||||
} catch (OAuthException | InterruptedException | ExecutionException | IOException e) {
|
} catch (OAuthException | InterruptedException | ExecutionException | IOException e) {
|
||||||
throw new ApiException(e);
|
throw new ApiException(e);
|
||||||
@ -141,10 +145,16 @@ public class OAuth implements Authentication {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OAuth setCredentials(String clientId, String clientSecret) {
|
public OAuth setCredentials(String clientId, String clientSecret, Boolean debug) {
|
||||||
|
if (Boolean.TRUE.equals(debug)) {
|
||||||
|
service = new ServiceBuilder(clientId)
|
||||||
|
.apiSecret(clientSecret).debug()
|
||||||
|
.build(authApi);
|
||||||
|
} else {
|
||||||
service = new ServiceBuilder(clientId)
|
service = new ServiceBuilder(clientId)
|
||||||
.apiSecret(clientSecret)
|
.apiSecret(clientSecret)
|
||||||
.build(authApi);
|
.build(authApi);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ public class ApiClient {
|
|||||||
public ApiClient setOauthCredentials(String clientId, String clientSecret) {
|
public ApiClient setOauthCredentials(String clientId, String clientSecret) {
|
||||||
for (Authentication auth : authentications.values()) {
|
for (Authentication auth : authentications.values()) {
|
||||||
if (auth instanceof OAuth) {
|
if (auth instanceof OAuth) {
|
||||||
((OAuth) auth).setCredentials(clientId, clientSecret);
|
((OAuth) auth).setCredentials(clientId, clientSecret, isDebugging());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,7 @@ public class OAuth implements Authentication {
|
|||||||
|
|
||||||
public synchronized OAuth2AccessToken obtainAccessToken(String refreshToken) throws ApiException {
|
public synchronized OAuth2AccessToken obtainAccessToken(String refreshToken) throws ApiException {
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
|
log.log(Level.FINE, "service is null in obtainAccessToken.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -126,6 +127,9 @@ public class OAuth implements Authentication {
|
|||||||
break;
|
break;
|
||||||
case application:
|
case application:
|
||||||
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log.log(Level.SEVERE, "Invalid flow in obtainAccessToken: " + flow);
|
||||||
}
|
}
|
||||||
} catch (OAuthException | InterruptedException | ExecutionException | IOException e) {
|
} catch (OAuthException | InterruptedException | ExecutionException | IOException e) {
|
||||||
throw new ApiException(e);
|
throw new ApiException(e);
|
||||||
@ -152,10 +156,16 @@ public class OAuth implements Authentication {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OAuth setCredentials(String clientId, String clientSecret) {
|
public OAuth setCredentials(String clientId, String clientSecret, Boolean debug) {
|
||||||
|
if (Boolean.TRUE.equals(debug)) {
|
||||||
|
service = new ServiceBuilder(clientId)
|
||||||
|
.apiSecret(clientSecret).debug()
|
||||||
|
.build(authApi);
|
||||||
|
} else {
|
||||||
service = new ServiceBuilder(clientId)
|
service = new ServiceBuilder(clientId)
|
||||||
.apiSecret(clientSecret)
|
.apiSecret(clientSecret)
|
||||||
.build(authApi);
|
.build(authApi);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ public class ApiClient {
|
|||||||
public ApiClient setOauthCredentials(String clientId, String clientSecret) {
|
public ApiClient setOauthCredentials(String clientId, String clientSecret) {
|
||||||
for (Authentication auth : authentications.values()) {
|
for (Authentication auth : authentications.values()) {
|
||||||
if (auth instanceof OAuth) {
|
if (auth instanceof OAuth) {
|
||||||
((OAuth) auth).setCredentials(clientId, clientSecret);
|
((OAuth) auth).setCredentials(clientId, clientSecret, isDebugging());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,7 @@ public class OAuth implements Authentication {
|
|||||||
|
|
||||||
public synchronized OAuth2AccessToken obtainAccessToken(String refreshToken) throws ApiException {
|
public synchronized OAuth2AccessToken obtainAccessToken(String refreshToken) throws ApiException {
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
|
log.log(Level.FINE, "service is null in obtainAccessToken.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -126,6 +127,9 @@ public class OAuth implements Authentication {
|
|||||||
break;
|
break;
|
||||||
case application:
|
case application:
|
||||||
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log.log(Level.SEVERE, "Invalid flow in obtainAccessToken: " + flow);
|
||||||
}
|
}
|
||||||
} catch (OAuthException | InterruptedException | ExecutionException | IOException e) {
|
} catch (OAuthException | InterruptedException | ExecutionException | IOException e) {
|
||||||
throw new ApiException(e);
|
throw new ApiException(e);
|
||||||
@ -152,10 +156,16 @@ public class OAuth implements Authentication {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OAuth setCredentials(String clientId, String clientSecret) {
|
public OAuth setCredentials(String clientId, String clientSecret, Boolean debug) {
|
||||||
|
if (Boolean.TRUE.equals(debug)) {
|
||||||
|
service = new ServiceBuilder(clientId)
|
||||||
|
.apiSecret(clientSecret).debug()
|
||||||
|
.build(authApi);
|
||||||
|
} else {
|
||||||
service = new ServiceBuilder(clientId)
|
service = new ServiceBuilder(clientId)
|
||||||
.apiSecret(clientSecret)
|
.apiSecret(clientSecret)
|
||||||
.build(authApi);
|
.build(authApi);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user