com.nimbusds.jose.util.Base64.<init>()方法的使用及代码示例

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

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

Base64.<init>介绍

[英]Creates a new Base64-encoded object.
[中]创建新的Base64编码对象。

代码示例

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

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

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

  1. /**
  2. * Base64-encodes the specified byte array.
  3. *
  4. * @param bytes The byte array to encode. Must not be {@code null}.
  5. *
  6. * @return The resulting Base64 object.
  7. */
  8. public static Base64 encode(final byte[] bytes) {
  9. return new Base64(Base64Codec.encodeToString(bytes, false));
  10. }

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

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

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

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

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

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

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

  1. private String[] getNamePassword(HttpServletRequest httpRequest) {
  2. String authValue = httpRequest.getHeader("Authorization");
  3. if (authValue != null && authValue.startsWith("Basic ")) {
  4. String encodedValue = authValue.substring(6);
  5. String decodedValue = new Base64(encodedValue).decodeToString();
  6. final String[] namePassword = decodedValue.contains(":") ? decodedValue.split(":")
  7. : new String[] { decodedValue, "" };
  8. return namePassword;
  9. } else if (httpRequest.getContentType().contains("application/x-www-form-urlencoded")) {
  10. String clientId = httpRequest.getParameter("client_id");
  11. String clientSecret = httpRequest.getParameter("client_secret");
  12. if (clientId == null || clientSecret == null) {
  13. return null;
  14. }
  15. return new String[]{clientId, clientSecret};
  16. } else {
  17. return null;
  18. }
  19. }

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

  1. /**
  2. * Parses a PEM-encoded X.509 certificate.
  3. *
  4. * @param pemEncodedCert The PEM-encoded X.509 certificate, as a
  5. * string. May be {@code null}.
  6. *
  7. * @return The X.509 certificate, {@code null} if parsing failed.
  8. */
  9. public static X509Certificate parse(final String pemEncodedCert) {
  10. if (pemEncodedCert == null || pemEncodedCert.isEmpty()) {
  11. return null;
  12. }
  13. final int markerStart = pemEncodedCert.indexOf(PEM_BEGIN_MARKER);
  14. if (markerStart < 0) {
  15. return null;
  16. }
  17. String buf = pemEncodedCert.substring(markerStart + PEM_BEGIN_MARKER.length());
  18. final int markerEnd = buf.indexOf(PEM_END_MARKER);
  19. if (markerEnd < 0) {
  20. return null;
  21. }
  22. buf = buf.substring(0, markerEnd);
  23. buf = buf.replaceAll("\\s", "");
  24. return parse(new Base64(buf).decode());
  25. }

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

  1. /**
  2. * Converts the specified JSON array of strings to a list of Base64
  3. * encoded objects.
  4. *
  5. * @param jsonArray The JSON array of string, {@code null} if not
  6. * specified.
  7. *
  8. * @return The Base64 list, {@code null} if not specified.
  9. *
  10. * @throws ParseException If parsing failed.
  11. */
  12. public static List<Base64> toBase64List(final JSONArray jsonArray)
  13. throws ParseException {
  14. if (jsonArray == null)
  15. return null;
  16. List<Base64> chain = new LinkedList<>();
  17. for (int i=0; i < jsonArray.size(); i++) {
  18. Object item = jsonArray.get(i);
  19. if (item == null) {
  20. throw new ParseException("The X.509 certificate at position " + i + " must not be null", 0);
  21. }
  22. if (! (item instanceof String)) {
  23. throw new ParseException("The X.509 certificate at position " + i + " must be encoded as a Base64 string", 0);
  24. }
  25. chain.add(new Base64((String)item));
  26. }
  27. return chain;
  28. }

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

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

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

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

代码示例来源:origin: AzureAD/azure-activedirectory-library-for-java

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

相关文章