-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jans-core): added pure java discovery sample custom script
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
jans-linux-setup/jans_setup/static/extension/discovery/Discovery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* Copyright (c) 2022, Gluu | ||
Author: Yuriy Z | ||
*/ | ||
|
||
import io.jans.model.SimpleCustomProperty; | ||
import io.jans.model.custom.script.model.CustomScript; | ||
import io.jans.model.custom.script.type.discovery.DiscoveryType; | ||
import io.jans.service.custom.script.CustomScriptManager; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.json.JSONObject; | ||
|
||
import java.util.Map; | ||
|
||
public class Discovery implements DiscoveryType { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(Discovery.class); | ||
private static final Logger scriptLogger = LoggerFactory.getLogger(CustomScriptManager.class); | ||
|
||
@Override | ||
public boolean init(Map<String, SimpleCustomProperty> configurationAttributes) { | ||
log.info("Init of Discovery Java custom script"); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean init(CustomScript customScript, Map<String, SimpleCustomProperty> configurationAttributes) { | ||
log.info("Init of Discovery Java custom script"); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean destroy(Map<String, SimpleCustomProperty> configurationAttributes) { | ||
log.info("Destroy of Discovery Java custom script"); | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getApiVersion() { | ||
log.info("getApiVersion Discovery Java custom script: 11"); | ||
return 11; | ||
} | ||
|
||
@Override | ||
public boolean modifyResponse(Object responseAsJsonObject, Object context) { | ||
scriptLogger.info("write to script logger"); | ||
JSONObject response = (JSONObject) responseAsJsonObject; | ||
response.accumulate("key_from_java", "value_from_script_on_java"); | ||
return true; | ||
} | ||
} |