Class JWKUtilCommands
- java.lang.Object
-
- edu.uiuc.ncsa.security.util.cli.CommonCommands
-
- org.oa4mp.server.admin.myproxy.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.CommonCommands
Created by Jeff Gaynor
on 5/6/19 at 2:39 PM- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description String
BASE64_FLAG
protected String
CL_IS_PRIVATE_FLAG
protected String
CL_IS_PUBLIC_FLAG
protected String
CL_KEY_FILE_FLAG
protected String
CL_KEY_ID_FLAG
protected String
CL_WELL_KNOWN_FLAG
protected long
DEFAULT_LIFETIME
protected String
JTI_FLAG
protected int
JTI_RADIX
static String
JWK_EXTENSION
protected String
LIFETIME_FLAG
static String
LOAD_KEY
static String
PEM_KEY
protected String
PRINT_CLAIMS_FLAG
protected String
showAllKeys
-
Constructor Summary
Constructors Constructor Description JWKUtilCommands(edu.uiuc.ncsa.security.core.util.MyLoggingFacade logger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
Generate and add keys to an existing key set.void
base64(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
protected void
base64Help()
void
bootstrap()
void
create_claims(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
Create a set of claims and write them to a file in JSON format.void
create_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
void
create_password(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
void
create_public_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
void
create_symmetric_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
void
create_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
protected void
createKeysHelps()
protected void
createPublicKeysHelp()
protected org.oa4mp.server.loader.qdl.util.SigningCommands
createSG(org.oa4mp.server.loader.oauth2.OA2SE oa2SE)
Little fudging of Throwable vs Exceptions.protected void
createTokenHelp()
void
error(Throwable t, String message)
void
generate_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
protected void
generateTokenHelp()
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.protected boolean
getBooleanInput(String prompt)
edu.uiuc.ncsa.security.util.cli.HelpUtil
getHelpUtil()
protected String
getInput(String prompt)
edu.uiuc.ncsa.security.util.jwk.JWKUtil2
getJwkUtil()
String
getPrompt()
void
list_key_ids(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
void
list_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
protected void
listKeysHelp()
static void
main(String[] args)
void
parse_claims(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
Read the claims in a file and verify that they are a valid JSON object.void
print_default_id(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
void
print_public_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
Prints the public keys in JSON format.void
print_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
void
print_well_known(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
protected void
printCreateClaimsHelp()
protected void
printListKeyIDs()
protected void
printParseClaimsHelp()
protected void
printPrintDefaultIDHelp()
protected void
printPublicKeysHelp()
protected void
printSetDefaultIDHelp()
protected void
printTokenHelp()
protected void
printValidateTokenHelp()
protected void
printWellKnownHelp()
void
read_key(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
protected edu.uiuc.ncsa.security.util.jwk.JSONWebKeys
readKeys(File file)
void
set_default_id(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
void
set_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
Set the keys to be used for signing and validation.void
setJwkUtil(edu.uiuc.ncsa.security.util.jwk.JWKUtil2 jwkUtil)
protected void
setKeysHelp()
protected void
showSymmetricKeyHelp(org.oa4mp.server.loader.qdl.util.SigningCommands signingCommands)
void
validate_token(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
protected void
writeFile(String filename, String contents)
Write the contents of a file as a string.-
Methods inherited from class edu.uiuc.ncsa.security.util.cli.CommonCommands
clear_env, clearEnvHelp, debug, echo, echoHelp, error, get_env, getBufferedReader, getDriver, getInput, getIOInterface, getPlaceHolder, getPropertyHelp, getValue, gracefulExit, indentWidth, info, isBatch, isBatchFile, isBatchMode, isDebugOn, isEmpty, isOk, isPrintOuput, isVerbose, logit, print_env, print_help, printEnvHelp, printGetEnvHelp, printReadEnvHelp, printSaveEnvHelp, printSetEnvHelp, read_env, readFile, readJSON, readline, readline, save_env, say, say, say2, sayi, sayii, sayv, set_env, set_output_on, set_verbose_on, setBatchFile, setBatchMode, setBufferedReader, setDebugOn, setDriver, setHelpUtil, setIOInterface, setOutputOnHelp, setPlaceHolder, setPrintOuput, setVerbose, setVerboseHelp, showHelp, version, versionHelp, warn
-
-
-
-
Field Detail
-
JWK_EXTENSION
public static String JWK_EXTENSION
-
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)
-
getPrompt
public String getPrompt()
-
bootstrap
public void bootstrap() throws Throwable
- Specified by:
bootstrap
in interfaceedu.uiuc.ncsa.security.util.cli.Commands
- Overrides:
bootstrap
in classedu.uiuc.ncsa.security.util.cli.CommonCommands
- Throws:
Throwable
-
getHelpUtil
public edu.uiuc.ncsa.security.util.cli.HelpUtil getHelpUtil()
- Specified by:
getHelpUtil
in interfaceedu.uiuc.ncsa.security.util.cli.Commands
- Overrides:
getHelpUtil
in classedu.uiuc.ncsa.security.util.cli.CommonCommands
-
createKeysHelps
protected void createKeysHelps()
-
createSG
protected org.oa4mp.server.loader.qdl.util.SigningCommands createSG(org.oa4mp.server.loader.oauth2.OA2SE oa2SE) throws Exception
Little fudging of Throwable vs Exceptions. Introspection requires that certain methods only throwException
and the constructor throwsThrowable
.- Parameters:
oa2SE
-- Returns:
- Throws:
Exception
-
add_keys
public void add_keys(edu.uiuc.ncsa.security.util.cli.InputLine inputLine) throws Exception
Generate 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(org.oa4mp.server.loader.qdl.util.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 Exception
Set 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 Exception
Prints 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 Exception
Create 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 Exception
Read 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()
-
-