org.jboss.resteasy.util.Base64.decode()方法的使用及代码示例

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

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

Base64.decode介绍

[英]Decodes data from Base64 notation, automatically detecting gzip-compressed data and decompressing it.
[中]对Base64符号中的数据进行解码,自动检测gzip压缩数据并对其进行解压缩。

代码示例

代码示例来源:origin: weibocom/motan

public static Exception getCause(BuiltResponse resp) {
  if (resp == null || resp.getStatus() != Status.EXPECTATION_FAILED.getStatusCode())
    return null;
  String exceptionClass = resp.getHeaderString(EXCEPTION_HEADER);
  if (!StringUtils.isBlank(exceptionClass)) {
    String body = resp.readEntity(String.class);
    resp.close();
    try {
      ByteArrayInputStream bais = new ByteArrayInputStream(
          Base64.decode(body.getBytes(MotanConstants.DEFAULT_CHARACTER)));
      ObjectInputStream ois = new ObjectInputStream(bais);
      return (Exception) ois.readObject();
    } catch (Exception e) {
      LoggerUtil.error("deserialize " + exceptionClass + " error", e);
    }
  }
  return null;
}

代码示例来源:origin: resteasy/Resteasy

/**
* Decodes data from Base64 notation, automatically
* detecting gzip-compressed data and decompressing it.
*
* @param s the string to decode
* @return the decoded data
* @throws java.io.IOException If there is a problem
* @since 1.4
*/
public static byte[] decode(String s) throws java.io.IOException
{
 return decode(s, NO_OPTIONS);
}

代码示例来源:origin: resteasy/Resteasy

/**
  * Low-level access to decoding ASCII characters in
  * the form of a byte array. <strong>Ignores GUNZIP option, if
  * it's set.</strong> This is not generally a recommended method,
  * although it is used internally as part of the decoding process.
  * Special case: if len = 0, an empty array is returned. Still,
  * if you need more speed and reduced memory footprint (and aren't
  * gzipping), consider this method.
  *
  * @param source The Base64 encoded data
  * @return decoded data
  * @throws IOException If bogus characters exist in source data
  * @since 2.3.1
  */
  public static byte[] decode(byte[] source)
     throws java.io.IOException
  {
   byte[] decoded = null;
//        try {
   decoded = decode(source, 0, source.length, Base64.NO_OPTIONS);
//        } catch( java.io.IOException ex ) {
//            assert false : "IOExceptions only come from GZipping, which is turned off: " + ex.getMessage();
//        }
   return decoded;
  }

代码示例来源:origin: resteasy/Resteasy

/**
* Decode a PEM string to DER format.
*
* @param pem PEM encoded string
* @return decoded bytes
* @throws java.io.IOException if I/O error occurred
*/
public static byte[] pemToDer(String pem) throws java.io.IOException
{
 pem = removeBeginEnd(pem);
 return Base64.decode(pem);
}

代码示例来源:origin: resteasy/Resteasy

protected void extractAttributes()
{
 String heads = attributes.get(HEADERS);
 if (heads != null)
 {
   headers = Arrays.asList(heads.split(":"));
 }
 String sig = attributes.get(SIGNATURE);
 try
 {
   if (sig != null) signature = Base64.decode(sig);
 }
 catch (IOException e)
 {
   throw new RuntimeException(e);
 }
}

代码示例来源:origin: resteasy/Resteasy

/**
* Base64 encoded pks bytes.
*
* @param base64 Base64 encoded string
*/
public PKCS7SignatureInput(final String base64)
{
 try
 {
   byte[] bytes = Base64.decode(base64);
   this.data = new CMSSignedData(bytes);
 }
 catch (Exception e)
 {
   throw new RuntimeException(e);
 }
}

代码示例来源:origin: resteasy/Resteasy

public static byte[] decode(String s)
{
 s = s.replace('-', '+'); // 62nd char of encoding
 s = s.replace('_', '/'); // 63rd char of encoding
 switch (s.length() % 4) // Pad with trailing '='s
 {
   case 0: break; // No pad chars in this case
   case 2: s += "=="; break; // Two pad chars
   case 3: s += "="; break; // One pad char
   default: throw new RuntimeException(Messages.MESSAGES.illegalBase64UrlString());
 }
 try
 {
   return Base64.decode(s);
 }
 catch (Exception e)
 {
   throw new RuntimeException(e);
 }
}

代码示例来源:origin: resteasy/Resteasy

byte[] objBytes = decode(encodedObject, options);

代码示例来源:origin: resteasy/Resteasy

bytes = decode(bytes, 0, bytes.length, options);

代码示例来源:origin: resteasy/Resteasy

byte[] der = Base64.decode(pem);

代码示例来源:origin: resteasy/Resteasy

try
 enclosedBh = Base64.decode(encodedBh);

代码示例来源:origin: org.jboss.resteasy/resteasy-core

/**
* Decodes data from Base64 notation, automatically
* detecting gzip-compressed data and decompressing it.
*
* @param s the string to decode
* @return the decoded data
* @throws java.io.IOException If there is a problem
* @since 1.4
*/
public static byte[] decode(String s) throws java.io.IOException
{
 return decode(s, NO_OPTIONS);
}

代码示例来源:origin: org.jboss.resteasy/resteasy-jaxrs-20

/**
* Decodes data from Base64 notation, automatically
* detecting gzip-compressed data and decompressing it.
*
* @param s the string to decode
* @return the decoded data
* @throws java.io.IOException If there is a problem
* @since 1.4
*/
public static byte[] decode(String s) throws java.io.IOException
{
 return decode(s, NO_OPTIONS);
}

代码示例来源:origin: org.jboss.resteasy/resteasy-jaxrs-20

/**
  * Low-level access to decoding ASCII characters in
  * the form of a byte array. <strong>Ignores GUNZIP option, if
  * it's set.</strong> This is not generally a recommended method,
  * although it is used internally as part of the decoding process.
  * Special case: if len = 0, an empty array is returned. Still,
  * if you need more speed and reduced memory footprint (and aren't
  * gzipping), consider this method.
  *
  * @param source The Base64 encoded data
  * @return decoded data
  * @since 2.3.1
  */
  public static byte[] decode(byte[] source)
      throws java.io.IOException
  {
   byte[] decoded = null;
//        try {
   decoded = decode(source, 0, source.length, Base64.NO_OPTIONS);
//        } catch( java.io.IOException ex ) {
//            assert false : "IOExceptions only come from GZipping, which is turned off: " + ex.getMessage();
//        }
   return decoded;
  }

代码示例来源:origin: yaoguangluo/DETA_BackEnd

public static String decode(String str) {
  byte[] bt = null;
  try {
    bt = Base64.decode(str);
  } catch (Exception e) {
    e.printStackTrace();
  }
  return new String(bt);
}

代码示例来源:origin: NationalSecurityAgency/datawave

public static String decodeId(String encodedId) throws IOException {
    String key64 = URLDecoder.decode(encodedId, "UTF-8");
    byte[] bKey = Base64.decode(key64);
    return new String(bKey);
  }
}

代码示例来源:origin: yaoguangluo/DETA_CACHE

public static String decode(String str) {
  byte[] bt = null;
  try {
    bt = Base64.decode(str);
  } catch (Exception e) {
    e.printStackTrace();
  }
  return new String(bt);
}

代码示例来源:origin: org.jboss.resteasy/skeleton-key-core

/**
* Decode a PEM string to DER format
*
* @param pem
* @return
* @throws java.io.IOException
*/
public static byte[] pemToDer(String pem) throws IOException
{
 pem = removeBeginEnd(pem);
 return Base64.decode(pem);
}

代码示例来源:origin: NationalSecurityAgency/datawave

private Key deserializeKey(String k) throws Exception {
  String key64 = URLDecoder.decode(k, "UTF-8");
  byte[] bKey = Base64.decode(key64);
  ByteArrayInputStream bais = new ByteArrayInputStream(bKey);
  DataInputStream in = new DataInputStream(bais);
  Key key = new Key();
  key.readFields(in);
  return key;
}

代码示例来源:origin: org.jboss.resteasy/jose-jwt

public static byte[] decode(String s)
{
 s = s.replace('-', '+'); // 62nd char of encoding
 s = s.replace('_', '/'); // 63rd char of encoding
 switch (s.length() % 4) // Pad with trailing '='s
 {
   case 0: break; // No pad chars in this case
   case 2: s += "=="; break; // Two pad chars
   case 3: s += "="; break; // One pad char
   default: throw new RuntimeException(Messages.MESSAGES.illegalBase64UrlString());
 }
 try
 {
   return Base64.decode(s);
 }
 catch (Exception e)
 {
   throw new RuntimeException(e);
 }
}

相关文章