Tabnine Logo
HttpRequestCanonicalizer.computeCanonicalRequestHash
Code IndexAdd Tabnine to your IDE (free)

How to use
computeCanonicalRequestHash
method
in
com.atlassian.jwt.core.HttpRequestCanonicalizer

Best Java code snippets using com.atlassian.jwt.core.HttpRequestCanonicalizer.computeCanonicalRequestHash (Showing top 4 results out of 315)

origin: com.atlassian.jwt/jwt-core

  /**
   * Convenience method for building and appending JWT claims related to a {@link com.atlassian.jwt.CanonicalHttpRequest}.
   * Encapsulates the knowledge of what claims we make regarding the request.
   * @param jsonBuilder {@link com.atlassian.jwt.writer.JwtJsonBuilder} that constructs the JWT payload
   * @param request {@link com.atlassian.jwt.CanonicalHttpRequest} representing the incoming or outgoing HTTP request
   * @throws UnsupportedEncodingException if {@link java.net.URLEncoder} cannot encode the request's characters
   * @throws NoSuchAlgorithmException if the hashing algorithm does not exist at runtime
   */
  public static void appendHttpRequestClaims(JwtJsonBuilder jsonBuilder, CanonicalHttpRequest request) throws UnsupportedEncodingException, NoSuchAlgorithmException
  {
    jsonBuilder.queryHash(HttpRequestCanonicalizer.computeCanonicalRequestHash(request));
  }
}
origin: com.atlassian.jwt/jwt-core

  /**
   * Encapsulate the building of requirements that we place upon JWTs in incoming requests.
   * @param request incoming request
   * @return {@link Map} of claim name to verifier for claims upon which we place requirements
   * @throws UnsupportedEncodingException if {@link java.net.URLEncoder} cannot encode the request's characters
   * @throws NoSuchAlgorithmException if the hashing algorithm does not exist at runtime
   */
  public static Map<String, ? extends JwtClaimVerifier> build(CanonicalHttpRequest request) throws UnsupportedEncodingException, NoSuchAlgorithmException
  {
    return Collections.singletonMap(JwtConstants.Claims.QUERY_HASH,
        new JwtClaimEqualityVerifier(JwtConstants.Claims.QUERY_HASH, HttpRequestCanonicalizer.computeCanonicalRequestHash(request)));
  }
}
origin: com.atlassian.plugins/atlassian-connect-integration-tests-support

  public static String generateJwtSignature(HttpMethod httpMethod, URI uri, String addonKey, String secret, String contextPath, String subject) throws UnsupportedEncodingException, NoSuchAlgorithmException {
    JwtWriterFactory jwtWriterFactory = new NimbusJwtWriterFactory();
    JwtWriter jwtWriter = jwtWriterFactory.macSigningWriter(SigningAlgorithm.HS256, secret);

    // Parse param values and build a map
    final List<NameValuePair> rawParams = URLEncodedUtils.parse(uri, "UTF-8");
    final ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder();
    for (NameValuePair rawParam : rawParams) {
      builder.put(rawParam.getName(), rawParam.getValue());
    }

    final ImmutableMap.Builder<String, String[]> paramsMap = ImmutableMap.builder();
    for (Map.Entry<String, Collection<String>> stringCollectionEntry : builder.build().asMap().entrySet()) {
      final Collection<String> collection = stringCollectionEntry.getValue();
      paramsMap.put(stringCollectionEntry.getKey(), collection.toArray(new String[collection.size()]));
    }

    final JwtJsonBuilder jsonBuilder = new JsonSmartJwtJsonBuilder()
        .issuer(addonKey)
        .queryHash(HttpRequestCanonicalizer.computeCanonicalRequestHash(new CanonicalHttpUriRequest(httpMethod.name(), uri.getPath(), URI.create(contextPath).getPath(), paramsMap.build())));

    if (null != subject) {
      jsonBuilder.subject(subject);
    }

    return jwtWriter.jsonToJwt(jsonBuilder.build());
  }
}
origin: com.atlassian.plugins/atlassian-connect-server-integration-tests-support

  public static String generateJwtSignature(HttpMethod httpMethod, URI uri, String addonKey, String secret, String contextPath, String subject) throws UnsupportedEncodingException, NoSuchAlgorithmException {
    JwtWriterFactory jwtWriterFactory = new NimbusJwtWriterFactory();
    JwtWriter jwtWriter = jwtWriterFactory.macSigningWriter(SigningAlgorithm.HS256, secret);

    // Parse param values and build a map
    final List<NameValuePair> rawParams = URLEncodedUtils.parse(uri, "UTF-8");
    final ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder();
    for (NameValuePair rawParam : rawParams) {
      builder.put(rawParam.getName(), rawParam.getValue());
    }

    final ImmutableMap.Builder<String, String[]> paramsMap = ImmutableMap.builder();
    for (Map.Entry<String, Collection<String>> stringCollectionEntry : builder.build().asMap().entrySet()) {
      final Collection<String> collection = stringCollectionEntry.getValue();
      paramsMap.put(stringCollectionEntry.getKey(), collection.toArray(new String[collection.size()]));
    }

    final JwtJsonBuilder jsonBuilder = new JsonSmartJwtJsonBuilder()
        .issuer(addonKey)
        .queryHash(HttpRequestCanonicalizer.computeCanonicalRequestHash(new CanonicalHttpUriRequest(httpMethod.name(), uri.getPath(), URI.create(contextPath).getPath(), paramsMap.build())));

    if (null != subject) {
      jsonBuilder.subject(subject);
    }

    return jwtWriter.jsonToJwt(jsonBuilder.build());
  }
}
com.atlassian.jwt.coreHttpRequestCanonicalizercomputeCanonicalRequestHash

Javadoc

Canonicalize the given CanonicalHttpRequest and hash it. This request hash can be included as a JWT claim to verify that request components are genuine.

Popular methods of HttpRequestCanonicalizer

  • canonicalize
    Assemble the components of the HTTP request into the correct format so that they can be signed or ha
  • canonicalizeMethod
  • canonicalizeQueryParameters
  • canonicalizeUri
  • getParameters
    Retrieve the original parameters from a sorted collection.
  • percentEncode
    Write a form-urlencoded document into the given stream, containing the given sequence of name/parame
  • safeToString

Popular in Java

  • Reading from database using SQL prepared statement
  • setContentView (Activity)
  • addToBackStack (FragmentTransaction)
  • setScale (BigDecimal)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now