/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author Sean Mullan
* @author Steve Hanna
*
*/
/**
* Static utility methods useful for testing certificate/certpath APIs.
*/
public class CertUtils {
private CertUtils() {}
/**
* Get a DER-encoded X.509 certificate from a file.
*
* @param certFilePath path to file containing DER-encoded certificate
* @return X509Certificate
* @throws IOException on error
*/
throws IOException {
try {
throw new IOException("File " +
" is not a readable file.");
new FileInputStream(certFile);
cert = (X509Certificate)
} catch (Exception e) {
e.printStackTrace();
throw new IOException("Can't construct X509Certificate: " +
e.getMessage());
}
return cert;
}
/**
* Get a DER-encoded X.509 CRL from a file.
*
* @param crlFilePath path to file containing DER-encoded CRL
* @return X509CRL
* @throws IOException on error
*/
throws IOException {
try {
throw new IOException("File " +
" is not a readable file.");
new FileInputStream(crlFile);
} catch (Exception e) {
e.printStackTrace();
throw new IOException("Can't construct X509CRL: " +
e.getMessage());
}
return crl;
}
/**
* Read a bunch of certs from files and create a CertPath from them.
*
* @param fileNames an array of <code>String</code>s that are file names
* @throws Exception on error
*/
}
/**
* Read a bunch of certs from files and create a CertPath from them.
*
* @param relPath relative path containing certs (must end in
* file.separator)
* @param fileNames an array of <code>String</code>s that are file names
* @throws Exception on error
*/
throws Exception {
}
}
/**
* Read a bunch of certs from files and create a CertStore from them.
*
* @param fileNames an array of <code>String</code>s that are file names
* @return the <code>CertStore</code> created
* @throws Exception on error
*/
}
/**
* Read a bunch of certs from files and create a CertStore from them.
*
* @param relPath relative path containing certs (must end in
* file.separator)
* @param fileNames an array of <code>String</code>s that are file names
* @return the <code>CertStore</code> created
* @throws Exception on error
*/
throws Exception {
}
}
/**
* Read a bunch of CRLs from files and create a CertStore from them.
*
* @param fileNames an array of <code>String</code>s that are file names
* @return the <code>CertStore</code> created
* @throws Exception on error
*/
throws Exception {
}
/**
* Read a bunch of CRLs from files and create a CertStore from them.
*
* @param relPath relative path containing CRLs (must end in file.separator)
* @param fileNames an array of <code>String</code>s that are file names
* @return the <code>CertStore</code> created
* @throws Exception on error
*/
throws Exception {
}
}
/**
* Perform a PKIX path build. On failure, throw an exception.
*
* @param params PKIXBuilderParameters to use in validation
* @throws Exception on error
*/
throws Exception {
}
/**
* Perform a PKIX validation. On failure, throw an exception.
*
* @param path CertPath to validate
* @param params PKIXParameters to use in validation
* @throws Exception on error
*/
}
/*
* Reads the entire input stream into a byte array.
*/
byte[] buffer = new byte[8192];
int n;
}
return baos.toByteArray();
}
}