es.gob.afirma.core.misc.Base64.decode()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(91)

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

Base64.decode介绍

[英]Descodifica datos en Base64.
[中]说明基准数据64。

代码示例

代码示例来源:origin: es.gob.afirma/afirma-core

/** Descodifica datos en Base64.
 * @param str Cadena de caracteres en formato Base64
 * @return Datos descodificados
 * @throws java.io.IOException si ocurre cualquier error */
public static byte[] decode(final String str) throws java.io.IOException {
  return decode(str, false);
}

代码示例来源:origin: es.gob.afirma/afirma-core

/** Descodifica datos en Base64.
 * @param str Cadena de caracteres en formato Base64
 * @param urlSafe Si se establece a <code>true</code> indica que los datos est&aacute;n con un alfabeto Base64
 *                susceptible de ser usado en URL, seg&uacute;n se indica en la seccti&oacute;n 4 de la RFC3548,
 *                si se establece a <code>false</code> los datos deben estar en Base64 normal
 * @return Datos descodificados
 * @throws java.io.IOException si ocurre cualquier error */
public static byte[] decode(final String str, final boolean urlSafe) throws java.io.IOException {
  if( str == null ){
    throw new IllegalArgumentException("Input string was null"); //$NON-NLS-1$
  }
  final byte[] bytes = str.getBytes(PREFERRED_ENCODING);
  return decode( bytes, 0, bytes.length, urlSafe);
}

代码示例来源:origin: es.gob.afirma/afirma-core

/** Convierte una cadena Base64 en un objeto de propiedades.
 * @param base64 Base64 que descodificado es un fichero de propiedades en texto plano.
 * @return Objeto de propiedades.
 * @throws IOException Si hay problemas en el proceso. */
public static Properties base642Properties(final String base64) throws IOException {
  final Properties p = new Properties();
  if (base64 == null || base64.isEmpty()) {
    return p;
  }
  p.load(
  new InputStreamReader(
      new ByteArrayInputStream(Base64.decode(base64)
  ),
  DEFAULT_ENCODING)
  );
  return p;
}

代码示例来源:origin: es.gob.afirma/afirma-core

protected static String getDefaultKeyStoreLib(final Map<String, String> params) {

    // Si se ha especificado un almacen, se usara ese
    String ksValue = null;
    if (params.get(KEYSTORE_OLD_PARAM) != null) {
      ksValue = params.get(KEYSTORE_OLD_PARAM);
    }
    else if (params.get(KEYSTORE_PARAM) != null) {
      try {
        ksValue = new String(Base64.decode(params.get(KEYSTORE_PARAM)));
      }
      catch (final Exception e) {
        // Interpretamos que no era Base64 y no se ha pasado un almacen valido
      }
    }

    if (ksValue == null) {
      return null;
    }

    final int separatorPos = ksValue.indexOf(':');
    if (separatorPos != -1 && separatorPos < ksValue.length() - 1) {
      return ksValue.substring(separatorPos + 1).trim();
    }
    return null;
  }
}

代码示例来源:origin: es.gob.afirma/afirma-crypto-core-xml

/** Crea un X509Certificate a partir de un certificado en Base64.
 * @param b64Cert Certificado en Base64. No debe incluir <i>Bag Attributes</i>.
 * @return Certificado X509 o <code>null</code> si no se pudo crear. */
public static X509Certificate createCert(final String b64Cert) {
  if (b64Cert == null || b64Cert.isEmpty()) {
    LOGGER.severe("Se ha proporcionado una cadena nula o vacia, se devolvera null"); //$NON-NLS-1$
    return null;
  }
  final X509Certificate cert;
  try (
    final InputStream isCert = new ByteArrayInputStream(Base64.decode(b64Cert));
  ) {
    cert = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(isCert); //$NON-NLS-1$
    try {
      isCert.close();
    }
    catch (final Exception e) {
      LOGGER.warning("Error cerrando el flujo de lectura del certificado: " + e); //$NON-NLS-1$
    }
  }
  catch (final Exception e) {
    LOGGER.severe("No se pudo decodificar el certificado en Base64, se devolvera null: " + e); //$NON-NLS-1$
    return null;
  }
  return cert;
}

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf

static com.aowagie.text.Image getImage(final String imagebase64Encoded) {
  if (imagebase64Encoded == null || imagebase64Encoded.isEmpty()) {
    return null;
  }
  final byte[] image;
  try {
    image = Base64.decode(imagebase64Encoded);
  }
  catch (final Exception e) {
    LOGGER.severe("Se ha proporcionado una imagen de rubrica que no esta codificada en Base64: " + e); //$NON-NLS-1$
    return null;
  }
  try {
    return new Jpeg(image);
  }
  catch (final Exception e) {
    LOGGER.info("Se ha proporcionado una imagen de rubrica que no esta codificada en JPEG: " + e); //$NON-NLS-1$
  }
  return null;
}

代码示例来源:origin: es.gob.afirma/afirma-crypto-batch-client

private static String getAlgorithm(final String batch) throws IOException {
  final byte[] xml =  Base64.decode(batch.replace("-", "+").replace("_", "/")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  final Document doc;
  try (

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf

static void attachFile(final Properties extraParams, final PdfStamper stp) throws IOException {
  if (extraParams == null) {
    return;
  }
  if (stp == null) {
    throw new IllegalArgumentException("No se puede adjuntar un fichero a un PdfStamper nulo"); //$NON-NLS-1$
  }
  // Contenido a adjuntar (en Base64)
  final String b64Attachment = extraParams.getProperty(PdfExtraParams.ATTACH);
  // Nombre que se pondra al fichero adjunto en el PDF
  final String attachmentFileName = extraParams.getProperty(PdfExtraParams.ATTACH_FILENAME);
  // Descripcion del adjunto
  final String attachmentDescription = extraParams.getProperty(PdfExtraParams.ATTACH_DESCRIPTION);
  if (b64Attachment != null && attachmentFileName != null) {
    final byte[] attachment;
    try {
      attachment = Base64.decode(b64Attachment);
    }
    catch(final IOException e) {
      LOGGER.warning("Se ha indicado un adjunto, pero no estaba en formato Base64, se ignorara : " + e); //$NON-NLS-1$
      return;
    }
    stp.getWriter().addFileAttachment(attachmentDescription, attachment, null, attachmentFileName);
  }
}

代码示例来源:origin: es.gob.afirma/afirma-crypto-core-xml

pkcs1 = Base64.decode(((Element) signature.getElementsByTagNameNS(XMLConstants.DSIGNNS, "SignatureValue").item(0)).getTextContent()); //$NON-NLS-1$

代码示例来源:origin: es.gob.afirma/afirma-keystores-single

Base64.decode(
 new String(certs).replace("%0A", "").replace("%2F", "/").replace("%2B", "+").replace("%3D", "=") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf

throw new IOException("No se encontro el nodo 'sign' del PdfSignResultSerializado"); //$NON-NLS-1$
this.sign = Base64.decode(node.getTextContent().trim());
  );
this.timestamp = node.getTextContent().trim().isEmpty() ? null : Base64.decode(node.getTextContent().trim());

代码示例来源:origin: es.gob.afirma/afirma-crypto-xmlsignature

return Base64.decode(firstChild.getTextContent());
return Base64.decode(object.getTextContent());

代码示例来源:origin: es.gob.afirma/afirma-core

Logger.getLogger("es.gob.afirma").info("El contenido a obtener es Base64"); //$NON-NLS-1$ //$NON-NLS-2$
try {
  return Base64.decode(dataSource.replace("_", "/").replace("-", "+")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

代码示例来源:origin: es.gob.afirma/afirma-core-massive

try {
  signs[i] = signer.sign(
    Base64.decode(hashes[i]),
    this.algorithm,
    keyEntry.getPrivateKey(),

代码示例来源:origin: es.gob.afirma/afirma-core

ksValue = new String(Base64.decode(params.get(KEYSTORE_PARAM)));

代码示例来源:origin: es.gob.afirma/afirma-crypto-pdf

return;
final byte[] image = Base64.decode(imageDataBase64);

代码示例来源:origin: es.gob.afirma/afirma-crypto-cadestri-client

triphaseData = TriphaseData.parser(Base64.decode(preSignResult, 0, preSignResult.length, true));
return Base64.decode(stringTrimmedResult.substring((SUCCESS + " NEWID=").length()), true); //$NON-NLS-1$

代码示例来源:origin: es.gob.afirma/afirma-crypto-cms-enveloper

this.cipherKey = new SecretKeySpec(Base64.decode(key), this.config.getAlgorithm().getName());

代码示例来源:origin: es.gob.afirma/afirma-core

preSign = Base64.decode(base64PreSign);

代码示例来源:origin: es.gob.afirma/afirma-crypto-cades

hashed = Base64.decode(policy.getPolicyIdentifierHash());

相关文章

微信公众号

最新文章

更多