本文整理汇总了Java中eu.europa.esig.dss.utils.Utils.isStringBlank方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.isStringBlank方法的具体用法?Java Utils.isStringBlank怎么用?Java Utils.isStringBlank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.europa.esig.dss.utils.Utils
的用法示例。
在下文中一共展示了Utils.isStringBlank方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSignatureById
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* Retrieves a signature based on its Id
*
* @param signatureId
* the given Id
* @return the corresponding {@code XAdESSignature}
* @throws DSSException
* in case no Id is provided, or in case no signature was found for the given Id
*/
public AdvancedSignature getSignatureById(final String signatureId) throws DSSException {
if (Utils.isStringBlank(signatureId)) {
throw new NullPointerException("signatureId");
}
final List<AdvancedSignature> advancedSignatures = getSignatures();
for (final AdvancedSignature advancedSignature : advancedSignatures) {
final String advancedSignatureId = advancedSignature.getId();
if (signatureId.equals(advancedSignatureId)) {
return advancedSignature;
}
}
throw new DSSException("The signature with the given id was not found!");
}
示例2: getOriginalDocuments
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public List<DSSDocument> getOriginalDocuments(final String signatureId) throws DSSException {
if (Utils.isStringBlank(signatureId)) {
throw new NullPointerException("signatureId");
}
List<DSSDocument> results = new ArrayList<DSSDocument>();
for (final Object signerInformationObject : cmsSignedData.getSignerInfos().getSigners()) {
final SignerInformation signerInformation = (SignerInformation) signerInformationObject;
final CAdESSignature cadesSignature = new CAdESSignature(cmsSignedData, signerInformation, validationCertPool);
cadesSignature.setSignatureFilename(document.getName());
cadesSignature.setDetachedContents(detachedContents);
cadesSignature.setProvidedSigningCertificateToken(providedSigningCertificateToken);
if (Utils.areStringsEqual(cadesSignature.getId(), signatureId)) {
results.add(new InMemoryDocument(cadesSignature.getOriginalDocumentStream()));
}
}
return results;
}
示例3: getOriginalDocuments
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public List<DSSDocument> getOriginalDocuments(final String signatureId) throws DSSException {
if (Utils.isStringBlank(signatureId)) {
throw new NullPointerException("signatureId");
}
List<DSSDocument> result = new ArrayList<DSSDocument>();
final NodeList signatureNodeList = rootElement.getElementsByTagNameNS(XMLSignature.XMLNS, XPathQueryHolder.XMLE_SIGNATURE);
List<AdvancedSignature> signatureList = getSignatures();
for (int ii = 0; ii < signatureNodeList.getLength(); ii++) {
final Element signatureEl = (Element) signatureNodeList.item(ii);
final String idIdentifier = DSSXMLUtils.getIDIdentifier(signatureEl);
if (signatureId.equals(idIdentifier)) {
XAdESSignature signature = (XAdESSignature) signatureList.get(ii);
signature.checkSignatureIntegrity();
if (getSignatureObjects(signatureEl).isEmpty() && signature.getReferences().isEmpty()) {
throw new DSSException("The signature must be enveloped or enveloping!");
} else if (isEnveloping(signatureEl)) {
List<Element> references = getSignatureObjects(signatureEl);
for (Element element : references) {
String content = element.getTextContent();
content = isBase64Encoded(content) ? new String(Base64.decode(content)) : content;
result.add(new InMemoryDocument(content.getBytes()));
}
} else {
signatureEl.getParentNode().removeChild(signatureEl);
final Node documentElement = rootElement.getDocumentElement();
byte[] documentBytes = DSSXMLUtils.serializeNode(documentElement);
documentBytes = isBase64Encoded(documentBytes) ? Base64.decode(documentBytes) : documentBytes;
result.add(new InMemoryDocument(documentBytes));
}
}
}
return result;
}
示例4: addContentIdentifier
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* ETSI TS 101 733 V2.2.1 (2013-04)
*
* 5.10.2 content-identifier Attribute
* The content-identifier attribute provides an identifier for the signed content, for use when a reference may be
* later required to that content; for example, in the content-reference attribute in other signed data sent later.
* The
* content-identifier shall be a signed attribute. content-identifier attribute type values for the ES have an ASN.1
* type ContentIdentifier, as defined in
* ESS (RFC 2634 [5]).
*
* The minimal content-identifier attribute should contain a concatenation of user-specific identification
* information (such as a user name or public keying material identification information), a GeneralizedTime string,
* and a random number.
*
* @param parameters
* @param signedAttributes
*/
private void addContentIdentifier(final CAdESSignatureParameters parameters, final ASN1EncodableVector signedAttributes) {
/* this attribute is prohibited in PAdES B */
if (!padesUsage) {
final String contentIdentifierPrefix = parameters.getContentIdentifierPrefix();
if (Utils.isStringNotBlank(contentIdentifierPrefix)) {
final String contentIdentifierSuffix;
if (Utils.isStringBlank(parameters.getContentIdentifierSuffix())) {
final Date now = new Date();
final String asn1GeneralizedTimeString = new ASN1GeneralizedTime(now).getTimeString();
final long randomNumber = new Random(now.getTime()).nextLong();
contentIdentifierSuffix = asn1GeneralizedTimeString + randomNumber;
parameters.setContentIdentifierSuffix(contentIdentifierSuffix);
} else {
contentIdentifierSuffix = parameters.getContentIdentifierSuffix();
}
final String contentIdentifierString = contentIdentifierPrefix + contentIdentifierSuffix;
final ContentIdentifier contentIdentifier = new ContentIdentifier(contentIdentifierString.getBytes());
final DERSet attrValues = new DERSet(contentIdentifier);
final Attribute attribute = new Attribute(id_aa_contentIdentifier, attrValues);
signedAttributes.add(attribute);
}
}
}
示例5: getSignatureProductionPlace
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public SignatureProductionPlace getSignatureProductionPlace() {
String location = pdfSignatureInfo.getLocation();
if (Utils.isStringBlank(location)) {
return super.getSignatureProductionPlace();
} else {
SignatureProductionPlace signatureProductionPlace = new SignatureProductionPlace();
signatureProductionPlace.setCountryName(location);
return signatureProductionPlace;
}
}
示例6: getOriginalDocuments
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public List<DSSDocument> getOriginalDocuments(String signatureId) throws DSSException {
if (Utils.isStringBlank(signatureId)) {
throw new NullPointerException("signatureId");
}
List<DSSDocument> result = new ArrayList<DSSDocument>();
List<AdvancedSignature> signatures = getSignatures();
for (AdvancedSignature signature : signatures) {
PAdESSignature padesSignature = (PAdESSignature) signature;
if (padesSignature.getId().equals(signatureId)) {
CAdESSignature cadesSignature = padesSignature.getCAdESSignature();
for (DSSDocument document : cadesSignature.getDetachedContents()) {
InputStream is = null;
try {
is = document.openStream();
byte[] content = Utils.toByteArray(is);
result.add(new InMemoryDocument(content));
} catch (IOException e) {
throw new DSSException("Unable to retrieve the original document for document '" + document.getName() + "'",e);
} finally {
Utils.closeQuietly(is);
}
}
}
}
return result;
}
示例7: getMimeTypeString
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
public static String getMimeTypeString(final ASiCParameters asicParameters) {
final String asicParameterMimeType = asicParameters.getMimeType();
String mimeTypeString;
if (Utils.isStringBlank(asicParameterMimeType)) {
if (isASiCE(asicParameters)) {
mimeTypeString = MimeType.ASICE.getMimeTypeString();
} else {
mimeTypeString = MimeType.ASICS.getMimeTypeString();
}
} else {
mimeTypeString = asicParameterMimeType;
}
return mimeTypeString;
}
示例8: findSignatureScope
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public List<SignatureScope> findSignatureScope(final XAdESSignature xadesSignature) {
final List<SignatureScope> result = new ArrayList<SignatureScope>();
final Set<Element> unsignedObjects = new HashSet<Element>();
unsignedObjects.addAll(xadesSignature.getSignatureObjects());
final Set<Element> signedObjects = new HashSet<Element>();
final List<Element> signatureReferences = xadesSignature.getSignatureReferences();
for (final Element signatureReference : signatureReferences) {
final String type = DomUtils.getValue(signatureReference, "@Type");
if (xadesSignature.getXPathQueryHolder().XADES_SIGNED_PROPERTIES.equals(type)) {
continue;
}
final String uri = DomUtils.getValue(signatureReference, "@URI");
final List<String> transformations = getTransformationNames(signatureReference);
if (Utils.isStringBlank(uri)) {
// self contained document
result.add(new XmlRootSignatureScope(transformations));
} else if (uri.startsWith("#")) {
// internal reference
final boolean xPointerQuery = XPointerResourceResolver.isXPointerQuery(uri, true);
if (xPointerQuery) {
final String id = DSSXMLUtils.getIDIdentifier(signatureReference);
final XPointerSignatureScope xPointerSignatureScope = new XPointerSignatureScope(id, uri);
result.add(xPointerSignatureScope);
continue;
}
final String xmlIdOfSignedElement = uri.substring(1);
final String xPathString = XPathQueryHolder.XPATH_OBJECT + "[@Id='" + xmlIdOfSignedElement + "']";
Element signedElement = DomUtils.getElement(xadesSignature.getSignatureElement(), xPathString);
if (signedElement != null) {
if (unsignedObjects.remove(signedElement)) {
signedObjects.add(signedElement);
result.add(new XmlElementSignatureScope(xmlIdOfSignedElement, transformations));
}
} else {
signedElement = DomUtils.getElement(xadesSignature.getSignatureElement().getOwnerDocument().getDocumentElement(),
"//*" + "[@Id='" + xmlIdOfSignedElement + "']");
if (signedElement != null) {
final String namespaceURI = signedElement.getNamespaceURI();
if ((namespaceURI == null) || (!XAdESNamespaces.exists(namespaceURI) && !namespaceURI.equals(XMLSignature.XMLNS))) {
signedObjects.add(signedElement);
result.add(new XmlElementSignatureScope(xmlIdOfSignedElement, transformations));
}
}
}
} else {
// detached file
result.add(new FullSignatureScope(DSSUtils.decodeUrl(uri)));
}
}
return result;
}
示例9: addContentHints
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* ETSI TS 101 733 V2.2.1 (2013-04)
*
* 5.10.3 content-hints Attribute
* The content-hints attribute provides information on the innermost signed content of a multi-layer message where
* one content is encapsulated in another.
* The syntax of the content-hints attribute type of the ES is as defined in ESS (RFC 2634 [5]).
* When used to indicate the precise format of the data to be presented to the user, the following rules apply:
* • the contentType indicates the type of the associated content. It is an object identifier (i.e. a unique string
* of
* integers) assigned by an authority that defines the content type; and
* • when the contentType is id-data the contentDescription shall define the presentation format; the
* format may be defined by MIME types.
* When the format of the content is defined by MIME types, the following rules apply:
* • the contentType shall be id-data as defined in CMS (RFC 3852 [4]);
* • the contentDescription shall be used to indicate the encoding of the data, in accordance with the rules
* defined RFC 2045 [6]; see annex F for an example of structured contents and MIME.
* NOTE 1: id-data OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs7(7) 1 }.
* NOTE 2: contentDescription is optional in ESS (RFC 2634 [5]). It may be used to complement
* contentTypes defined elsewhere; such definitions are outside the scope of the present document.
*
* @param parameters
* @param signedAttributes
* @return
*/
private void addContentHints(final CAdESSignatureParameters parameters, final ASN1EncodableVector signedAttributes) {
if (Utils.isStringNotBlank(parameters.getContentHintsType())) {
final ASN1ObjectIdentifier contentHintsType = new ASN1ObjectIdentifier(parameters.getContentHintsType());
final String contentHintsDescriptionString = parameters.getContentHintsDescription();
final DERUTF8String contentHintsDescription = Utils.isStringBlank(contentHintsDescriptionString) ? null
: new DERUTF8String(contentHintsDescriptionString);
// "text/plain";
// "1.2.840.113549.1.7.1";
final ContentHints contentHints = new ContentHints(contentHintsType, contentHintsDescription);
final DERSet attrValues = new DERSet(contentHints);
final Attribute attribute = new Attribute(id_aa_contentHint, attrValues);
signedAttributes.add(attribute);
}
}
示例10: testNoImplementationException
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Test(expected = ExceptionInInitializerError.class)
public void testNoImplementationException() {
Utils.isStringBlank("test");
}