Class JWKUtilCommands
- java.lang.Object
-
- edu.uiuc.ncsa.security.util.cli.AbstractCommandsImpl
-
- edu.uiuc.ncsa.security.util.cli.CommonCommands2
-
- org.oa4mp.server.admin.oauth2.tools.JWKUtilCommands
-
- All Implemented Interfaces:
edu.uiuc.ncsa.security.core.Logable,edu.uiuc.ncsa.security.util.cli.Commands,Serializable
public class JWKUtilCommands extends edu.uiuc.ncsa.security.util.cli.CommonCommands2Created by Jeff Gaynor
on 5/6/19 at 2:39 PM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description StringBASE64_FLAGprotected StringCL_IS_PRIVATE_FLAGprotected StringCL_IS_PUBLIC_FLAGprotected StringCL_KEY_FILE_FLAGprotected StringCL_KEY_ID_FLAGprotected StringCL_WELL_KNOWN_FLAGprotected longDEFAULT_LIFETIMEprotected StringJTI_FLAGprotected intJTI_RADIXprotected StringLIFETIME_FLAGstatic StringLOAD_KEYstatic StringPEM_KEYprotected StringPRINT_CLAIMS_FLAGprotected StringshowAllKeys
-
Constructor Summary
Constructors Constructor Description JWKUtilCommands(edu.uiuc.ncsa.security.util.cli.CLIDriver driver)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabout(boolean showBanner, boolean showHeader)voidadd_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)Generate and add keys to an existing key set.voidbase64(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)protected voidbase64Help()voidcreate_claims(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)Create a set of claims and write them to a file in JSON format.voidcreate_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)voidcreate_password(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)voidcreate_public_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)voidcreate_symmetric_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)voidcreate_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)protected voidcreateKeysHelps()protected voidcreatePublicKeysHelp()protected SigningCommandscreateSG(OA2SE oa2SE)Little fudging of Throwable vs Exceptions.protected voidcreateTokenHelp()voidgenerate_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)protected voidgenerateTokenHelp()protected StringgetArgValue(edu.uiuc.ncsa.security.util.cli.InputLine inputLine, String key)This will take an input line and search for the arg, returning the next value.protected booleangetBooleanInput(String prompt)protected StringgetInput(String prompt)edu.uiuc.ncsa.security.util.jwk.JWKUtil2getJwkUtil()StringgetName()StringgetPrompt()voidinitialize()voidlist_key_ids(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)voidlist_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)protected voidlistKeysHelp()voidload(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)static voidmain(String[] args)voidparse_claims(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)Read the claims in a file and verify that they are a valid JSON object.voidprint_default_id(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)voidprint_public_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)Prints the public keys in JSON format.voidprint_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)voidprint_well_known(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)protected voidprintCreateClaimsHelp()protected voidprintListKeyIDs()protected voidprintParseClaimsHelp()protected voidprintPrintDefaultIDHelp()protected voidprintPublicKeysHelp()protected voidprintSetDefaultIDHelp()protected voidprintTokenHelp()protected voidprintValidateTokenHelp()protected voidprintWellKnownHelp()voidread_key(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)protected edu.uiuc.ncsa.security.util.jwk.JSONWebKeysreadKeys(File file)voidset_default_id(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)voidset_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)Set the keys to be used for signing and validation.voidsetJwkUtil(edu.uiuc.ncsa.security.util.jwk.JWKUtil2 jwkUtil)protected voidsetKeysHelp()protected voidshowSymmetricKeyHelp(SigningCommands signingCommands)voidvalidate_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)protected voidwriteFile(String filename, String contents)Write the contents of a file as a string.-
Methods inherited from class edu.uiuc.ncsa.security.util.cli.CommonCommands2
getIOInterface, getPlaceHolder, getValue, isEmpty, isThrowExceptions, isVerbose, print_help, say2, sayii, set_output_on, set_verbose_on, setOutputOnHelp, setPlaceHolder, setThrowExceptions, setVerboseHelp, version, versionHelp
-
Methods inherited from class edu.uiuc.ncsa.security.util.cli.AbstractCommandsImpl
bootstrap, bootstrap, clear_env, clearEnvHelp, debug, error, error, get_env, getDriver, getHelpUtil, getInput, getLogoName, getPropertyHelp, gracefulExit, hasLogger, indentWidth, info, initHelp, isDebugOn, isOk, isShowHeader, isShowLogo, print_env, printEnvHelp, printGetEnvHelp, printReadEnvHelp, printSaveEnvHelp, printSetEnvHelp, read_env, readJSON, readline, readline, save_env, say, say, sayi, sayv, set_env, setDebugOn, setDriver, setLogoName, setShowHeader, setShowLogo, showHelp, warn
-
-
-
-
Field Detail
-
LOAD_KEY
public static String LOAD_KEY
-
PEM_KEY
public static String PEM_KEY
-
showAllKeys
protected String showAllKeys
-
BASE64_FLAG
public String BASE64_FLAG
-
CL_KEY_FILE_FLAG
protected String CL_KEY_FILE_FLAG
-
CL_KEY_ID_FLAG
protected String CL_KEY_ID_FLAG
-
CL_WELL_KNOWN_FLAG
protected String CL_WELL_KNOWN_FLAG
-
CL_IS_PUBLIC_FLAG
protected String CL_IS_PUBLIC_FLAG
-
CL_IS_PRIVATE_FLAG
protected String CL_IS_PRIVATE_FLAG
-
LIFETIME_FLAG
protected String LIFETIME_FLAG
-
JTI_FLAG
protected String JTI_FLAG
-
PRINT_CLAIMS_FLAG
protected String PRINT_CLAIMS_FLAG
-
DEFAULT_LIFETIME
protected long DEFAULT_LIFETIME
-
JTI_RADIX
protected int JTI_RADIX
-
-
Method Detail
-
getJwkUtil
public edu.uiuc.ncsa.security.util.jwk.JWKUtil2 getJwkUtil()
-
setJwkUtil
public void setJwkUtil(edu.uiuc.ncsa.security.util.jwk.JWKUtil2 jwkUtil)
-
about
public void about(boolean showBanner, boolean showHeader)- Specified by:
aboutin classedu.uiuc.ncsa.security.util.cli.AbstractCommandsImpl
-
initialize
public void initialize() throws Throwable- Specified by:
initializein classedu.uiuc.ncsa.security.util.cli.AbstractCommandsImpl- Throws:
Throwable
-
load
public void load(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Throwable- Specified by:
loadin classedu.uiuc.ncsa.security.util.cli.AbstractCommandsImpl- Throws:
Throwable
-
getName
public String getName()
-
getPrompt
public String getPrompt()
-
createKeysHelps
protected void createKeysHelps()
-
createSG
protected SigningCommands createSG(OA2SE oa2SE) throws Exception
Little fudging of Throwable vs Exceptions. Introspection requires that certain methods only throwExceptionand the constructor throwsThrowable.- Parameters:
oa2SE-- Returns:
- Throws:
Exception
-
add_keys
public void add_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws ExceptionGenerate and add keys to an existing key set. If the key set is empty or missing, it will be created. Note that this generates full sets of keys. If a file is specified, then that will be updated rather than the currently active set of keys.- Parameters:
inputLine-- Throws:
Exception
-
create_keys
public void create_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
showSymmetricKeyHelp
protected void showSymmetricKeyHelp(SigningCommands signingCommands)
-
create_password
public void create_password(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
create_symmetric_keys
public void create_symmetric_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
print_well_known
public void print_well_known(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
printWellKnownHelp
protected void printWellKnownHelp()
-
setKeysHelp
protected void setKeysHelp()
-
set_keys
public void set_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws ExceptionSet the keys to be used for signing and validation.- Parameters:
inputLine-- Throws:
Exception
-
readKeys
protected edu.uiuc.ncsa.security.util.jwk.JSONWebKeys readKeys(File file) throws Exception
- Throws:
Exception
-
read_key
public void read_key(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
listKeysHelp
protected void listKeysHelp()
-
printPublicKeysHelp
protected void printPublicKeysHelp()
-
print_public_keys
public void print_public_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws ExceptionPrints the public keys in JSON format.- Parameters:
inputLine-- Throws:
Exception
-
createPublicKeysHelp
protected void createPublicKeysHelp()
-
create_public_keys
public void create_public_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
writeFile
protected void writeFile(String filename, String contents) throws Exception
Write the contents of a file as a string.- Parameters:
filename-contents-- Throws:
Exception
-
list_keys
public void list_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
printCreateClaimsHelp
protected void printCreateClaimsHelp()
-
create_claims
public void create_claims(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws ExceptionCreate a set of claims and write them to a file in JSON format.- Parameters:
inputLine-- Throws:
Exception
-
getBooleanInput
protected boolean getBooleanInput(String prompt) throws IOException
- Throws:
IOException
-
getInput
protected String getInput(String prompt) throws IOException
- Throws:
IOException
-
printSetDefaultIDHelp
protected void printSetDefaultIDHelp()
-
set_default_id
public void set_default_id(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
printPrintDefaultIDHelp
protected void printPrintDefaultIDHelp()
-
print_default_id
public void print_default_id(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
printParseClaimsHelp
protected void printParseClaimsHelp()
-
parse_claims
public void parse_claims(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws ExceptionRead the claims in a file and verify that they are a valid JSON object.- Parameters:
inputLine-- Throws:
Exception
-
getArgValue
protected String getArgValue(edu.uiuc.ncsa.security.util.cli.InputLine inputLine, String key)
This will take an input line and search for the arg, returning the next value. E.g. if the input line is "-file y -id z -v" then supplying "-file" as the key here will return "y". If there is no such key, then a null is returned.- Parameters:
inputLine-key-- Returns:
-
createTokenHelp
protected void createTokenHelp()
-
create_token
public void create_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
generateTokenHelp
protected void generateTokenHelp()
-
generate_token
public void generate_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
printTokenHelp
protected void printTokenHelp()
-
print_token
public void print_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
printListKeyIDs
protected void printListKeyIDs()
-
list_key_ids
public void list_key_ids(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
printValidateTokenHelp
protected void printValidateTokenHelp()
-
validate_token
public void validate_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception- Throws:
Exception
-
main
public static void main(String[] args)
-
base64Help
protected void base64Help()
-
-