本文整理汇总了Java中eu.europa.esig.dss.utils.Utils.toHex方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.toHex方法的具体用法?Java Utils.toHex怎么用?Java Utils.toHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.europa.esig.dss.utils.Utils
的用法示例。
在下文中一共展示了Utils.toHex方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uniqueId
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public String uniqueId() {
if (uniqueId == null) {
byte[] digest = DSSUtils.digest(DigestAlgorithm.SHA1, cms);
uniqueId = Utils.toHex(digest);
}
return uniqueId;
}
示例2: getMD5Digest
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* Returns a Hex encoded of the MD5 digest of ByteArrayOutputStream
*
* @param bytes
* @return
*/
public static String getMD5Digest(byte[] bytes) {
try {
byte[] digestValue = digest(DigestAlgorithm.MD5, bytes);
return Utils.toHex(digestValue);
} catch (Exception e) {
throw new DSSException(e);
}
}
示例3: getDigestSignaturePolicy
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Test
public void getDigestSignaturePolicy() throws Exception {
FileInputStream fis = new FileInputStream("src/test/resources/signature-policy-example.der");
byte[] policyBytes = Utils.toByteArray(fis);
Utils.closeQuietly(fis);
byte[] signaturePolicyDigest = DSSASN1Utils.getAsn1SignaturePolicyDigest(DigestAlgorithm.SHA256, policyBytes);
String hexSignaturePolicyDigest = Utils.toHex(signaturePolicyDigest);
assertEquals("fe71e01aedd99f444238602d4e98f47bbab405c58c0e3811b9511dcd58c3c983", hexSignaturePolicyDigest);
}
示例4: toString
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public String toString() {
return "CertificateRef[issuerName=" + issuerName + ",issuerSerial=" + issuerSerial + ",digest=" + Utils.toHex(digestValue) + "]";
}
示例5: getXmlCertificate
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private XmlCertificate getXmlCertificate(Set<DigestAlgorithm> usedDigestAlgorithms, CertificateToken certToken) {
final XmlCertificate xmlCert = new XmlCertificate();
xmlCert.setId(certToken.getDSSIdAsString());
xmlCert.setBase64Encoded(certToken.getEncoded());
xmlCert.getSubjectDistinguishedName().add(getXmlDistinguishedName(X500Principal.CANONICAL, certToken.getSubjectX500Principal()));
xmlCert.getSubjectDistinguishedName().add(getXmlDistinguishedName(X500Principal.RFC2253, certToken.getSubjectX500Principal()));
xmlCert.getIssuerDistinguishedName().add(getXmlDistinguishedName(X500Principal.CANONICAL, certToken.getIssuerX500Principal()));
xmlCert.getIssuerDistinguishedName().add(getXmlDistinguishedName(X500Principal.RFC2253, certToken.getIssuerX500Principal()));
xmlCert.setSerialNumber(certToken.getSerialNumber());
X500Principal x500Principal = certToken.getSubjectX500Principal();
xmlCert.setCommonName(DSSASN1Utils.extractAttributeFromX500Principal(BCStyle.CN, x500Principal));
xmlCert.setCountryName(DSSASN1Utils.extractAttributeFromX500Principal(BCStyle.C, x500Principal));
xmlCert.setOrganizationName(DSSASN1Utils.extractAttributeFromX500Principal(BCStyle.O, x500Principal));
xmlCert.setGivenName(DSSASN1Utils.extractAttributeFromX500Principal(BCStyle.GIVENNAME, x500Principal));
xmlCert.setOrganizationalUnit(DSSASN1Utils.extractAttributeFromX500Principal(BCStyle.OU, x500Principal));
xmlCert.setSurname(DSSASN1Utils.extractAttributeFromX500Principal(BCStyle.SURNAME, x500Principal));
xmlCert.setPseudonym(DSSASN1Utils.extractAttributeFromX500Principal(BCStyle.PSEUDONYM, x500Principal));
xmlCert.setAuthorityInformationAccessUrls(DSSASN1Utils.getCAAccessLocations(certToken));
xmlCert.setOCSPAccessUrls(DSSASN1Utils.getOCSPAccessLocations(certToken, false));
xmlCert.setCRLDistributionPoints(DSSASN1Utils.getCrlUrls(certToken, false));
xmlCert.setDigestAlgoAndValues(getXmlDigestAlgoAndValues(usedDigestAlgorithms, certToken));
xmlCert.setNotAfter(certToken.getNotAfter());
xmlCert.setNotBefore(certToken.getNotBefore());
final PublicKey publicKey = certToken.getPublicKey();
xmlCert.setPublicKeySize(DSSPKUtils.getPublicKeySize(publicKey));
xmlCert.setPublicKeyEncryptionAlgo(DSSPKUtils.getPublicKeyEncryptionAlgo(publicKey));
xmlCert.setKeyUsageBits(getXmlKeyUsages(certToken.getKeyUsageBits()));
xmlCert.setIdKpOCSPSigning(DSSASN1Utils.isOCSPSigning(certToken));
xmlCert.setIdPkixOcspNoCheck(DSSASN1Utils.hasIdPkixOcspNoCheckExtension(certToken));
xmlCert.setBasicSignature(getXmlBasicSignature(certToken));
final CertificateToken issuerToken = certToken.getIssuerToken();
xmlCert.setSigningCertificate(getXmlSigningCertificate(issuerToken));
xmlCert.setCertificateChain(getXmlForCertificateChain(issuerToken));
xmlCert.setQCStatementIds(getXmlOids(DSSASN1Utils.getQCStatementsIdList(certToken)));
xmlCert.setQCTypes(getXmlOids(DSSASN1Utils.getQCTypesIdList(certToken)));
xmlCert.setCertificatePolicyIds(getXmlOids(DSSASN1Utils.getPolicyIdentifiers(certToken)));
xmlCert.setSelfSigned(certToken.isSelfSigned());
xmlCert.setTrusted(certToken.isTrusted());
xmlCert.setInfo(getXmlInfo(certToken.getValidationInfo()));
final Set<RevocationToken> revocationTokens = certToken.getRevocationTokens();
if (Utils.isCollectionNotEmpty(revocationTokens)) {
for (RevocationToken revocationToken : revocationTokens) {
// In case of CRL, the X509CRL can be the same for different certificates
String xmlId = Utils.toHex(certToken.getDigest(DigestAlgorithm.SHA256)) + Utils.toHex(revocationToken.getDigest(DigestAlgorithm.SHA256));
xmlCert.getRevocations().add(getXmlRevocation(revocationToken, xmlId, usedDigestAlgorithms));
}
}
xmlCert.setTrustedServiceProviders(getXmlTrustedServiceProviders(certToken));
return xmlCert;
}
示例6: toHexNull
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Test(expected = Exception.class)
public void toHexNull() {
Utils.toHex(null);
}
示例7: getPrintableHex
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private static String getPrintableHex(byte[] digest) {
String hexString = Utils.toHex(digest);
// Add space every two characters
return hexString.replaceAll("..", "$0 ");
}
示例8: toHex
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* Converts an array of bytes into a String representing the hexadecimal values of each byte in order. The returned
* String will be double the length of the passed array, as it takes two characters to represent any given byte. If
* the input array is null then null is returned. The obtained string is converted to uppercase.
*
* @param value
* @return
*/
public static String toHex(final byte[] value) {
return (value != null) ? Utils.toHex(value) : null;
}
示例9: getSHA1Digest
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This method digests the given string with SHA1 algorithm and encode returned array of bytes as hex string.
*
* @param stringToDigest
* Everything in the name
* @return hex encoded digest value
*/
public static String getSHA1Digest(final String stringToDigest) {
final byte[] digest = getMessageDigest(DigestAlgorithm.SHA1).digest(stringToDigest.getBytes());
return Utils.toHex(digest);
}