Class QDLJSONConfigUtil
- java.lang.Object
-
- org.oa4mp.server.loader.qdl.scripting.QDLJSONConfigUtil
-
- All Implemented Interfaces:
edu.uiuc.ncsa.security.util.scripting.ScriptingConstants
public class QDLJSONConfigUtil extends Object implements edu.uiuc.ncsa.security.util.scripting.ScriptingConstants
Created by Jeff Gaynor
on 2/12/20 at 3:21 PM
-
-
Field Summary
-
Fields inherited from interface edu.uiuc.ncsa.security.util.scripting.ScriptingConstants
ALL_PHASES, AUTH_PHASE, EXCHANGE_PHASE, POST_PREFIX, PRE_PREFIX, REFRESH_PHASE, SRE_EXEC_INIT, SRE_EXEC_PHASE, SRE_NO_EXEC_PHASE, SRE_PHASES, SRE_POST_ALL, SRE_POST_AT, SRE_POST_AUTH, SRE_POST_EXCHANGE, SRE_POST_REFRESH, SRE_POST_USER_INFO, SRE_PRE_ALL, SRE_PRE_AT, SRE_PRE_AUTH, SRE_PRE_EXCHANGE, SRE_PRE_REFRESH, SRE_PRE_USER_INFO, SRE_REQ_ACCESS_TOKEN, SRE_REQ_AUDIENCE, SRE_REQ_AUTH_HEADERS, SRE_REQ_CLAIM_SOURCES, SRE_REQ_CLAIMS, SRE_REQ_EXTENDED_ATTRIBUTES, SRE_REQ_FLOW_STATES, SRE_REQ_MAIL_CONFIG, SRE_REQ_MAIL_MESSAGE, SRE_REQ_PROXY_CLAIMS, SRE_REQ_REFRESH_TOKEN, SRE_REQ_RESOURCE, SRE_REQ_SCOPES, SRE_TX_REQ_AUDIENCE, SRE_TX_REQ_RESOURCES, SRE_TX_REQ_SCOPES, TOKEN_PHASE, USER_INFO_PHASE
-
-
Constructor Summary
Constructors Constructor Description QDLJSONConfigUtil()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static net.sf.json.JSONObjectcreateCfg(String fileName)Creates a script from a file.protected static org.qdl_lang.scripting.QDLScriptcreateCfg(String relativePath, String absolutePath)This will create a QDL script with the relative path.static net.sf.json.JSONObjectcreateCfg(net.sf.json.JSONObject currentConfig, String filePath)This creates a simple script with no path information, just the name for the file and will add it to theJSONObjectargument
So this read a file, creates aQDLScriptfrom its contents and adds it to the current list of scripts.static net.sf.json.JSONObjectcreateCfgFromString(String rawScript, String execPhase)NOTE that this creates the JSONObject from a string, but does not have a file, so it creates a file name that is the execution phase.protected net.sf.json.JSONObjectcreateFileEntry(String contents)static net.sf.json.JSONObjectcreateFS()static net.sf.json.JSONObjectcreateNCSA()static voidmain(String[] args)static net.sf.json.JSONObjectreadDir(File rootDir)NOTE This is under development and should not be used yet!static net.sf.json.JSONObjectreadDir(File rootDir, File dir, net.sf.json.JSONObject repo)static net.sf.json.JSONObjectreadDir(String directory)static edu.uiuc.ncsa.security.util.scripting.ScriptSetreadScriptSet(net.sf.json.JSONObject config)This assumes that the configuration is the scripts tag, not the entire configuration.static net.sf.json.JSONObjectscriptSetToJSON(edu.uiuc.ncsa.security.util.scripting.ScriptSet<? extends org.qdl_lang.scripting.QDLScript> scriptSet)Takes a list of @link QDLScript} objects and turns it in to a QDL configuration, i.e. this gets
{script, script,...}
and returns a new JSON object consisting ofprotected static voidtestLoadDir()
-
-
-
Method Detail
-
scriptSetToJSON
public static net.sf.json.JSONObject scriptSetToJSON(edu.uiuc.ncsa.security.util.scripting.ScriptSet<? extends org.qdl_lang.scripting.QDLScript> scriptSet)
Takes a list of @link QDLScript} objects and turns it in to a QDL configuration, i.e. this gets
{script, script,...}
and returns a new JSON object consisting of
{"qdl":{"scripts":[...]}}turning the list of scripts in to the JSON array.- Parameters:
scriptSet-- Returns:
-
readScriptSet
public static edu.uiuc.ncsa.security.util.scripting.ScriptSet readScriptSet(net.sf.json.JSONObject config)
This assumes that the configuration is the scripts tag, not the entire configuration. I.e. the thing passed in is the entry here:{"qdl":{"scripts":[...]}}This returns the [...] array of script objects as a list ofQDLScriptobjects- Parameters:
config-- Returns:
-
createCfg
public static net.sf.json.JSONObject createCfg(String fileName) throws Throwable
Creates a script from a file. Note that this takes a convenience approach: If the file name is the same as one of the execute phases, the phase is set to that and you are done. If not, you must set it later if needed. See alsocreateCfg(JSONObject, String)which does the actual work.- Parameters:
fileName-- Returns:
- Throws:
Throwable
-
createCfgFromString
public static net.sf.json.JSONObject createCfgFromString(String rawScript, String execPhase) throws Throwable
NOTE that this creates the JSONObject from a string, but does not have a file, so it creates a file name that is the execution phase. This takes a line which is the actual script and a phase then creates aQDLScriptfrom it, which is turned in to a complete JSON configuration.- Parameters:
rawScript-- Returns:
- Throws:
Throwable
-
createCfg
public static net.sf.json.JSONObject createCfg(net.sf.json.JSONObject currentConfig, String filePath) throws ThrowableThis creates a simple script with no path information, just the name for the file and will add it to theJSONObjectargument
So this read a file, creates aQDLScriptfrom its contents and adds it to the current list of scripts.- Parameters:
currentConfig-filePath-- Returns:
- Throws:
Throwable
-
createCfg
protected static org.qdl_lang.scripting.QDLScript createCfg(String relativePath, String absolutePath) throws Throwable
This will create a QDL script with the relative path.- Parameters:
relativePath- -- the path relative some directory including file nameabsolutePath- -- the actual path on the system that will be used to load this script.- Returns:
- Throws:
Throwable
-
readDir
public static net.sf.json.JSONObject readDir(File rootDir) throws Throwable
NOTE This is under development and should not be used yet!
This will take a given directory and read EVERYTHING in it and return a JSON representation of it. The scripting facility will treat this as a library and when evaluating it, will create a virtual file system (VFS) against which you may make calls.
In server mode, only such a VFS is available. Calls for other scripts, loading modules and reading files will all be done against this, so you don't need to worry about it.- Parameters:
rootDir-- Returns:
- Throws:
Throwable
-
readDir
public static net.sf.json.JSONObject readDir(File rootDir, File dir, net.sf.json.JSONObject repo) throws Throwable
- Throws:
Throwable
-
readDir
public static net.sf.json.JSONObject readDir(String directory) throws Throwable
- Throws:
Throwable
-
createNCSA
public static net.sf.json.JSONObject createNCSA()
-
createFileEntry
protected net.sf.json.JSONObject createFileEntry(String contents)
-
createFS
public static net.sf.json.JSONObject createFS()
-
testLoadDir
protected static void testLoadDir()
-
main
public static void main(String[] args)
-
-