Skip to content

Commit

Permalink
remove runtime log
Browse files Browse the repository at this point in the history
  • Loading branch information
ntqdinh-axonivy committed Sep 28, 2023
1 parent 840bc1d commit e542864
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions adobe-esign-connector-demo/processes/Demo.p.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
"type" : "Script",
"name" : "log",
"config" : {
"security" : "system",
"output" : {
"code" : [
"ivy.log.info(\"uploaded document with id {0}\", in.fileId);",
"if(in.#error is initialized) {",
" ivy.log.error(in.error);",
"}"
Expand Down Expand Up @@ -139,9 +139,9 @@
"type" : "Script",
"name" : "log",
"config" : {
"security" : "system",
"output" : {
"code" : [
"ivy.log.info(\"create agreement with id {0}\", in.agreementId);",
"if(in.#error is initialized) {",
" ivy.log.error(in.error);",
"}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
"code" : [
"import api.rest.v6.client.SigningUrlResponseSigningUrls;",
"import api.rest.v6.client.SigningUrlResponseSigningUrlSetInfos;",
"ivy.log.info(result.signingURIs);",
"",
"for(SigningUrlResponseSigningUrlSetInfos signingInfos : result.signingURIs) {",
" for(SigningUrlResponseSigningUrls signingUrls : signingInfos.getSigningUrls()) {",
Expand Down Expand Up @@ -363,7 +362,6 @@
"code" : [
"import api.rest.v6.client.SigningUrlResponseSigningUrls;",
"import api.rest.v6.client.SigningUrlResponseSigningUrlSetInfos;",
"ivy.log.info(result.signingURIs);",
"",
"for(SigningUrlResponseSigningUrlSetInfos signingInfos : result.signingURIs) {",
" for(SigningUrlResponseSigningUrls signingUrls : signingInfos.getSigningUrls()) {",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.axonivy.connector.adobe.esign.connector.enums.AdobeVariable;

import ch.ivyteam.ivy.bpm.error.BpmPublicErrorBuilder;
import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.rest.client.FeatureConfig;
import ch.ivyteam.ivy.rest.client.oauth2.OAuth2RedirectErrorBuilder;
import ch.ivyteam.ivy.rest.client.oauth2.uri.OAuth2CallbackUriBuilder;
Expand Down Expand Up @@ -195,7 +194,6 @@ private static BpmPublicErrorBuilder authRedirectError(FeatureConfig config, OAu
.queryParam("client_id", config.readMandatory(Property.CLIENT_ID))
.queryParam("scope", getScope(config))
.build();
Ivy.log().debug("created oauth URI: " + uri);
return OAuth2RedirectErrorBuilder
.create(uri)
.withMessage("Missing permission from user to act in his name.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import ch.ivyteam.ivy.request.IRequest;
import ch.ivyteam.ivy.rest.client.FeatureConfig;
import ch.ivyteam.ivy.rest.client.RestClientFactoryConstants;
import ch.ivyteam.ivy.rest.client.internal.oauth2.RedirectToIdentityProvider;

@SuppressWarnings("restriction")
public class OAuth2BearerFilter implements javax.ws.rs.client.ClientRequestFilter {
private static final String AUTHORIZATION = "Authorization";
private static final String BEARER = "Bearer ";
Expand All @@ -34,8 +36,6 @@ public class OAuth2BearerFilter implements javax.ws.rs.client.ClientRequestFilte

public static final AdobeVariable REFRESH_TOKEN_VAR = AdobeVariable.OAUTH_TOKEN;
public static final AdobeVariable ACCESS_TOKEN_VAR = AdobeVariable.ACCESS_TOKEN;

private static final String OAUTH2_ERROR_CODE = "ivy:error:rest:client:oauth2";

private String property;
private Supplier<String> name = null;
Expand Down Expand Up @@ -63,12 +63,12 @@ protected final String getAccessToken(ClientRequestContext context) {
FeatureConfig config = new FeatureConfig(context.getConfiguration(), getSource());
VarTokenStore refreshTokenStore = VarTokenStore.get(REFRESH_TOKEN_VAR.getVariableName());
var refreshToken = refreshTokenStore.getToken();

VarTokenStore accessTokenStore = VarTokenStore.get(ACCESS_TOKEN_VAR.getVariableName());
var accessToken = accessTokenStore.getToken();

String resultToken = null;

if(accessToken == null || accessToken.isExpired()) {
// refresh access token
if(refreshToken != null && refreshToken.hasRefreshToken()) {
Expand All @@ -86,7 +86,7 @@ protected final String getAccessToken(ClientRequestContext context) {
else { // use existing token
resultToken = accessToken.accessToken();
}

if (accessToken != null && !accessToken.hasAccessToken()) {
accessTokenStore.setToken(null);
authError().withMessage("Failed to read 'access_token' from " + refreshToken).throwError();
Expand Down Expand Up @@ -128,7 +128,7 @@ private Token getRefreshedAccessToken(Client client, FeatureConfig config, Strin

private Token getAccessToken(Client client, FeatureConfig config, String refreshToken) {
GenericType<Map<String, Object>> map = new GenericType<>(Map.class);

// use refresh uri for refresh token
var tokenUri = StringUtils.isNotBlank(refreshToken) ? uriFactory.getRefreshUri() : uriFactory.getTokenUri();
String authCode = getAuthCode();
Expand All @@ -155,6 +155,6 @@ protected String getAuthCode() {
}

private static BpmPublicErrorBuilder authError() {
return BpmError.create(OAUTH2_ERROR_CODE);
return BpmError.create(RedirectToIdentityProvider.OAUTH2_ERROR_CODE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public static void authRedirect()
.queryParam("client_id", clientId)
.queryParam("scope", scope)
.build();
Ivy.log().debug("created oauth URI: " + uri);
PrimeFaces.current().executeScript("window.open('" + uri.toString() + "', '_top')");
}

Expand Down

0 comments on commit e542864

Please sign in to comment.