Package edu.uiuc.ncsa.sas.webclient
Class Client
- java.lang.Object
-
- edu.uiuc.ncsa.security.servlet.ServiceClient
-
- edu.uiuc.ncsa.sas.webclient.Client
-
- All Implemented Interfaces:
SASConstants
public class Client extends ServiceClient implements SASConstants
Created by Jeff Gaynor
on 8/18/22 at 3:14 PM
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_CLIENT_ID
static String
CONFIG_HOST
static String
CONFIG_PRIVATE_KEY
static String
CONFIG_TR_DN
static String
CONFIG_TR_FILE
static String
CONFIG_TR_PASSWORD
static String
CONFIG_TR_TYPE
static String
FLAG_CONFIG
static String
FLAG_EDIT
static String
FLAG_HELP
static String
FLAG_NEW
static String
FLAG_PRINT_PUBLIC_KEY
static String
FLAG_VERBOSE
-
Fields inherited from class edu.uiuc.ncsa.security.servlet.ServiceClient
clientPool, ECHO_REQUEST, ECHO_RESPONSE, ENCODING
-
Fields inherited from interface edu.uiuc.ncsa.sas.SASConstants
ACTION_EXECUTE, ACTION_INVOKE, ACTION_LOGOFF, ACTION_LOGON, ACTION_NEW_KEY, CLIENT_ID_HEAD, HEADER_SESSION_ID, KEYS_ACTION, KEYS_ARGUMENT, KEYS_COMMENT, KEYS_EXECUTABLE_NAME, KEYS_INTERNAL_ID, KEYS_METHOD, KEYS_PROMPT, KEYS_SAS, KEYS_STATE, KEYS_SUBJECT, KEYS_SUBJECT_ID, KEYS_SUBJECT_SESSION_ID, KEYS_TYPE, REQUEST_TYPE, RESPONSE_CONTENT, RESPONSE_MESSAGE, RESPONSE_PROMPT, RESPONSE_SESSION_ID, RESPONSE_STATUS, RESPONSE_STATUS_ERROR, RESPONSE_STATUS_OK, RESPONSE_SYMMETRIC_KEY, RESPONSE_TYPE, RESPONSE_TYPE_ERROR, RESPONSE_TYPE_LOGOFF, RESPONSE_TYPE_LOGON, RESPONSE_TYPE_NEW_KEY, RESPONSE_TYPE_OUTPUT, RESPONSE_TYPE_PROMPT
-
-
Constructor Summary
Constructors Constructor Description Client(URI address)
Client(URI address, SSLConfiguration sslConfiguration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
cli()
Avery, very simple command line.static String
createConfig(String filename, boolean isNew)
Create a new configuration file on the flyResponse
doExecute(String contents)
Response
doInvoke(String x)
Response
doInvoke(String name, net.sf.json.JSONArray args)
Response
doLogoff()
Response
doLogon()
Response
doLogon(Identifier identifier)
Response
doNewKey(int keySize)
Response
doPost(Action action)
Wraps the action in and does the post.Response
doPost(Action action, boolean rsaEncrypt)
String
doPost(String contents, boolean rsaEncrypt)
String
doPost(String content, String id, String secret)
protected static void
editConfigFile(XMLMap xmlMap)
Response
execute(Action action)
Call this for an arbitraryAction
.static BufferedReader
getBufferedReader()
XMLMap
getConfig()
static String
getInput(String prompt)
PrivateKey
getPrivateKey()
PublicKey
getPublicKey()
ResponseDeserializer
getResponseDeserializer()
byte[]
getsKey()
The symmetric key.static void
main(String[] args)
protected static String
multiLineInput(String oldValue, String key)
protected static void
newConfigFile(XMLMap xmlMap)
static Client
newInstance(InputLine inputLine)
Create a new instance of this client.protected static XMLMap
readConfig(String fileName)
static String
readline()
Read a single lineprotected String
RSADecrypt(String content64)
protected String
RSAEncrypt(String contents)
static void
say(Object x)
protected String
sDecrypt(String content64)
protected String
sEncrypt(String contents)
void
setConfig(XMLMap config)
void
setPrivateKey(PrivateKey privateKey)
void
setPublicKey(PublicKey publicKey)
void
setResponseDeserializer(ResponseDeserializer responseDeserializer)
void
setsKey(byte[] sKey)
protected static void
updateItem(XMLMap xmlMap, String key)
-
Methods inherited from class edu.uiuc.ncsa.security.servlet.ServiceClient
convertToStringRequest, convertToStringRequest, decode, doBearerRequest, doBearerRequest, doGet, doGet, doGet, doGet, doPost, doPost, doPost, doRequest, doRequest, encode, host, isVerbose, setVerbose
-
-
-
-
Field Detail
-
FLAG_EDIT
public static final String FLAG_EDIT
- See Also:
- Constant Field Values
-
FLAG_CONFIG
public static final String FLAG_CONFIG
- See Also:
- Constant Field Values
-
FLAG_NEW
public static final String FLAG_NEW
- See Also:
- Constant Field Values
-
FLAG_HELP
public static final String FLAG_HELP
- See Also:
- Constant Field Values
-
FLAG_VERBOSE
public static final String FLAG_VERBOSE
- See Also:
- Constant Field Values
-
FLAG_PRINT_PUBLIC_KEY
public static final String FLAG_PRINT_PUBLIC_KEY
- See Also:
- Constant Field Values
-
CONFIG_CLIENT_ID
public static final String CONFIG_CLIENT_ID
- See Also:
- Constant Field Values
-
CONFIG_PRIVATE_KEY
public static final String CONFIG_PRIVATE_KEY
- See Also:
- Constant Field Values
-
CONFIG_TR_FILE
public static final String CONFIG_TR_FILE
- See Also:
- Constant Field Values
-
CONFIG_TR_PASSWORD
public static final String CONFIG_TR_PASSWORD
- See Also:
- Constant Field Values
-
CONFIG_TR_TYPE
public static final String CONFIG_TR_TYPE
- See Also:
- Constant Field Values
-
CONFIG_TR_DN
public static final String CONFIG_TR_DN
- See Also:
- Constant Field Values
-
CONFIG_HOST
public static final String CONFIG_HOST
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Client
public Client(URI address, SSLConfiguration sslConfiguration)
-
Client
public Client(URI address)
-
-
Method Detail
-
getResponseDeserializer
public ResponseDeserializer getResponseDeserializer()
-
setResponseDeserializer
public void setResponseDeserializer(ResponseDeserializer responseDeserializer)
-
say
public static void say(Object x)
-
readline
public static String readline() throws IOException
Read a single line- Returns:
- Throws:
IOException
-
getBufferedReader
public static BufferedReader getBufferedReader()
-
readConfig
protected static XMLMap readConfig(String fileName) throws IOException
- Throws:
IOException
-
createConfig
public static String createConfig(String filename, boolean isNew) throws IOException
Create a new configuration file on the fly- Parameters:
filename
- file to create (if null, user is prompted)- Returns:
- filename, either original or the one the user gave.
- Throws:
IOException
-
newConfigFile
protected static void newConfigFile(XMLMap xmlMap) throws IOException
- Throws:
IOException
-
editConfigFile
protected static void editConfigFile(XMLMap xmlMap) throws IOException
- Throws:
IOException
-
newInstance
public static Client newInstance(InputLine inputLine) throws Throwable
Create a new instance of this client. The arguments are- -cfg - path to the config file
- -v - verbose. Be yacky (mostly for debugging the client itself
- -edit - create a new config file if none exists.
- Parameters:
inputLine
-- Returns:
- Throws:
Throwable
-
getPublicKey
public PublicKey getPublicKey()
-
setPublicKey
public void setPublicKey(PublicKey publicKey)
-
getConfig
public XMLMap getConfig()
-
setConfig
public void setConfig(XMLMap config)
-
cli
protected void cli() throws Throwable
Avery, very simple command line. This is normally not used for anything except testing. When this class has main called, this is what you get.- Throws:
Throwable
-
doLogon
public Response doLogon() throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeySpecException, IOException, BadPaddingException, InvalidKeyException
-
doLogon
public Response doLogon(Identifier identifier) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, InvalidKeySpecException, IOException, BadPaddingException, InvalidKeyException
-
execute
public Response execute(Action action) throws Throwable
Call this for an arbitraryAction
. It will call the SAS and return the response.- Parameters:
action
-- Returns:
- Throws:
Throwable
-
doInvoke
public Response doInvoke(String name, net.sf.json.JSONArray args) throws Throwable
- Throws:
Throwable
-
RSAEncrypt
protected String RSAEncrypt(String contents) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidKeyException
-
RSADecrypt
protected String RSADecrypt(String content64) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidKeyException
-
getPrivateKey
public PrivateKey getPrivateKey()
-
setPrivateKey
public void setPrivateKey(PrivateKey privateKey)
-
getsKey
public byte[] getsKey()
The symmetric key.- Returns:
-
setsKey
public void setsKey(byte[] sKey)
-
doPost
public String doPost(String contents, boolean rsaEncrypt) throws Throwable
- Throws:
Throwable
-
doPost
public Response doPost(Action action) throws Throwable
Wraps the action in and does the post. It does symmetric key decryption. Assumption is a single response- Parameters:
action
-- Returns:
- Throws:
Throwable
-
doPost
public Response doPost(Action action, boolean rsaEncrypt) throws Throwable
- Throws:
Throwable
-
multiLineInput
protected static String multiLineInput(String oldValue, String key) throws IOException
- Throws:
IOException
-
-