当前位置: 首页>>代码示例>>Java>>正文


Java MacOutputStream类代码示例

本文整理汇总了Java中org.jcp.xml.dsig.internal.MacOutputStream的典型用法代码示例。如果您正苦于以下问题:Java MacOutputStream类的具体用法?Java MacOutputStream怎么用?Java MacOutputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MacOutputStream类属于org.jcp.xml.dsig.internal包,在下文中一共展示了MacOutputStream类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sign

import org.jcp.xml.dsig.internal.MacOutputStream; //导入依赖的package包/类
byte[] sign(Key key, SignedInfo si, XMLSignContext context)
    throws InvalidKeyException, XMLSignatureException
{
    if (key == null || si == null) {
        throw new NullPointerException();
    }
    if (!(key instanceof SecretKey)) {
        throw new InvalidKeyException("key must be SecretKey");
    }
    if (hmac == null) {
        try {
            hmac = Mac.getInstance(getJCAAlgorithm());
        } catch (NoSuchAlgorithmException nsae) {
            throw new XMLSignatureException(nsae);
        }
    }
    if (outputLengthSet && outputLength < getDigestLength()) {
        throw new XMLSignatureException
            ("HMACOutputLength must not be less than " + getDigestLength());
    }
    hmac.init((SecretKey)key);
    ((DOMSignedInfo)si).canonicalize(context, new MacOutputStream(hmac));
    return hmac.doFinal();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:DOMHMACSignatureMethod.java

示例2: verify

import org.jcp.xml.dsig.internal.MacOutputStream; //导入依赖的package包/类
boolean verify(Key key, DOMSignedInfo si, byte[] sig,
    XMLValidateContext context)
    throws InvalidKeyException, SignatureException, XMLSignatureException {
    if (key == null || si == null || sig == null) {
        throw new NullPointerException();
    }
    if (!(key instanceof SecretKey)) {
        throw new InvalidKeyException("key must be SecretKey");
    }
    if (hmac == null) {
        try {
            hmac = Mac.getInstance(getSignatureAlgorithm());
        } catch (NoSuchAlgorithmException nsae) {
            throw new XMLSignatureException(nsae);
        }
    }
    if (outputLengthSet && outputLength < getDigestLength()) {
        throw new XMLSignatureException
            ("HMACOutputLength must not be less than " + getDigestLength());
    }
    hmac.init((SecretKey) key);
    si.canonicalize(context, new MacOutputStream(hmac));
    byte[] result = hmac.doFinal();

    return MessageDigest.isEqual(sig, result);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:27,代码来源:DOMHMACSignatureMethod.java

示例3: sign

import org.jcp.xml.dsig.internal.MacOutputStream; //导入依赖的package包/类
byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context)
    throws InvalidKeyException, XMLSignatureException {
    if (key == null || si == null) {
        throw new NullPointerException();
    }
    if (!(key instanceof SecretKey)) {
        throw new InvalidKeyException("key must be SecretKey");
    }
    if (hmac == null) {
        try {
            hmac = Mac.getInstance(getSignatureAlgorithm());
        } catch (NoSuchAlgorithmException nsae) {
            throw new XMLSignatureException(nsae);
        }
    }
    if (outputLengthSet && outputLength < getDigestLength()) {
        throw new XMLSignatureException
            ("HMACOutputLength must not be less than " + getDigestLength());
    }
    hmac.init((SecretKey) key);
    si.canonicalize(context, new MacOutputStream(hmac));
    return hmac.doFinal();
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:24,代码来源:DOMHMACSignatureMethod.java

示例4: verify

import org.jcp.xml.dsig.internal.MacOutputStream; //导入依赖的package包/类
boolean verify(Key key, SignedInfo si, byte[] sig,
               XMLValidateContext context)
    throws InvalidKeyException, SignatureException, XMLSignatureException
{
    if (key == null || si == null || sig == null) {
        throw new NullPointerException();
    }
    if (!(key instanceof SecretKey)) {
        throw new InvalidKeyException("key must be SecretKey");
    }
    if (hmac == null) {
        try {
            hmac = Mac.getInstance(getJCAAlgorithm());
        } catch (NoSuchAlgorithmException nsae) {
            throw new XMLSignatureException(nsae);
        }
    }
    if (outputLengthSet && outputLength < getDigestLength()) {
        throw new XMLSignatureException
            ("HMACOutputLength must not be less than " + getDigestLength());
    }
    hmac.init((SecretKey)key);
    ((DOMSignedInfo)si).canonicalize(context, new MacOutputStream(hmac));
    byte[] result = hmac.doFinal();

    return MessageDigest.isEqual(sig, result);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:DOMHMACSignatureMethod.java


注:本文中的org.jcp.xml.dsig.internal.MacOutputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。