1 /** 2 * Portions of this software was developed by employees of the National Institute 3 * of Standards and Technology (NIST), an agency of the Federal Government and is 4 * being made available as a public service. Pursuant to title 17 United States 5 * Code Section 105, works of NIST employees are not subject to copyright 6 * protection in the United States. This software may be subject to foreign 7 * copyright. Permission in the United States and in foreign countries, to the 8 * extent that NIST may hold copyright, to use, copy, modify, create derivative 9 * works, and distribute this software and its documentation without fee is hereby 10 * granted on a non-exclusive basis, provided that this notice and disclaimer 11 * of warranty appears in all copies. 12 * 13 * THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, EITHER 14 * EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY 15 * THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND FREEDOM FROM 17 * INFRINGEMENT, AND ANY WARRANTY THAT THE DOCUMENTATION WILL CONFORM TO THE 18 * SOFTWARE, OR ANY WARRANTY THAT THE SOFTWARE WILL BE ERROR FREE. IN NO EVENT 19 * SHALL NIST BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, 20 * INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, 21 * OR IN ANY WAY CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, 22 * CONTRACT, TORT, OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR 23 * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT 24 * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. 25 */ 26 27 package gov.nist.secauto.swid.client.service; 28 29 import org.apache.http.impl.client.CloseableHttpClient; 30 31 import java.io.IOException; 32 import java.security.KeyManagementException; 33 import java.security.KeyStoreException; 34 import java.security.NoSuchAlgorithmException; 35 import java.security.UnrecoverableKeyException; 36 import java.security.cert.CertificateException; 37 import java.util.List; 38 39 import javax.xml.transform.TransformerException; 40 41 public interface HTTPService { 42 43 /** 44 * Insert or Update end points 45 * 46 * @param client 47 * the http client 48 * @param token 49 * the JSON web token 50 * @param swidFiles 51 * the location of input SWID tags to POST 52 * @param action 53 * the action either insert or update to performs on the SWID tags 54 * @param type 55 * the SWID tag type 56 * @return the REST response 57 * @throws KeyStoreException 58 * if there are errors with loading client certificate 59 * @throws NoSuchAlgorithmException 60 * if there are errors 61 * @throws CertificateException 62 * if there are errors with loading client certificate 63 * @throws IOException 64 * if there are errors with read or write 65 * @throws KeyManagementException 66 * if there are errors with certificate 67 * @throws UnrecoverableKeyException 68 * if there are errors with loading client certificate 69 * @throws TransformerException 70 * if error with transformer factory 71 */ 72 String sendSWIDData(CloseableHttpClient client, String token, List<String> swidFiles, Action action, TagType type) 73 throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException, 74 UnrecoverableKeyException, TransformerException; 75 76 /** 77 * 78 * @param clientCertificatePath 79 * location of client keystore 80 * @param clientCertificatePassword 81 * password of client keystore 82 * @param passwordSeed 83 * the password seed 84 * @param swidFiles 85 * the list of SWID tags to POST 86 * @param action 87 * the action either insert or update to performs on the SWID tags 88 * @param type 89 * the SWID tag type 90 * @return the Rest response 91 * @throws KeyStoreException 92 * if there are errors with loading client certificate 93 * @throws NoSuchAlgorithmException 94 * if there are errors 95 * @throws CertificateException 96 * if there are errors with loading client certificate 97 * @throws IOException 98 * if there are errors with read or write 99 * @throws KeyManagementException 100 * if there are errors with certificate 101 * @throws UnrecoverableKeyException 102 * if there are errors with loading client certificate 103 * @throws TransformerException 104 * if error with transformer factory 105 */ 106 public String postSwid(String clientCertificatePath, String clientCertificatePassword, String passwordSeed, 107 List<String> swidFiles, Action action, TagType type) throws KeyStoreException, NoSuchAlgorithmException, 108 CertificateException, IOException, KeyManagementException, UnrecoverableKeyException, TransformerException; 109 110 }