Skip to content

Commit

Permalink
feat(jans-auth-server): added post response modification method
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriyz committed Jan 19, 2022
1 parent 9f18613 commit db936f9
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.jans.as.model.error.ErrorResponseFactory;
import io.jans.as.model.jwt.Jwt;
import io.jans.as.model.util.CertUtils;
import io.jans.as.server.model.common.ExecutionContext;
import io.jans.as.server.service.external.context.DynamicClientRegistrationContext;
import io.jans.model.custom.script.CustomScriptType;
import io.jans.model.custom.script.conf.CustomScriptConfiguration;
Expand Down Expand Up @@ -231,4 +232,27 @@ public boolean isCertValidForClient(X509Certificate cert, DynamicClientRegistrat
return false;
}
}

public boolean modifyPostResponse(JSONObject responseAsJsonObject, ExecutionContext context) {
CustomScriptConfiguration script = defaultExternalCustomScript;

try {
if (log.isTraceEnabled()) {
log.trace("Executing python 'modifyPostResponse' method, script name: {}, context: {}, response: {}", script.getName(), context, responseAsJsonObject.toString());
}
context.setScript(script);

ClientRegistrationType type = (ClientRegistrationType) script.getExternalType();
final boolean result = type.modifyPostResponse(responseAsJsonObject, context);
if (log.isTraceEnabled()) {
log.trace("Finished 'modifyPostResponse' method, script name: {}, context: {}, result: {}, response: {}", script.getName(), context, result, responseAsJsonObject.toString());
}

return result;
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
saveScriptError(script.getCustomScript(), ex);
}
return false;
}
}

0 comments on commit db936f9

Please sign in to comment.