本文整理汇总了Java中eu.europa.esig.dss.utils.Utils.isStringEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.isStringEmpty方法的具体用法?Java Utils.isStringEmpty怎么用?Java Utils.isStringEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.europa.esig.dss.utils.Utils
的用法示例。
在下文中一共展示了Utils.isStringEmpty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConnectionManagerSchemeHttps
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private RegistryBuilder<ConnectionSocketFactory> setConnectionManagerSchemeHttps(
final RegistryBuilder<ConnectionSocketFactory> socketFactoryRegistryBuilder) throws DSSException {
FileInputStream fis = null;
FileInputStream trustStoreIs = null;
try {
X509TrustManager trustManager = null;
if (Utils.isStringEmpty(sslTruststorePath)) {
trustManager = new AcceptAllTrustManager();
} else {
trustStoreIs = new FileInputStream(new File(sslTruststorePath));
trustManager = new DefaultTrustManager(trustStoreIs, sslTruststoreType, sslTruststorePassword);
}
KeyManager[] keysManager = null;
if (Utils.isStringEmpty(sslKeystorePath)) {
LOG.debug("Use default SSL configuration");
keysManager = new KeyManager[0];
} else {
LOG.debug("Use provided info for SSL");
fis = new FileInputStream(new File(sslKeystorePath));
DefaultKeyManager dkm = new DefaultKeyManager(fis, sslKeystoreType, sslKeystorePassword);
keysManager = new KeyManager[] { dkm };
}
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keysManager, new TrustManager[] { trustManager }, new SecureRandom());
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext);
return socketFactoryRegistryBuilder.register("https", sslConnectionSocketFactory);
} catch (final Exception e) {
throw new DSSException(e);
} finally {
Utils.closeQuietly(fis);
Utils.closeQuietly(trustStoreIs);
}
}
示例2: ldapGet
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This method retrieves data using LDAP protocol. - CRL from given LDAP
* url, e.g. ldap://ldap.infonotary.com/dc=identity-ca,dc=infonotary,dc=com
* - ex URL from AIA
* ldap://xadessrv.plugtests.net/CN=LevelBCAOK,OU=Plugtests_2015-2016,O=ETSI,C=FR?cACertificate;binary
*
* @param urlString
* @return
*/
protected byte[] ldapGet(final String urlString) {
final Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, urlString);
try {
// parse URL according to the template: 'ldap://host:port/DN?attributes?scope?filter?extensions'
String ldapParams = Utils.substringAfter(urlString, "?");
StringTokenizer tokenizer = new StringTokenizer(ldapParams, "?");
String attributeName = (tokenizer.hasMoreTokens()) ? tokenizer.nextToken() : null;
if (Utils.isStringEmpty(attributeName)) {
// default was CRL
attributeName = "certificateRevocationList;binary";
}
final DirContext ctx = new InitialDirContext(env);
final Attributes attributes = ctx.getAttributes(Utils.EMPTY_STRING, new String[] { attributeName });
if (attributes == null || attributes.size() < 1) {
LOG.warn("Cannot download CRL from: " + urlString + ", no attributes with name: " + attributeName + " returned");
} else {
final Attribute attribute = attributes.getAll().next();
final byte[] ldapBytes = (byte[]) attribute.get();
if (Utils.isArrayNotEmpty(ldapBytes)) {
return ldapBytes;
}
}
} catch (Exception e) {
LOG.warn(e.getMessage(), e);
}
return null;
}
示例3: processValueCheck
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
protected boolean processValueCheck(String value, String expected) {
if (Utils.isStringEmpty(value)) {
return false;
}
if (ALL_VALUE.equals(expected)) {
return true;
} else {
return Utils.areStringsEqual(expected, value);
}
}
示例4: process
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
protected boolean process() {
String signedElement = token.getSigningCertificateSigned();
// TODO
return Utils.isStringEmpty(signedElement)
|| (XMLE_X509CERTIFICATE.equals(signedElement) || XMLE_X509DATA.equals(signedElement) || XMLE_KEYINFO.equals(signedElement));
}
示例5: getExpirationDate
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private Date getExpirationDate(String algoToFind, List<Algo> algos, String format) {
SimpleDateFormat dateFormat = new SimpleDateFormat(Utils.isStringEmpty(format) ? DATE_FORMAT : format);
Date result = null;
for (Algo algo : algos) {
if (Utils.areStringsEqual(algoToFind, algo.getValue()) && Utils.isStringNotEmpty(algo.getDate())) {
try {
result = dateFormat.parse(algo.getDate());
} catch (Exception e) {
LOG.warn("Unable to parse date with pattern '" + dateFormat.toPattern() + "' : " + e.getMessage());
}
}
}
return result;
}
示例6: process
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
protected boolean process() {
String policyId = signature.getPolicyId();
if (multiValues.getId().contains(SignaturePolicy.NO_POLICY) && Utils.isStringEmpty(policyId)) {
return true;
} else if (multiValues.getId().contains(SignaturePolicy.ANY_POLICY) && Utils.isStringNotEmpty(policyId)) {
return true;
} else if (multiValues.getId().contains(SignaturePolicy.IMPLICIT_POLICY) && Utils.areStringsEqual(SignaturePolicy.IMPLICIT_POLICY, policyId)) {
return true;
}
// oids
return processValueCheck(policyId);
}
示例7: load
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This is the utility method that loads the data from the file determined by the path parameter into a
* {@link org.w3c.dom.Document}.
*
* @param path
* @return
*/
public static ConstraintsParameters load(final String path) {
if (Utils.isStringEmpty(path)) {
return null;
}
final InputStream fileInputStream = getResourceInputStream(path);
if (fileInputStream == null) {
LOG.warn("Unknown resource (path: '{}')", path);
}
return load(fileInputStream);
}
示例8: getAllSignatures
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This method returns signatures (not countersignatures)
*
* @return
*/
public Set<SignatureWrapper> getAllSignatures() {
Set<SignatureWrapper> signatures = new HashSet<SignatureWrapper>();
List<SignatureWrapper> mixedSignatures = getSignatures();
for (SignatureWrapper signatureWrapper : mixedSignatures) {
if (Utils.isStringEmpty(signatureWrapper.getParentId())) {
signatures.add(signatureWrapper);
}
}
return signatures;
}
示例9: check
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public boolean check(CertificateToken certificateToken) {
X500Principal subjectX500Principal = certificateToken.getSubjectX500Principal();
if (Utils.isCollectionNotEmpty(subjectAttributeOids)) {
for (String oid : subjectAttributeOids) {
String attribute = DSSASN1Utils.extractAttributeFromX500Principal(new ASN1ObjectIdentifier(oid), subjectX500Principal);
if (Utils.isStringEmpty(attribute)) {
return false;
}
}
}
return true;
}
示例10: incorporatePolicy
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private void incorporatePolicy() {
final Policy signaturePolicy = params.bLevel().getSignaturePolicy();
if ((signaturePolicy != null)) {// && (signaturePolicy.getId() != null)) {
final Element signaturePolicyIdentifierDom = DomUtils.addElement(documentDom, signedSignaturePropertiesDom, XAdES,
XADES_SIGNATURE_POLICY_IDENTIFIER);
String signaturePolicyId = signaturePolicy.getId();
if (Utils.isStringEmpty(signaturePolicyId)) { // implicit
DomUtils.addElement(documentDom, signaturePolicyIdentifierDom, XAdES, XADES_SIGNATURE_POLICY_IMPLIED);
} else { // explicit
final Element signaturePolicyIdDom = DomUtils.addElement(documentDom, signaturePolicyIdentifierDom, XAdES, XADES_SIGNATURE_POLICY_ID);
final Element sigPolicyIdDom = DomUtils.addElement(documentDom, signaturePolicyIdDom, XAdES, XADES_SIG_POLICY_ID);
Element identifierDom = DomUtils.addTextElement(documentDom, sigPolicyIdDom, XAdES, XADES_IDENTIFIER, signaturePolicyId);
String qualifier = signaturePolicy.getQualifier();
if (Utils.isStringNotBlank(qualifier)) {
identifierDom.setAttribute(QUALIFIER, qualifier);
}
String description = signaturePolicy.getDescription();
if (Utils.isStringNotEmpty(description)) {
DomUtils.addTextElement(documentDom, sigPolicyIdDom, XAdES, XADES_DESCRIPTION, description);
}
if ((signaturePolicy.getDigestAlgorithm() != null) && (signaturePolicy.getDigestValue() != null)) {
final Element sigPolicyHashDom = DomUtils.addElement(documentDom, signaturePolicyIdDom, XAdES, XADES_SIG_POLICY_HASH);
// <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
final DigestAlgorithm digestAlgorithm = signaturePolicy.getDigestAlgorithm();
incorporateDigestMethod(sigPolicyHashDom, digestAlgorithm);
final byte[] hashValue = signaturePolicy.getDigestValue();
final String bas64EncodedHashValue = Utils.toBase64(hashValue);
DomUtils.addTextElement(documentDom, sigPolicyHashDom, XMLNS, DS_DIGEST_VALUE, bas64EncodedHashValue);
}
String spuri = signaturePolicy.getSpuri();
if (Utils.isStringNotEmpty(spuri)) {
Element sigPolicyQualifiers = DomUtils.addElement(documentDom, signaturePolicyIdDom, XAdES, XADES_SIGNATURE_POLICY_QUALIFIERS);
Element sigPolicyQualifier = DomUtils.addElement(documentDom, sigPolicyQualifiers, XAdES, XADES_SIGNATURE_POLICY_QUALIFIER);
DomUtils.addTextElement(documentDom, sigPolicyQualifier, XAdES, XADES_SPURI, spuri);
}
}
}
}
示例11: process
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
protected boolean process() {
PseudoStrategy pseudoStrategy = new JoinedPseudoStrategy();
pseudo = pseudoStrategy.getPseudo(certificate);
return Utils.isStringEmpty(pseudo);
}
示例12: getSignatures
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private List<PdfSignatureOrDocTimestampInfo> getSignatures(CertificatePool validationCertPool, byte[] originalBytes) {
List<PdfSignatureOrDocTimestampInfo> signatures = new ArrayList<PdfSignatureOrDocTimestampInfo>();
PDDocument doc = null;
try {
doc = PDDocument.load(originalBytes);
List<PDSignature> pdSignatures = doc.getSignatureDictionaries();
if (Utils.isCollectionNotEmpty(pdSignatures)) {
LOG.debug("{} signature(s) found", pdSignatures.size());
PdfDict catalog = new PdfBoxDict(doc.getDocumentCatalog().getCOSObject(), doc);
PdfDssDict dssDictionary = PdfDssDict.extract(catalog);
for (PDSignature signature : pdSignatures) {
String subFilter = signature.getSubFilter();
COSDictionary dict = signature.getCOSObject();
COSString item = (COSString) dict.getDictionaryObject(COSName.CONTENTS);
byte[] cms = item.getBytes();
byte[] cmsWithByteRange = signature.getContents(originalBytes);
if (!Arrays.equals(cmsWithByteRange, cms)) {
LOG.warn("The byte range doesn't match found /Content value!");
}
if (Utils.isStringEmpty(subFilter) || Utils.isArrayEmpty(cms)) {
LOG.warn("Wrong signature with empty subfilter or cms.");
continue;
}
byte[] signedContent = signature.getSignedContent(originalBytes);
int[] byteRange = signature.getByteRange();
PdfDict signatureDictionary = new PdfBoxDict(signature.getCOSObject(), doc);
PdfSignatureOrDocTimestampInfo signatureInfo = null;
if (PdfBoxDocTimeStampService.SUB_FILTER_ETSI_RFC3161.getName().equals(subFilter)) {
boolean isArchiveTimestamp = false;
// LT or LTA
if (dssDictionary != null) {
// check is DSS dictionary already exist
if (isDSSDictionaryPresentInPreviousRevision(getOriginalBytes(byteRange, signedContent))) {
isArchiveTimestamp = true;
}
}
signatureInfo = new PdfBoxDocTimestampInfo(validationCertPool, signature, signatureDictionary, dssDictionary, cms, signedContent,
isArchiveTimestamp);
} else {
signatureInfo = new PdfBoxSignatureInfo(validationCertPool, signature, signatureDictionary, dssDictionary, cms, signedContent);
}
if (signatureInfo != null) {
signatures.add(signatureInfo);
}
}
Collections.sort(signatures, new PdfSignatureOrDocTimestampInfoComparator());
linkSignatures(signatures);
for (PdfSignatureOrDocTimestampInfo sig : signatures) {
LOG.debug("Signature " + sig.uniqueId() + " found with byteRange " + Arrays.toString(sig.getSignatureByteRange()) + " ("
+ sig.getSubFilter() + ")");
}
}
} catch (Exception e) {
LOG.warn("Cannot analyze signatures : " + e.getMessage(), e);
} finally {
Utils.closeQuietly(doc);
}
return signatures;
}