Package net.shibboleth.idp.cli
Class AbstractCommandLineArguments
- java.lang.Object
-
- net.shibboleth.idp.cli.AbstractCommandLineArguments
-
- All Implemented Interfaces:
CommandLineArguments
- Direct Known Subclasses:
MetadataQueryArguments,ReloadMetadataArguments,ReloadServiceArguments,ResolverTestArguments,StatusArguments
public abstract class AbstractCommandLineArguments extends Object implements CommandLineArguments
Base class for JCommander command line argument handling for an HTTP-based remote service call, with an abstract method that adds to a URL based on a derived class' arguments.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBASEURL_PROPERTYName of system property for overriding default URL.private booleandisableNameCheckingDisable TLS certificate name checking.private List<String>headersHTTP header name/value pair(s).private booleanhelpDisplay command usage.private StringmethodHTTP method to use, GET by default.private StringpasswordPassword to be used in the HTTP-Basic authentication.private StringpathPath to add to base URL.private StringtrustStoreTrust store for SSL connectivity.private StringtrustStorePasswordTrust store password for SSL connectivity.private StringtrustStoreTypeTrust store type for SSL connectivity.private StringurlBase of URL to invoke.private StringusernameUsername to be used in the HTTP-Basic authentication.
-
Constructor Summary
Constructors Constructor Description AbstractCommandLineArguments()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URLbuildURL()Compute the full URL to connect to.protected StringBuilderdoBuildURL(StringBuilder builder)Override this method to modify the eventual URL and attach any parameters.StringgetBasicAuthHeader()Builds the HTTP-Basic value to be used in the Authorization -header, containing username and password.Map<String,String>getHeaders()Values of "header" parameter.booleangetHelp()Value of "help" parameter.StringgetMethod()Value of "method" parameter.StringgetPassword()Value of "password" parameter.StringgetPath()Value of "path" parameter.StringgetTrustStore()Value of "trustStore" parameter.StringgetTrustStorePassword()Value of "trustStorePassword" parameter.StringgetTrustStoreType()Value of "trustStoreType" parameter.StringgetURL()Value of "url" parameter.StringgetUsername()Value of "username" parameter.private voidinstallTrustStore()Use the configured parameters to set global JVM trust store parameters for SSL connectivity.booleanisDisableNameChecking()Value of "disableNameChecking" parameter.booleanisUsage()Should command usage be displayed?voidvalidate()Validate the parameter set.
-
-
-
Field Detail
-
BASEURL_PROPERTY
@Nonnull @NotEmpty public static final String BASEURL_PROPERTY
Name of system property for overriding default URL.- See Also:
- Constant Field Values
-
help
private boolean help
Display command usage.
-
url
@Nonnull private String url
Base of URL to invoke.
-
path
@Nullable private String path
Path to add to base URL.
-
disableNameChecking
private boolean disableNameChecking
Disable TLS certificate name checking.
-
trustStore
@Nullable private String trustStore
Trust store for SSL connectivity.
-
trustStoreType
@Nullable private String trustStoreType
Trust store type for SSL connectivity.
-
trustStorePassword
@Nullable private String trustStorePassword
Trust store password for SSL connectivity.
-
username
@Nullable private String username
Username to be used in the HTTP-Basic authentication.
-
password
@Nullable private String password
Password to be used in the HTTP-Basic authentication.
-
-
Method Detail
-
getHelp
public boolean getHelp()
Value of "help" parameter.- Returns:
- parameter value
-
getURL
@Nonnull public String getURL()
Value of "url" parameter.Defaults to http://localhost
- Returns:
- parameter value
-
getPath
@Nullable public String getPath()
Value of "path" parameter.- Returns:
- parameter value
-
getTrustStore
@Nullable public String getTrustStore()
Value of "trustStore" parameter.- Returns:
- parameter value
-
getTrustStoreType
@Nullable public String getTrustStoreType()
Value of "trustStoreType" parameter.- Returns:
- parameter value
-
getTrustStorePassword
@Nullable public String getTrustStorePassword()
Value of "trustStorePassword" parameter.- Returns:
- parameter value
-
isDisableNameChecking
public boolean isDisableNameChecking()
Value of "disableNameChecking" parameter.- Returns:
- parameter value
-
getUsername
@Nullable public String getUsername()
Value of "username" parameter.- Returns:
- username parameter
- Since:
- 4.2.0
-
getPassword
@Nullable public String getPassword()
Value of "password" parameter.- Returns:
- password parameter
- Since:
- 4.2.0
-
getMethod
@Nullable @NotEmpty public String getMethod()
Value of "method" parameter.- Specified by:
getMethodin interfaceCommandLineArguments- Returns:
- method
- Since:
- 4.2.0
-
getHeaders
@Nullable @NonnullElements @NotLive @Unmodifiable public Map<String,String> getHeaders()
Values of "header" parameter.- Specified by:
getHeadersin interfaceCommandLineArguments- Returns:
- header parameter
-
isUsage
public boolean isUsage()
Should command usage be displayed?- Specified by:
isUsagein interfaceCommandLineArguments- Returns:
- true iff this is a help request
-
validate
public void validate()
Validate the parameter set.- Specified by:
validatein interfaceCommandLineArguments
-
buildURL
@Nonnull public URL buildURL() throws MalformedURLException
Compute the full URL to connect to.- Specified by:
buildURLin interfaceCommandLineArguments- Returns:
- the URL to connect to
- Throws:
MalformedURLException- if the URL constructed is invalid
-
doBuildURL
@Nonnull protected StringBuilder doBuildURL(@Nonnull StringBuilder builder)
Override this method to modify the eventual URL and attach any parameters.- Parameters:
builder- contains the URL in a partial state of construction, possibly including query string- Returns:
- a builder containing the modified URL string
-
getBasicAuthHeader
@Nullable @NotEmpty public String getBasicAuthHeader()
Builds the HTTP-Basic value to be used in the Authorization -header, containing username and password.- Specified by:
getBasicAuthHeaderin interfaceCommandLineArguments- Returns:
- The value to be used in the Authorization -header, or null if username or password didn't have a value.
-
installTrustStore
private void installTrustStore()
Use the configured parameters to set global JVM trust store parameters for SSL connectivity.
-
-