diff --git a/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalIntrospectionService.java b/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalIntrospectionService.java index 46644dc3bb2..975cfb7b3e3 100644 --- a/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalIntrospectionService.java +++ b/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalIntrospectionService.java @@ -13,13 +13,14 @@ import io.jans.model.custom.script.conf.CustomScriptConfiguration; import io.jans.model.custom.script.type.introspection.IntrospectionType; import io.jans.service.custom.script.ExternalScriptService; -import org.jetbrains.annotations.NotNull; -import org.json.JSONObject; - import jakarta.ejb.DependsOn; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.inject.Named; +import jakarta.ws.rs.WebApplicationException; +import org.jetbrains.annotations.NotNull; +import org.json.JSONObject; + import java.util.List; /** @@ -93,7 +94,10 @@ private boolean executeExternalModifyResponse(CustomScriptConfiguration scriptCo final boolean result = script.modifyResponse(responseAsJsonObject, context); log.trace("Finished external 'executeExternalModifyResponse' method, script name: {}, responseAsJsonObject: {} , context: {}, result: {}", scriptConf.getName(), responseAsJsonObject, context, result); + context.throwWebApplicationExceptionIfSet(); return result; + } catch (WebApplicationException e) { + throw e; } catch (Exception ex) { log.error(ex.getMessage(), ex); saveScriptError(scriptConf.getCustomScript(), ex); diff --git a/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalUpdateTokenService.java b/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalUpdateTokenService.java index 19c8b146a18..e2715c5e149 100644 --- a/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalUpdateTokenService.java +++ b/jans-auth-server/server/src/main/java/io/jans/as/server/service/external/ExternalUpdateTokenService.java @@ -15,9 +15,10 @@ import io.jans.model.custom.script.conf.CustomScriptConfiguration; import io.jans.model.custom.script.type.token.UpdateTokenType; import io.jans.service.custom.script.ExternalScriptService; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.ws.rs.WebApplicationException; import org.jetbrains.annotations.NotNull; -import jakarta.enterprise.context.ApplicationScoped; import java.util.List; import java.util.function.Function; @@ -42,7 +43,10 @@ public boolean modifyIdTokenMethod(CustomScriptConfiguration script, JsonWebResp final boolean result = updateTokenType.modifyIdToken(jsonWebResponse, context); log.trace("Finished 'updateToken' method, script name: {}, jsonWebResponse: {}, context: {}, result: {}", script.getName(), jsonWebResponse, context, result); + context.throwWebApplicationExceptionIfSet(); return result; + } catch (WebApplicationException e) { + throw e; } catch (Exception ex) { log.error(ex.getMessage(), ex); saveScriptError(script.getCustomScript(), ex); @@ -84,7 +88,10 @@ public int getRefreshTokenLifetimeInSeconds(CustomScriptConfiguration script, Ex final int result = updateTokenType.getRefreshTokenLifetimeInSeconds(context); log.trace("Finished 'getRefreshTokenLifetimeInSeconds' method, script name: {}, context: {}, result: {}", script.getName(), context, result); + context.throwWebApplicationExceptionIfSet(); return result; + } catch (WebApplicationException e) { + throw e; } catch (Exception ex) { log.error(ex.getMessage(), ex); saveScriptError(script.getCustomScript(), ex); @@ -133,7 +140,10 @@ public boolean modifyRefreshToken(CustomScriptConfiguration script, RefreshToken final boolean result = updateTokenType.modifyRefreshToken(refreshToken, context); log.trace("Finished 'modifyRefreshToken' method, script name: {}, context: {}, result: {}", script.getName(), context, result); + context.throwWebApplicationExceptionIfSet(); return result; + } catch (WebApplicationException e) { + throw e; } catch (Exception ex) { log.error(ex.getMessage(), ex); saveScriptError(script.getCustomScript(), ex); @@ -167,7 +177,10 @@ public boolean modifyAccessToken(CustomScriptConfiguration script, AccessToken a final boolean result = updateTokenType.modifyAccessToken(accessToken, context); log.trace("Finished 'modifyAccessToken' method, script name: {}, context: {}, result: {}", script.getName(), context, result); + context.throwWebApplicationExceptionIfSet(); return result; + } catch (WebApplicationException e) { + throw e; } catch (Exception ex) { log.error(ex.getMessage(), ex); saveScriptError(script.getCustomScript(), ex); @@ -201,7 +214,10 @@ public int getAccessTokenLifetimeInSeconds(CustomScriptConfiguration script, Ext final int result = updateTokenType.getAccessTokenLifetimeInSeconds(context); log.trace("Finished 'getAccessTokenLifetimeInSeconds' method, script name: {}, context: {}, result: {}", script.getName(), context, result); + context.throwWebApplicationExceptionIfSet(); return result; + } catch (WebApplicationException e) { + throw e; } catch (Exception ex) { log.error(ex.getMessage(), ex); saveScriptError(script.getCustomScript(), ex); @@ -235,7 +251,10 @@ public int getIdTokenLifetimeInSeconds(CustomScriptConfiguration script, Externa final int result = updateTokenType.getIdTokenLifetimeInSeconds(context); log.trace("Finished 'getIdTokenLifetimeInSeconds' method, script name: {}, context: {}, result: {}", script.getName(), context, result); + context.throwWebApplicationExceptionIfSet(); return result; + } catch (WebApplicationException e) { + throw e; } catch (Exception ex) { log.error(ex.getMessage(), ex); saveScriptError(script.getCustomScript(), ex);