本文整理汇总了Java中eu.europa.esig.dss.x509.KeyStoreCertificateSource类的典型用法代码示例。如果您正苦于以下问题:Java KeyStoreCertificateSource类的具体用法?Java KeyStoreCertificateSource怎么用?Java KeyStoreCertificateSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyStoreCertificateSource类属于eu.europa.esig.dss.x509包,在下文中一共展示了KeyStoreCertificateSource类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
KeyStoreCertificateSource kscs = new KeyStoreCertificateSource((InputStream) null, KEYSTORE_TYPE, KEYSTORE_PASSWORD);
addCertificate(kscs, "src/main/resources/keystore/ec.europa.eu.1.cer");
addCertificate(kscs, "src/main/resources/keystore/ec.europa.eu.2.cer");
addCertificate(kscs, "src/main/resources/keystore/ec.europa.eu.3.cer");
addCertificate(kscs, "src/main/resources/keystore/ec.europa.eu.4.cer");
// PIVOT 172
// addCertificate(kscs, "src/main/resources/keystore/ec.europa.eu.5.cer");
// addCertificate(kscs, "src/main/resources/keystore/ec.europa.eu.6.cer");
OutputStream fos = new FileOutputStream(KEYSTORE_FILEPATH);
kscs.store(fos);
Utils.closeQuietly(fos);
LOG.info("****************");
KeyStoreCertificateSource certificateSource = new KeyStoreCertificateSource(new File(KEYSTORE_FILEPATH), KEYSTORE_TYPE, KEYSTORE_PASSWORD);
List<CertificateToken> certificatesFromKeyStore = certificateSource.getCertificates();
for (CertificateToken certificateToken : certificatesFromKeyStore) {
LOG.info("" + certificateToken);
}
}
示例2: tslValidationJob
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
@Bean
public TSLValidationJob tslValidationJob(DataLoader dataLoader, TSLRepository tslRepository, KeyStoreCertificateSource ojContentKeyStore) {
TSLValidationJob validationJob = new TSLValidationJob();
validationJob.setDataLoader(dataLoader);
validationJob.setRepository(tslRepository);
validationJob.setLotlUrl(lotlUrl);
validationJob.setLotlRootSchemeInfoUri(lotlRootSchemeInfoUri);
validationJob.setLotlCode(lotlCountryCode);
validationJob.setOjUrl(ojUrl);
validationJob.setOjContentKeyStore(ojContentKeyStore);
validationJob.setCheckLOTLSignature(true);
validationJob.setCheckTSLSignatures(true);
return validationJob;
}
示例3: addCertificate
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
private static void addCertificate(KeyStoreCertificateSource kscs, String certPath) throws Exception {
try (InputStream is = new FileInputStream(certPath)) {
CertificateToken cert = DSSUtils.loadCertificate(is);
if (!allow_expired && cert.isExpiredOn(new Date())) {
throw new RuntimeException("Certificate " + DSSASN1Utils.getSubjectCommonName(cert) + " is expired");
}
displayCertificateDigests(cert);
LOG.info("Adding certificate " + cert);
kscs.addCertificateToKeyStore(cert);
}
}
示例4: loadLOTL
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
@Test
public void loadLOTL() throws IOException {
// tag::demo[]
// The keystore contains certificates extracted from the OJ
KeyStoreCertificateSource keyStoreCertificateSource = new KeyStoreCertificateSource(new File("src/main/resources/keystore.p12"), "PKCS12",
"dss-password");
TrustedListsCertificateSource certificateSource = new TrustedListsCertificateSource();
TSLRepository tslRepository = new TSLRepository();
tslRepository.setTrustedListsCertificateSource(certificateSource);
TSLValidationJob job = new TSLValidationJob();
job.setDataLoader(new CommonsDataLoader());
job.setOjContentKeyStore(keyStoreCertificateSource);
job.setLotlRootSchemeInfoUri("https://ec.europa.eu/information_society/policy/esignature/trusted-list/tl.html");
job.setLotlUrl("https://ec.europa.eu/information_society/policy/esignature/trusted-list/tl-mp.xml");
job.setOjUrl("http://eur-lex.europa.eu/legal-content/EN/TXT/?uri=uriserv:OJ.C_.2016.233.01.0001.01.ENG");
job.setLotlCode("EU");
job.setRepository(tslRepository);
job.refresh();
// end::demo[]
}
示例5: ojContentKeyStore
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
@Bean
public KeyStoreCertificateSource ojContentKeyStore() throws IOException {
return new KeyStoreCertificateSource(new ClassPathResource(ksFilename).getFile(), ksType, ksPassword);
}
示例6: setOjContentKeyStore
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
public void setOjContentKeyStore(KeyStoreCertificateSource ojContentKeyStore) {
this.ojContentKeyStore = ojContentKeyStore;
}
示例7: init
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
@Before
public void init() throws IOException {
dssKeyStore = new KeyStoreCertificateSource(new File("src/test/resources/keystore.p12"), "PKCS12", "dss-password");
}
示例8: getTrustAnchors
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
private KeyStoreCertificateSource getTrustAnchors() {
return new KeyStoreCertificateSource(new ByteArrayInputStream(getKeystoreContent("trust-anchors.jks")), TRUSTSTORE_TYPE, PKI_FACTORY_KEYSTORE_PASSWORD);
}
示例9: validateXAdESBaselineLTWithOnlineSources
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
@Test
public void validateXAdESBaselineLTWithOnlineSources() throws IOException {
// tag::demo[]
// To be able to validate our fake signature, we must define one of the certificates in the chain as trusted
// anchor.
// If you have a real signature for which it is possible to build the chain till the TSL then just skip this
// point.
preparePKCS12TokenAndKey();
final CertificateToken[] certificateChain = privateKey.getCertificateChain();
final CertificateToken trustedCertificate = certificateChain[0];
// Already signed document
DSSDocument document = new FileDocument(new File("src/test/resources/signedXmlXadesLT.xml"));
SignedDocumentValidator validator = SignedDocumentValidator.fromDocument(document);
CommonsDataLoader commonsDataLoader = new CommonsDataLoader();
CommonCertificateVerifier verifier = new CommonCertificateVerifier();
OnlineCRLSource crlSource = new OnlineCRLSource();
crlSource.setDataLoader(commonsDataLoader);
verifier.setCrlSource(crlSource);
OnlineOCSPSource ocspSource = new OnlineOCSPSource();
// The default OCSPDataLoader is created. You can also create your own HttpDataLoader.
verifier.setOcspSource(ocspSource);
// SEE NOTE 1
FileCacheDataLoader fileCacheDataLoader = new FileCacheDataLoader();
File cacheFolder = new File("/temp");
fileCacheDataLoader.setFileCacheDirectory(cacheFolder);
KeyStoreCertificateSource keyStoreCertificateSource = new KeyStoreCertificateSource(new File("src/main/resources/keystore.p12"), "PKCS12",
"dss-password");
TrustedListsCertificateSource certificateSource = new TrustedListsCertificateSource();
TSLRepository tslRepository = new TSLRepository();
tslRepository.setTrustedListsCertificateSource(certificateSource);
TSLValidationJob job = new TSLValidationJob();
job.setDataLoader(new CommonsDataLoader());
job.setOjContentKeyStore(keyStoreCertificateSource);
job.setLotlRootSchemeInfoUri("https://ec.europa.eu/information_society/policy/esignature/trusted-list/tl.html");
job.setLotlUrl("https://ec.europa.eu/information_society/policy/esignature/trusted-list/tl-mp.xml");
job.setOjUrl("http://eur-lex.europa.eu/legal-content/EN/TXT/?uri=uriserv:OJ.C_.2016.233.01.0001.01.ENG");
job.setLotlCode("EU");
job.setRepository(tslRepository);
job.refresh();
certificateSource.addCertificate(trustedCertificate, new MockServiceInfo());
verifier.setTrustedCertSource(certificateSource);
verifier.setDataLoader(fileCacheDataLoader);
validator.setCertificateVerifier(verifier);
Reports reports = validator.validateDocument();
SimpleReport simpleReport = reports.getSimpleReport();
DetailedReport detailedReport = reports.getDetailedReport();
// end::demo[]
assertNotNull(reports);
assertNotNull(simpleReport);
assertNotNull(detailedReport);
}
示例10: getKeyStore
import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //导入依赖的package包/类
private KeyStoreCertificateSource getKeyStore() {
File tslKeystoreFile = getTslKeystoreFile();
return new KeyStoreCertificateSource(tslKeystoreFile, configuration.getTslKeyStorePassword());
}