public class HTTPServiceImpl extends Object implements HTTPService
Modifier and Type | Field and Description |
---|---|
static String |
TOKEN_CACHE_FILENAME |
Constructor and Description |
---|
HTTPServiceImpl() |
Modifier and Type | Method and Description |
---|---|
String |
getCachedToken(String subjectDN)
Fetch token if cached
|
String |
getKeyStoreSubjectDN(KeyStore ks)
Get Subject DN from Keystore instance
|
String |
postSwid(String clientCertificatePath,
String clientCertificatePassword,
String passwordSeed,
List<String> swidFiles,
Action action,
TagType type) |
static String |
prettyFormat(String input)
Format XML input String
|
static String |
prettyFormat(String input,
int indent)
Format XML response for human readability
|
String |
sendSWIDData(org.apache.http.impl.client.CloseableHttpClient client,
String token,
List<String> swidFiles,
Action action,
TagType type)
Insert or Update end points
|
void |
setTokenCache(String token,
String subjectDN)
Set token cache
|
public static final String TOKEN_CACHE_FILENAME
public String postSwid(String clientCertificatePath, String clientCertificatePassword, String passwordSeed, List<String> swidFiles, Action action, TagType type) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException, UnrecoverableKeyException, TransformerException
postSwid
in interface HTTPService
clientCertificatePath
- location of client keystoreclientCertificatePassword
- password of client keystorepasswordSeed
- the password seedswidFiles
- the list of SWID tags to POSTaction
- the action either insert or update to performs on the SWID tagstype
- the SWID tag typeKeyStoreException
- if there are errors with loading client certificateNoSuchAlgorithmException
- if there are errorsCertificateException
- if there are errors with loading client certificateIOException
- if there are errors with read or writeKeyManagementException
- if there are errors with certificateUnrecoverableKeyException
- if there are errors with loading client certificateTransformerException
- if error with transformer factorypublic String sendSWIDData(org.apache.http.impl.client.CloseableHttpClient client, String token, List<String> swidFiles, Action action, TagType type) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException, UnrecoverableKeyException, TransformerException
HTTPService
sendSWIDData
in interface HTTPService
client
- the http clienttoken
- the JSON web tokenswidFiles
- the location of input SWID tags to POSTaction
- the action either insert or update to performs on the SWID tagstype
- the SWID tag typeKeyStoreException
- if there are errors with loading client certificateNoSuchAlgorithmException
- if there are errorsCertificateException
- if there are errors with loading client certificateIOException
- if there are errors with read or writeKeyManagementException
- if there are errors with certificateUnrecoverableKeyException
- if there are errors with loading client certificateTransformerException
- if error with transformer factorypublic static String prettyFormat(String input, int indent) throws TransformerException
input
- input string to formatindent
- the number of space to indextTransformerException
- if transformation error occurspublic static String prettyFormat(String input) throws TransformerException
input
- the string to formatTransformerException
- if error with formatting occurspublic String getCachedToken(String subjectDN) throws UnsupportedEncodingException, IOException
subjectDN
- the DN of the certificateUnsupportedEncodingException
- if encoding error occursIOException
- if error with read or writepublic void setTokenCache(String token, String subjectDN) throws IOException
token
- the token to cachesubjectDN
- DN of the certificateIOException
- if read or write error occurspublic String getKeyStoreSubjectDN(KeyStore ks) throws KeyStoreException
ks
- the keystoreKeyStoreException
- if error occurs with keystore loadingCopyright © 2020 National Institute of Standards and Technology. All rights reserved.