org.apache.xml.security.utils.Base64.decode()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(133)

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

Base64.decode介绍

[英]Base64 decode the lines from the reader and return an InputStream with the bytes.
[中]Base64对来自读卡器的行进行解码,并返回带有字节的InputStream。

代码示例

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

/**
 * Decodes Base64 data into outputstream
 *
 * @param base64Data Byte array containing Base64 data
 * @param os the outputstream
 * @throws IOException
 * @throws Base64DecodingException
 */
public static final void decode(byte[] base64Data, OutputStream os)
  throws Base64DecodingException, IOException {
  decode(base64Data, os, -1);
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.relyingparty

certInBytes = Base64.decode(certValue);
inputStream = new ByteArrayInputStream(certInBytes);
factory = CertificateFactory.getInstance("X509");

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

/**
 * Method decodeBigIntegerFromElement
 *
 * @param element
 * @return the biginteger obtained from the node
 * @throws Base64DecodingException
 */
public static final BigInteger decodeBigIntegerFromElement(Element element)
  throws Base64DecodingException {
  return new BigInteger(1, Base64.decode(element));
}

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

/**
 * Decode a base 64 string into a {@link BigInteger}
 * @param base64str Base 64 encoded string.
 * @return a decoded BigInteger
 * @throws Base64DecodingException
 */
public static BigInteger decodeBigIntegerFromString(String base64str)
    throws Base64DecodingException {
  return new BigInteger(1, Base64.decode(base64str));
}

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

/**
 * Decodes Base64 data into outputstream
 *
 * @param base64Data String containing Base64 data
 * @param os the outputstream
 * @throws IOException
 * @throws Base64DecodingException
 */
public static final void decode(String base64Data, OutputStream os)
  throws Base64DecodingException, IOException {
  byte[] bytes = new byte[base64Data.length()];
  int len = getBytesInternal(base64Data, bytes);
  decode(bytes, os, len);
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.core

public static String getPPIDDisplayValue(String value) throws Exception {
  log.info("Generating display value of PPID : " + value);
  byte[] rawPpid = Base64.decode(value);
  MessageDigest sha1 = MessageDigest.getInstance("SHA1");
  sha1.update(rawPpid);
  byte[] hashId = sha1.digest();
  char[] returnChars = new char[10];
  for (int i = 0; i < 10; i++) {
    int rawValue = (hashId[i] + 128) % 32;
    returnChars[i] = ppidDisplayCharMap[rawValue];
  }
  StringBuilder sb = new StringBuilder();
  sb.append(returnChars, 0, 3);
  sb.append("-");
  sb.append(returnChars, 3, 4);
  sb.append("-");
  sb.append(returnChars, 6, 3);
  return sb.toString();
}

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

/**
 * Method decode
 *
 * Takes the <CODE>Text</CODE> children of the Element and interprets
 * them as input for the <CODE>Base64.decode()</CODE> function.
 *
 * @param element
 * @return the byte obtained of the decoding the element
 * $todo$ not tested yet
 * @throws Base64DecodingException
 */
public static final byte[] decode(Element element) throws Base64DecodingException {
  Node sibling = element.getFirstChild();
  StringBuilder sb = new StringBuilder();
  while (sibling != null) {
    if (sibling.getNodeType() == Node.TEXT_NODE) {
      Text t = (Text) sibling;
      sb.append(t.getData());
    }
    sibling = sibling.getNextSibling();
  }
  return decode(sb.toString());
}

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.core

public static String getPPIDDisplayValue(String value) throws Exception {
  if (log.isDebugEnabled()) {
    log.debug("Generating display value of PPID : " + value);
  }
  byte[] rawPpid = Base64.decode(value);
  MessageDigest sha1 = MessageDigest.getInstance("SHA1");
  sha1.update(rawPpid);
  byte[] hashId = sha1.digest();
  char[] returnChars = new char[10];
  for (int i = 0; i < 10; i++) {
    int rawValue = (hashId[i] + 128) % 32;
    returnChars[i] = ppidDisplayCharMap[rawValue];
  }
  StringBuilder sb = new StringBuilder();
  sb.append(returnChars, 0, 3);
  sb.append("-");
  sb.append(returnChars, 3, 4);
  sb.append("-");
  sb.append(returnChars, 6, 3);
  return sb.toString();
}

代码示例来源:origin: wso2/carbon-identity-framework

public static String getPPIDDisplayValue(String value) throws Exception {
  if (log.isDebugEnabled()) {
    log.debug("Generating display value of PPID : " + value);
  }
  byte[] rawPpid = Base64.decode(value);
  MessageDigest sha1 = MessageDigest.getInstance("SHA1");
  sha1.update(rawPpid);
  byte[] hashId = sha1.digest();
  char[] returnChars = new char[10];
  for (int i = 0; i < 10; i++) {
    int rawValue = (hashId[i] + 128) % 32;
    returnChars[i] = ppidDisplayCharMap[rawValue];
  }
  StringBuilder sb = new StringBuilder();
  sb.append(returnChars, 0, 3);
  sb.append("-");
  sb.append(returnChars, 3, 4);
  sb.append("-");
  sb.append(returnChars, 6, 3);
  return sb.toString();
}

代码示例来源:origin: org.apache.cxf.fediz/fediz-idp-core

private void validateSeparateSignature(Idp idp, String sigAlg, String signature, String relayState,
                    String samlRequest, String realm) throws Exception {
  // Check signature
  X509Certificate validatingCert = getValidatingCertificate(idp, realm);
  // Process the received SigAlg parameter - fall back to RSA SHA1
  String processedSigAlg = null;
  if (sigAlg != null && SIG_ALGS.contains(sigAlg)) {
    processedSigAlg = sigAlg;
  } else {
    LOG.debug("Supplied SigAlg parameter is either null or not known, so falling back to use RSA-SHA1");
    processedSigAlg = SSOConstants.RSA_SHA1;
  }
  java.security.Signature sig =
    java.security.Signature.getInstance(JCEMapper.translateURItoJCEID(processedSigAlg));
  sig.initVerify(validatingCert);
  // Recreate request to sign
  String requestToSign =
      SSOConstants.SAML_REQUEST + "=" + URLEncoder.encode(samlRequest, StandardCharsets.UTF_8.name())
      + "&" + SSOConstants.RELAY_STATE + "=" + URLEncoder.encode(relayState, StandardCharsets.UTF_8.name())
      + "&" + SSOConstants.SIG_ALG + "=" + URLEncoder.encode(processedSigAlg, StandardCharsets.UTF_8.name());
  sig.update(requestToSign.getBytes(StandardCharsets.UTF_8));
  if (!sig.verify(Base64.decode(signature))) {
    LOG.debug("Signature validation failed");
    throw new ProcessingException(TYPE.BAD_REQUEST);
  }
}

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

/**
 * Base64 decode the lines from the reader and return an InputStream
 * with the bytes.
 *
 * @param reader
 * @return InputStream with the decoded bytes
 * @exception IOException passes what the reader throws
 * @throws IOException
 * @throws Base64DecodingException
 */
public static final byte[] decode(BufferedReader reader)
  throws IOException, Base64DecodingException {
  byte[] retBytes = null;
  UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
  try {
    String line;
    while (null != (line = reader.readLine())) {
      byte[] bytes = decode(line);
      baos.write(bytes);
    }
    retBytes = baos.toByteArray();
  } finally {
    baos.close();
  }
  return retBytes;
}

代码示例来源:origin: Evolveum/midpoint

byte[] cipherValueBytes;
try {
  cipherValueBytes = Base64.decode(cipherValue);
} catch (Base64DecodingException e) {
  throw new IllegalArgumentException("Bad base64 encoding in CipherValue element: "+e.getMessage(),e);

相关文章