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


Java Constants类代码示例

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


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

示例1: RSAKeyValue

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Constructor RSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public RSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.RSAPublicKey ) {
        this.addBigIntegerElement(
            ((RSAPublicKey) key).getModulus(), Constants._TAG_MODULUS
        );
        this.addBigIntegerElement(
            ((RSAPublicKey) key).getPublicExponent(), Constants._TAG_EXPONENT
        );
    } else {
        Object exArgs[] = { Constants._TAG_RSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:RSAKeyValue.java

示例2: Reference

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Build a {@link Reference} from an {@link Element}
 *
 * @param element <code>Reference</code> element
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param manifest is the {@link Manifest} of {@link SignedInfo} in which the Reference occurs.
 * @param secureValidation whether secure validation is enabled or not
 * We need this because the Manifest has the individual {@link ResourceResolver}s which have
 * been set by the user
 * @throws XMLSecurityException
 */
protected Reference(Element element, String baseURI, Manifest manifest, boolean secureValidation)
    throws XMLSecurityException {
    super(element, baseURI);
    this.secureValidation = secureValidation;
    this.baseURI = baseURI;
    Element el = XMLUtils.getNextElement(element.getFirstChild());
    if (Constants._TAG_TRANSFORMS.equals(el.getLocalName())
        && Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
        transforms = new Transforms(el, this.baseURI);
        transforms.setSecureValidation(secureValidation);
        if (secureValidation && transforms.getLength() > MAXIMUM_TRANSFORM_COUNT) {
            Object exArgs[] = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };

            throw new XMLSecurityException("signature.tooManyTransforms", exArgs);
        }
        el = XMLUtils.getNextElement(el.getNextSibling());
    }
    digestMethodElem = el;
    digestValueElement = XMLUtils.getNextElement(digestMethodElem.getNextSibling());
    this.manifest = manifest;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:Reference.java

示例3: getContentsBeforeTransformation

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Returns the XMLSignatureInput which is created by de-referencing the URI attribute.
 * @return the XMLSignatureInput of the source of this reference
 * @throws ReferenceNotInitializedException If the resolver found any
 * problem resolving the reference
 */
public XMLSignatureInput getContentsBeforeTransformation()
    throws ReferenceNotInitializedException {
    try {
        Attr uriAttr =
            this.constructionElement.getAttributeNodeNS(null, Constants._ATT_URI);

        ResourceResolver resolver =
            ResourceResolver.getInstance(
                uriAttr, this.baseURI, this.manifest.getPerManifestResolvers(), secureValidation
            );
        resolver.addProperties(this.manifest.getResolverProperties());

        return resolver.resolve(uriAttr, this.baseURI, secureValidation);
    }  catch (ResourceResolverException ex) {
        throw new ReferenceNotInitializedException("empty", ex);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:Reference.java

示例4: SignedInfo

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Constructor SignedInfo
 *
 * @param doc <code>SignedInfo</code> is placed in this document
 * @param signatureMethodURI URI representation of the Digest and
 *    Signature algorithm
 * @param hMACOutputLength
 * @param canonicalizationMethodURI URI representation of the
 *    Canonicalization method
 * @throws XMLSecurityException
 */
public SignedInfo(
    Document doc, String signatureMethodURI,
    int hMACOutputLength, String canonicalizationMethodURI
) throws XMLSecurityException {
    super(doc);

    c14nMethod =
        XMLUtils.createElementInSignatureSpace(this.doc, Constants._TAG_CANONICALIZATIONMETHOD);

    c14nMethod.setAttributeNS(null, Constants._ATT_ALGORITHM, canonicalizationMethodURI);
    this.constructionElement.appendChild(c14nMethod);
    XMLUtils.addReturnToElement(this.constructionElement);

    if (hMACOutputLength > 0) {
        this.signatureAlgorithm =
            new SignatureAlgorithm(this.doc, signatureMethodURI, hMACOutputLength);
    } else {
        this.signatureAlgorithm = new SignatureAlgorithm(this.doc, signatureMethodURI);
    }

    signatureMethod = this.signatureAlgorithm.getElement();
    this.constructionElement.appendChild(signatureMethod);
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:SignedInfo.java

示例5: getInclusiveNamespaces

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
public String getInclusiveNamespaces() {
    String c14nMethodURI = c14nMethod.getAttributeNS(null, Constants._ATT_ALGORITHM);
    if (!(c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#") ||
        c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#WithComments"))) {
        return null;
    }

    Element inclusiveElement = XMLUtils.getNextElement(c14nMethod.getFirstChild());

    if (inclusiveElement != null) {
        try {
            String inclusiveNamespaces =
                new InclusiveNamespaces(
                    inclusiveElement,
                    InclusiveNamespaces.ExclusiveCanonicalizationNamespace
                ).getInclusiveNamespaces();
            return inclusiveNamespaces;
        } catch (XMLSecurityException e) {
            return null;
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:SignedInfo.java

示例6: engineAddContextToElement

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Method engineAddContextToElement
 *
 * @param element
 */
public void engineAddContextToElement(Element element) {
    if (element == null) {
        throw new IllegalArgumentException("null element");
    }

    if (this.HMACOutputLengthSet) {
        Document doc = element.getOwnerDocument();
        Element HMElem =
            XMLUtils.createElementInSignatureSpace(doc, Constants._TAG_HMACOUTPUTLENGTH);
        Text HMText =
            doc.createTextNode(Integer.valueOf(this.HMACOutputLength).toString());

        HMElem.appendChild(HMText);
        XMLUtils.addReturnToElement(element);
        element.appendChild(HMElem);
        XMLUtils.addReturnToElement(element);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:IntegrityHmac.java

示例7: X509Data

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Constructor X509Data
 *
 * @param element
 * @param baseURI
 * @throws XMLSecurityException
 */
public X509Data(Element element, String baseURI) throws XMLSecurityException {
    super(element, baseURI);

    Node sibling = this.constructionElement.getFirstChild();
    while (sibling != null) {
        if (sibling.getNodeType() != Node.ELEMENT_NODE) {
            sibling = sibling.getNextSibling();
            continue;
        }
        return;
    }
    /* No Elements found */
    Object exArgs[] = { "Elements", Constants._TAG_X509DATA };
    throw new XMLSecurityException("xml.WrongContent", exArgs);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:X509Data.java

示例8: engineResolveSecretKey

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Method engineResolveSecretKey
 *
 * @param element
 * @param baseURI
 * @param storage
 * @return resolved SecretKey key or null if no {@link SecretKey} could be obtained
 *
 * @throws KeyResolverException
 */
public SecretKey engineResolveSecretKey(
    Element element, String baseURI, StorageResolver storage
) throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
    }

    if (secretKey != null
        && XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
        String name = element.getFirstChild().getNodeValue();
        if (keyName.equals(name)) {
            return secretKey;
        }
    }

    log.log(java.util.logging.Level.FINE, "I can't");
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:SingleKeyResolver.java

示例9: engineLookupAndResolvePrivateKey

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Method engineResolvePrivateKey
 * @inheritDoc
 * @param element
 * @param baseURI
 * @param storage
 * @return resolved PrivateKey key or null if no {@link PrivateKey} could be obtained
 * @throws KeyResolverException
 */
public PrivateKey engineLookupAndResolvePrivateKey(
    Element element, String baseURI, StorageResolver storage
) throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
    }

    if (privateKey != null
        && XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
        String name = element.getFirstChild().getNodeValue();
        if (keyName.equals(name)) {
            return privateKey;
        }
    }

    log.log(java.util.logging.Level.FINE, "I can't");
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:SingleKeyResolver.java

示例10: SignatureProperties

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Constructs {@link SignatureProperties} from {@link Element}
 * @param element <code>SignatureProperties</code> element
 * @param BaseURI the URI of the resource where the XML instance was stored
 * @throws XMLSecurityException
 */
public SignatureProperties(Element element, String BaseURI) throws XMLSecurityException {
    super(element, BaseURI);

    Attr attr = element.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        element.setIdAttributeNode(attr, true);
    }

    int length = getLength();
    for (int i = 0; i < length; i++) {
        Element propertyElem =
            XMLUtils.selectDsNode(this.constructionElement, Constants._TAG_SIGNATUREPROPERTY, i);
        Attr propertyAttr = propertyElem.getAttributeNodeNS(null, "Id");
        if (propertyAttr != null) {
            propertyElem.setIdAttributeNode(propertyAttr, true);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:SignatureProperties.java

示例11: engineCanResolve

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/** {@inheritDoc}. */
public boolean engineCanResolve(Element element, String baseURI, StorageResolver storage) {
    if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_X509DATA)) {
        try {
            X509Data x509Data = new X509Data(element, baseURI);
            return x509Data.containsDigest();
        } catch (XMLSecurityException e) {
            return false;
        }
    } else {
        return false;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:X509DigestResolver.java

示例12: engineLookupAndResolvePrivateKey

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Method engineResolvePrivateKey
 * @inheritDoc
 * @param element
 * @param baseURI
 * @param storage
 * @return resolved PrivateKey key or null if no {@link PrivateKey} could be obtained
 * @throws KeyResolverException
 */
public PrivateKey engineLookupAndResolvePrivateKey(
    Element element, String baseURI, StorageResolver storage
) throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
    }

    if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_X509DATA)) {
        PrivateKey privKey = resolveX509Data(element, baseURI);
        if (privKey != null) {
            return privKey;
        }
    } else if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve KeyName?");
        String keyName = element.getFirstChild().getNodeValue();

        try {
            Key key = keyStore.getKey(keyName, password);
            if (key instanceof PrivateKey) {
                return (PrivateKey) key;
            }
        } catch (Exception e) {
            log.log(java.util.logging.Level.FINE, "Cannot recover the key", e);
        }
    }

    log.log(java.util.logging.Level.FINE, "I can't");
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:PrivateKeyResolver.java

示例13: XMLSecurityException

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Constructor XMLSecurityException
 *
 * @param originalException
 */
public XMLSecurityException(Exception originalException) {

    super("Missing message ID to locate message string in resource bundle \""
          + Constants.exceptionMessagesResourceBundleBase
          + "\". Original Exception was a "
          + originalException.getClass().getName() + " and message "
          + originalException.getMessage(), originalException);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:XMLSecurityException.java

示例14: setId

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
/**
 * Sets the <code>Id</code> attribute
 *
 * @param Id <code>Id</code> attribute
 */
public void setId(String Id) {
    if (Id != null) {
        this.constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
        this.constructionElement.setIdAttributeNS(null, Constants._ATT_ID, true);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:ObjectContainer.java

示例15: validate

import com.sun.org.apache.xml.internal.security.utils.Constants; //导入依赖的package包/类
private static void validate(String data, boolean pass) throws Exception {
    System.out.println("Validating " + data);
    File file = new File(DIR, data);

    Document doc = dbf.newDocumentBuilder().parse(file);
    NodeList nl =
        doc.getElementsByTagNameNS(Constants.SignatureSpecNS, "Signature");
    if (nl.getLength() == 0) {
        throw new Exception("Couldn't find signature Element");
    }
    Element sigElement = (Element) nl.item(0);
    XMLSignature signature = new XMLSignature
        (sigElement, file.toURI().toString());
    SecretKey sk = signature.createSecretKey("secret".getBytes("ASCII"));
    try {
        System.out.println
            ("Validation status: " + signature.checkSignatureValue(sk));
        if (!pass) {
            System.out.println("FAILED");
            atLeastOneFailed = true;
        } else {
            System.out.println("PASSED");
        }
    } catch (XMLSignatureException xse) {
        System.out.println(xse.getMessage());
        if (!pass) {
            System.out.println("PASSED");
        } else {
            System.out.println("FAILED");
            atLeastOneFailed = true;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:TruncateHMAC.java


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