當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyStoreCertificateSource類代碼示例

本文整理匯總了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);
		}
	}
 
開發者ID:esig,項目名稱:dss,代碼行數:26,代碼來源:CreateKeyStoreApp.java

示例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;
}
 
開發者ID:esig,項目名稱:dss-demonstrations,代碼行數:15,代碼來源:DSSBeanConfig.java

示例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);
	}
}
 
開發者ID:esig,項目名稱:dss,代碼行數:14,代碼來源:CreateKeyStoreApp.java

示例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[]

}
 
開發者ID:esig,項目名稱:dss,代碼行數:29,代碼來源:LOTLLoadingTest.java

示例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);
}
 
開發者ID:esig,項目名稱:dss-demonstrations,代碼行數:5,代碼來源:DSSBeanConfig.java

示例6: setOjContentKeyStore

import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //導入依賴的package包/類
public void setOjContentKeyStore(KeyStoreCertificateSource ojContentKeyStore) {
	this.ojContentKeyStore = ojContentKeyStore;
}
 
開發者ID:esig,項目名稱:dss,代碼行數:4,代碼來源:TSLValidationJob.java

示例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");
}
 
開發者ID:esig,項目名稱:dss,代碼行數:5,代碼來源:TSLValidationJobTest.java

示例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);
}
 
開發者ID:esig,項目名稱:dss,代碼行數:4,代碼來源:PKIFactoryAccess.java

示例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);
}
 
開發者ID:esig,項目名稱:dss,代碼行數:71,代碼來源:ValidateXmlXadesLTWithOnlineSourcesTest.java

示例10: getKeyStore

import eu.europa.esig.dss.x509.KeyStoreCertificateSource; //導入依賴的package包/類
private KeyStoreCertificateSource getKeyStore() {
  File tslKeystoreFile = getTslKeystoreFile();
  return new KeyStoreCertificateSource(tslKeystoreFile, configuration.getTslKeyStorePassword());
}
 
開發者ID:open-eid,項目名稱:digidoc4j,代碼行數:5,代碼來源:TslLoader.java


注:本文中的eu.europa.esig.dss.x509.KeyStoreCertificateSource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。