com.nimbusds.jose.util.Base64类的使用及代码示例

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

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

Base64介绍

[英]Base64-encoded object.
[中]Base64编码对象。

代码示例

代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server

@Override
  protected ClientHttpRequest createRequest(URI url, HttpMethod method) throws IOException {
    ClientHttpRequest httpRequest = super.createRequest(url, method);
    httpRequest.getHeaders().add("Authorization",
        String.format("Basic %s", Base64.encode(String.format("%s:%s", clientId, clientSecret)) ));
    return httpRequest;
  }
};

代码示例来源:origin: org.pac4j/pac4j-jwt

public void setSecretBase64(final String secret) {
  this.secret = new Base64(secret).decode();
}

代码示例来源:origin: org.pac4j/pac4j-jwt

public String getSecretBase64() {
  return Base64.encode(secret).toString();
}

代码示例来源:origin: com.nimbusds/nimbus-jose-jwt

/**
 * Base64-encodes the specified byte array. 
 *
 * @param bytes The byte array to encode. Must not be {@code null}.
 *
 * @return The resulting Base64 object.
 */
public static Base64 encode(final byte[] bytes) {
  return new Base64(Base64Codec.encodeToString(bytes, false));
}

代码示例来源:origin: com.nimbusds/nimbus-jose-jwt

/**
 * Decodes this Base64 object to an unsigned big integer.
 *
 * <p>Same as {@code new BigInteger(1, base64.decode())}.
 *
 * @return The resulting big integer.
 */
public BigInteger decodeToBigInteger() {
  return new BigInteger(1, decode());
}

代码示例来源:origin: de.adorsys.oauth/oauth-server

private String[] getNamePassword(HttpServletRequest httpRequest) {
  String authValue = httpRequest.getHeader("Authorization");
  if (authValue != null && authValue.startsWith("Basic ")) {
    String encodedValue = authValue.substring(6);
    String decodedValue = new Base64(encodedValue).decodeToString();
    final String[] namePassword = decodedValue.contains(":") ? decodedValue.split(":")
        : new String[] { decodedValue, "" };
    return namePassword;
  } else if (httpRequest.getContentType().contains("application/x-www-form-urlencoded")) {
    String clientId = httpRequest.getParameter("client_id");
    String clientSecret = httpRequest.getParameter("client_secret");
    if (clientId == null || clientSecret == null) {
      return null;
    }
    return new String[]{clientId, clientSecret};
  } else {
    return null;			
  }
}

代码示例来源:origin: com.nimbusds/nimbus-jose-jwt

/**
 * Overrides {@code Object.equals()}.
 *
 * @param object The object to compare to.
 *
 * @return {@code true} if the objects have the same value, otherwise
 *         {@code false}.
 */
@Override
public boolean equals(final Object object) {
  return object != null && 
      object instanceof Base64 && 
      this.toString().equals(object.toString());
}

代码示例来源:origin: de.adorsys.oauth/oauth-server

private static byte[] getSecretKey() {
  return new Base64(SECRET_KEY).decode();
}

代码示例来源:origin: org.pac4j/pac4j-jwt

public String getSecretBase64() {
  return Base64.encode(secret).toString();
}

代码示例来源:origin: com.nimbusds/nimbus-jose-jwt

/**
 * Converts the specified JSON array of strings to a list of Base64
 * encoded objects.
 *
 * @param jsonArray The JSON array of string, {@code null} if not
 *                  specified.
 *
 * @return The Base64 list, {@code null} if not specified.
 *
 * @throws ParseException If parsing failed.
 */
public static List<Base64> toBase64List(final JSONArray jsonArray)
  throws ParseException {
  
  if (jsonArray == null)
    return null;
  List<Base64> chain = new LinkedList<>();
  for (int i=0; i < jsonArray.size(); i++) {
    Object item = jsonArray.get(i);
    if (item == null) {
      throw new ParseException("The X.509 certificate at position " + i + " must not be null", 0);
    }
    if  (! (item instanceof String)) {
      throw new ParseException("The X.509 certificate at position " + i + " must be encoded as a Base64 string", 0);
    }
    chain.add(new Base64((String)item));
  }
  return chain;
}

代码示例来源:origin: com.nimbusds/nimbus-jose-jwt

/**
 * Decodes this Base64 object to a string.
 *
 * @return The resulting string, in the UTF-8 character set.
 */
public String decodeToString() {
  return new String(decode(), StandardCharset.UTF_8);
}

代码示例来源:origin: gravitee-io/graviteeio-access-management

jwk.setX5c(nimbusJwk.getX509CertChain().stream().map(cert -> cert.toString()).collect(Collectors.toSet()));

代码示例来源:origin: org.pac4j/pac4j-jwt

public void setSecretBase64(final String secret) {
  this.secret = new Base64(secret).decode();
}

代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server

@Override
  protected ClientHttpRequest createRequest(URI url, HttpMethod method) throws IOException {
    ClientHttpRequest httpRequest = super.createRequest(url, method);
    httpRequest.getHeaders().add("Authorization",
        String.format("Basic %s", Base64.encode(String.format("%s:%s",
            UriUtils.encodePathSegment(clientConfig.getClientId(), "UTF-8"),
            UriUtils.encodePathSegment(clientConfig.getClientSecret(), "UTF-8")))));
    return httpRequest;
  }
};

代码示例来源:origin: com.nimbusds/nimbus-jose-jwt

sb.append(Base64.encode(cert.getEncoded()).toString());
} catch (CertificateEncodingException e) {
  return null;

代码示例来源:origin: com.microsoft.aad/adal4j

JWSHeader.Builder builder = new Builder(JWSAlgorithm.RS256);
List<Base64> certs = new ArrayList<Base64>();
certs.add(new Base64(credential.getPublicCertificate()));
builder.x509CertChain(certs);
builder.x509CertThumbprint(new Base64URL(credential

代码示例来源:origin: com.nimbusds/nimbus-jose-jwt

X509Certificate cert = X509CertUtils.parse(b64List.get(i).decode());

代码示例来源:origin: org.apereo.cas/cas-server-support-token-authentication

/**
   * Convert secret to bytes honoring {@link RegisteredServiceProperty.RegisteredServiceProperties#TOKEN_SECRETS_ARE_BASE64_ENCODED}
   * config parameter.
   *
   * @param secret                - String to be represented to byte[]
   * @param secretIsBase64Encoded - is this a base64 encoded #secret?
   * @return byte[] representation of #secret
   */
  private static byte[] getSecretBytes(final String secret, final boolean secretIsBase64Encoded) {
    return secretIsBase64Encoded ? new Base64(secret).decode() : secret.getBytes(UTF_8);
  }
}

代码示例来源:origin: com.nimbusds/nimbus-jose-jwt

/**
   * Base64-encodes the specified string.
   *
   * @param text The string to encode. Must be in the UTF-8 character set
   *             and not {@code null}.
   *
   * @return The resulting Base64 object.
   */
  public static Base64 encode(final String text) {

    return encode(text.getBytes(StandardCharset.UTF_8));
  }
}

代码示例来源:origin: com.microsoft.azure/adal4j

JWSHeader.Builder builder = new Builder(JWSAlgorithm.RS256);
List<Base64> certs = new ArrayList<Base64>();
certs.add(new Base64(credential.getPublicCertificate()));
builder.x509CertChain(certs);
builder.x509CertThumbprint(new Base64URL(credential

相关文章