gpt4 book ai didi

org.apache.wss4j.dom.util.WSSecurityUtil.generateNonce()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 20:41:05 25 4
gpt4 key购买 nike

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

WSSecurityUtil.generateNonce介绍

[英]Generate a nonce of the given length using the SHA1PRNG algorithm. The SecureRandom instance that backs this method is cached for efficiency.
[中]使用SHA1PRNG算法生成给定长度的nonce。为了提高效率,会缓存支持此方法的SecureRandom实例。

代码示例

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

/**
 * Creates and adds a Nonce element to this UsernameToken
 */
public void addNonce(Document doc) {
  if (elementNonce != null) {
    return;
  }
  byte[] nonceValue = null;
  try {
    nonceValue = WSSecurityUtil.generateNonce(16);
  } catch (WSSecurityException ex) {
    LOG.debug(ex.getMessage(), ex);
    return;
  }
  elementNonce = doc.createElementNS(WSConstants.WSSE_NS, "wsse:" + WSConstants.NONCE_LN);
  elementNonce.appendChild(doc.createTextNode(org.apache.xml.security.utils.XMLUtils.encodeToString(nonceValue)));
  elementNonce.setAttributeNS(null, "EncodingType", BASE64_ENCODING);
  element.appendChild(elementNonce);
}

代码示例来源:origin: apache/cxf

protected byte[] writeElementsForRSTSymmetricKey(W3CDOMStreamWriter writer,
    boolean wroteKeySize) throws Exception {
  byte[] requestorEntropy = null;
  if (!wroteKeySize) {
    addKeySize(keySize, writer);
  }
  if (requiresEntropy) {
    writer.writeStartElement("wst", "Entropy", namespace);
    writer.writeStartElement("wst", "BinarySecret", namespace);
    writer.writeAttribute("Type", namespace + "/Nonce");
    if (algorithmSuite == null) {
      requestorEntropy = WSSecurityUtil.generateNonce(keySize / 8);
    } else {
      AlgorithmSuiteType algType = algorithmSuite.getAlgorithmSuiteType();
      requestorEntropy = WSSecurityUtil
        .generateNonce(algType.getMaximumSymmetricKeyLength() / 8);
    }
    writer.writeCharacters(org.apache.xml.security.utils.XMLUtils.encodeToString(requestorEntropy));
    writer.writeEndElement();
    writer.writeEndElement();
    writer.writeStartElement("wst", "ComputedKeyAlgorithm", namespace);
    writer.writeCharacters(namespace + "/CK/PSHA1");
    writer.writeEndElement();
  }
  return requestorEntropy;
}

代码示例来源:origin: apache/cxf

entropyBytes = WSSecurityUtil.generateNonce(keySize / 8);
  secret = entropyBytes;
} catch (WSSecurityException ex) {

代码示例来源:origin: org.apache.cxf/cxf-rt-ws-security

protected byte[] writeElementsForRSTSymmetricKey(W3CDOMStreamWriter writer,
    boolean wroteKeySize) throws Exception {
  byte[] requestorEntropy = null;
  if (!wroteKeySize) {
    addKeySize(keySize, writer);
  }
  if (requiresEntropy) {
    writer.writeStartElement("wst", "Entropy", namespace);
    writer.writeStartElement("wst", "BinarySecret", namespace);
    writer.writeAttribute("Type", namespace + "/Nonce");
    if (algorithmSuite == null) {
      requestorEntropy = WSSecurityUtil.generateNonce(keySize / 8);
    } else {
      AlgorithmSuiteType algType = algorithmSuite.getAlgorithmSuiteType();
      requestorEntropy = WSSecurityUtil
        .generateNonce(algType.getMaximumSymmetricKeyLength() / 8);
    }
    writer.writeCharacters(org.apache.xml.security.utils.XMLUtils.encodeToString(requestorEntropy));
    writer.writeEndElement();
    writer.writeEndElement();
    writer.writeStartElement("wst", "ComputedKeyAlgorithm", namespace);
    writer.writeCharacters(namespace + "/CK/PSHA1");
    writer.writeEndElement();
  }
  return requestorEntropy;
}

代码示例来源:origin: org.apache.cxf.services.sts/cxf-services-sts-core

entropyBytes = WSSecurityUtil.generateNonce(keySize / 8);
  secret = entropyBytes;
} catch (WSSecurityException ex) {

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

String labelText = clientLabel + serviceLabel;
label = labelText.getBytes(StandardCharsets.UTF_8);
byte[] nonce = WSSecurityUtil.generateNonce(16);

代码示例来源:origin: apache/cxf

writer.writeStartElement(prefix, "RequestedProofToken", namespace);
if (clientEntropy == null) {
  secret = WSSecurityUtil.generateNonce(keySize / 8);
  writer.writeEndElement();
} else {
  byte[] entropy = WSSecurityUtil.generateNonce(keySize / 8);
  P_SHA1 psha1 = new P_SHA1();
  secret = psha1.createKey(clientEntropy, entropy, 0, keySize / 8);

代码示例来源:origin: org.apache.cxf/cxf-rt-ws-security

writer.writeStartElement(prefix, "RequestedProofToken", namespace);
if (clientEntropy == null) {
  secret = WSSecurityUtil.generateNonce(keySize / 8);
  writer.writeEndElement();
} else {
  byte[] entropy = WSSecurityUtil.generateNonce(keySize / 8);
  P_SHA1 psha1 = new P_SHA1();
  secret = psha1.createKey(clientEntropy, entropy, 0, keySize / 8);

代码示例来源:origin: apache/cxf

writer.writeEndElement();
byte[] secret = WSSecurityUtil.generateNonce(keySize / 8);
byte[] key = spnegoToken.wrapKey(secret);

代码示例来源:origin: org.apache.cxf/cxf-rt-ws-security

writer.writeEndElement();
byte[] secret = WSSecurityUtil.generateNonce(keySize / 8);
byte[] key = spnegoToken.wrapKey(secret);

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com