javax.xml.crypto.dsig.XMLSignContext类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中javax.xml.crypto.dsig.XMLSignContext类的一些代码示例,展示了XMLSignContext类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLSignContext类的具体详情如下:
包路径:javax.xml.crypto.dsig.XMLSignContext
类名称:XMLSignContext

XMLSignContext介绍

[英]Contains context information for generating XML Signatures. This interface is primarily intended for type-safety.

Note that XMLSignContext instances can contain information and state specific to the XML signature structure it is used with. The results are unpredictable if an XMLSignContext is used with different signature structures (for example, you should not use the same XMLSignContext instance to sign two different XMLSignature objects).

Supported Properties

The following properties can be set using the #setProperty method.

  • javax.xml.crypto.dsig.cacheReference: value must be a Boolean. This property controls whether or not the digested Reference objects will cache the dereferenced content and pre-digested input for subsequent retrieval via the Reference#getDereferencedData and Reference#getDigestInputStreammethods. The default value if not specified is Boolean.FALSE.
    [中]包含用于生成XML签名的上下文信息。该接口主要用于类型安全。
    请注意,XMLSignContext实例可以包含特定于它所使用的XML签名结构的信息和状态。如果XMLSignContext与不同的签名结构一起使用(例如,不应使用同一XMLSignContext实例对两个不同的XMLSignature对象进行签名),则结果是不可预测的。
    支持的属性
    可以使用#setProperty方法设置以下属性。
    *javax.xml.crypto.dsig.cacheReference:值必须是布尔值。此属性控制摘要引用对象是否将缓存取消引用的内容和预摘要输入,以便通过引用#GetDereferenceData和引用#getDigestInputStreammethods进行后续检索。如果未指定,则默认值为[$4$]。

代码示例

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-dom

signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
  signContext.putNamespacePrefix(
    WSConstants.C14N_EXCL_OMIT_COMMENTS,
    WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
  );
signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
wsDocInfo.setCallbackLookup(callbackLookup);

代码示例来源:origin: org.apache.santuario/xmlsec

Provider p = (Provider)context.getProperty
  ("org.jcp.xml.dsig.internal.dom.SignatureProvider");
signature = (p == null)

代码示例来源:origin: be.fedict.eid-applet/eid-applet-service-signer

URIDereferencer uriDereferencer = getURIDereferencer();
if (null != uriDereferencer) {
  xmlSignContext.setURIDereferencer(uriDereferencer);
  xmlSignContext.putNamespacePrefix(javax.xml.crypto.dsig.XMLSignature.XMLNS, this.signatureNamespacePrefix);

代码示例来源:origin: be.fedict.eid-applet/eid-applet-test-model

signContext.putNamespacePrefix(javax.xml.crypto.dsig.XMLSignature.XMLNS, "ds");

代码示例来源:origin: net.shibboleth.metadata/aggregator-pipeline

/** {@inheritDoc} */
@Override protected boolean doExecute(@Nonnull final Item<Element> item) throws StageProcessingException {
  Element element = item.unwrap();
  XMLSignature signature = xmlSigFactory.newXMLSignature(buildSignedInfo(element), buildKeyInfo());
  try {
    XMLSignContext context = new DOMSignContext(privKey, element, element.getFirstChild());
    
    // Enable caching reference values if required for debugging.
    if (isDebugPreDigest() && log.isDebugEnabled()) {
      context.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
    }
    
    // Perform the signature operation
    signature.sign(context);
    
    // Log the pre-digest data for debugging
    if (isDebugPreDigest() && log.isDebugEnabled()) {
      Reference ref = (Reference) signature.getSignedInfo().getReferences().get(0);
      String preDigest = CharStreams.toString(new InputStreamReader(ref.getDigestInputStream(), "UTF-8"));
      log.debug("pre digest: {}", preDigest);
    }
  } catch (Exception e) {
    log.error("Unable to create signature for element", e);
    throw new StageProcessingException("Unable to create signature for element", e);
  }
  return true;
}

代码示例来源:origin: org.apache.santuario/xmlsec

KeySelectorResult keySelectorResult = signContext.getKeySelector().select(ki,
                     KeySelector.Purpose.SIGN,
                     si.getSignatureMethod(),

代码示例来源:origin: be.fedict.eid-idp/eid-idp-common-saml2

signContext.putNamespacePrefix(
    javax.xml.crypto.dsig.XMLSignature.XMLNS, "ds");
javax.xml.crypto.dsig.DigestMethod digestMethod = signatureFactory

代码示例来源:origin: com.hynnet/xws-security

try { 
  sm = si.getSignatureMethod(); 
  keySelectoResult = xMLSignContext.getKeySelector().select(getKeyInfo(),KeySelector.Purpose.SIGN,sm,xMLSignContext); 
  signingKey = keySelectoResult.getKey(); 
  if (signingKey == null) { 
    throw new XMLSignatureException("The KeySelector"+ xMLSignContext.getKeySelector()+ " did not " + 
         "find the key used for signing");

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.wss4j

signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
  signContext.putNamespacePrefix(
    WSConstants.C14N_EXCL_OMIT_COMMENTS, 
    WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
  );
signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
wsDocInfo.setCallbackLookup(callbackLookup);

代码示例来源:origin: org.apache.ws.security/wss4j

signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
  signContext.putNamespacePrefix(
    WSConstants.C14N_EXCL_OMIT_COMMENTS, 
    WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
  );
signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
wsDocInfo.setCallbackLookup(callbackLookup);

代码示例来源:origin: org.apache.ws.security/wss4j

signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
  signContext.putNamespacePrefix(
    WSConstants.C14N_EXCL_OMIT_COMMENTS, 
    WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
  );
signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
wsDocInfo.setCallbackLookup(callbackLookup);

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-dom

signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
  signContext.putNamespacePrefix(
    WSConstants.C14N_EXCL_OMIT_COMMENTS,
    WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
  );
signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, getWsDocInfo());
getWsDocInfo().setCallbackLookup(callbackLookup);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.wss4j

signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
  signContext.putNamespacePrefix(
    WSConstants.C14N_EXCL_OMIT_COMMENTS, 
    WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
  );
signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
wsDocInfo.setCallbackLookup(callbackLookup);

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-dom

signContext = new DOMSignContext(key, securityHeaderElement);
signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(getSigCanonicalization())) {
  signContext.putNamespacePrefix(
    WSConstants.C14N_EXCL_OMIT_COMMENTS,
    WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
  );
signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, getWsDocInfo());
getWsDocInfo().setCallbackLookup(callbackLookup);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.wss4j

signContext = new DOMSignContext(key, securityHeaderElement);
signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
  signContext.putNamespacePrefix(
    WSConstants.C14N_EXCL_OMIT_COMMENTS, 
    WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
  );
signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
wsDocInfo.setCallbackLookup(callbackLookup);

代码示例来源:origin: org.apache.ws.security/wss4j

signContext = new DOMSignContext(key, securityHeaderElement);
signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
  signContext.putNamespacePrefix(
    WSConstants.C14N_EXCL_OMIT_COMMENTS, 
    WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
  );
signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
wsDocInfo.setCallbackLookup(callbackLookup);

相关文章