Class JWKUtilCommands

  • All Implemented Interfaces:
    edu.uiuc.ncsa.security.core.Logable, edu.uiuc.ncsa.security.util.cli.Commands

    public class JWKUtilCommands
    extends edu.uiuc.ncsa.security.util.cli.CommonCommands

    Created by Jeff Gaynor
    on 5/6/19 at 2:39 PM

    • 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
    • Constructor Detail

      • JWKUtilCommands

        public JWKUtilCommands​(edu.uiuc.ncsa.security.core.util.MyLoggingFacade logger)
                        throws Throwable
        Throws:
        Throwable
    • 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 interface edu.uiuc.ncsa.security.util.cli.Commands
        Overrides:
        bootstrap in class edu.uiuc.ncsa.security.util.cli.CommonCommands
        Throws:
        Throwable
      • getHelpUtil

        public edu.uiuc.ncsa.security.util.cli.HelpUtil getHelpUtil()
        Specified by:
        getHelpUtil in interface edu.uiuc.ncsa.security.util.cli.Commands
        Overrides:
        getHelpUtil in class edu.uiuc.ncsa.security.util.cli.CommonCommands
      • createKeysHelps

        protected void createKeysHelps()
      • createSG

        protected edu.uiuc.ncsa.myproxy.oa4mp.qdl.util.SigningCommands createSG​(edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2SE oa2SE)
                                                                         throws Exception
        Little fudging of Throwable vs Exceptions. Introspection requires that certain methods only throw Exception and the constructor throws Throwable.
        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​(edu.uiuc.ncsa.myproxy.oa4mp.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
      • 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()
      • base64

        public void base64​(edu.uiuc.ncsa.security.util.cli.InputLine inputLine)
                    throws Exception
        Throws:
        Exception