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

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

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

origin: com.atlassian.jwt/jwt-core

/**
 * Canonicalize the given {@link CanonicalHttpRequest} and hash it.
 * This request hash can be included as a JWT claim to verify that request components are genuine.
 * @param request {@link CanonicalHttpRequest} to be canonicalized and hashed
 * @return {@link String} hash suitable for use as a JWT claim value
 * @throws UnsupportedEncodingException if the {@link java.net.URLEncoder} cannot encode the request's field's characters
 * @throws NoSuchAlgorithmException if the hashing algorithm does not exist at runtime
 */
public static String computeCanonicalRequestHash(CanonicalHttpRequest request) throws UnsupportedEncodingException, NoSuchAlgorithmException
{
  // prevent the code in this method being repeated in every call site that needs a request hash,
  // encapsulate the knowledge of the type of hash that we are using
  return JwtUtil.computeSha256Hash(canonicalize(request));
}
origin: com.atlassian.plugins/atlassian-connect-server-core

public String encodeJwt(HttpMethod httpMethod, URI targetPath, URI addonBaseUrl, Map<String, String[]> params, String issuerId, String secret, Optional<UserProfile> user) {
  checkArgument(null != httpMethod, "HttpMethod argument cannot be null");
  checkArgument(null != targetPath, "URI argument cannot be null");
  checkArgument(null != addonBaseUrl, "base URI argument cannot be null");
  checkArgument(null != secret, "secret argument cannot be null");
  final long currentTime = TimeUtil.currentTimeSeconds();
  JwtJsonBuilder jsonBuilder = jwtBuilderFactory.jsonBuilder()
      .issuedAt(currentTime)
      .expirationTime(currentTime + JWT_EXPIRY_WINDOW_SECONDS)
      .issuer(issuerId);
  Map<String, String[]> completeParams = params;
  try {
    if (!StringUtils.isEmpty(targetPath.getQuery())) {
      completeParams = new HashMap<>(params);
      completeParams.putAll(constructParameterMap(targetPath));
    }
    CanonicalHttpUriRequest request = new CanonicalHttpUriRequest(httpMethod.toString(), extractRelativePath(targetPath, addonBaseUrl), "", completeParams);
    log.debug("Canonical request is: " + HttpRequestCanonicalizer.canonicalize(request));
    JwtClaimsBuilder.appendHttpRequestClaims(jsonBuilder, request);
  } catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
  JwtUserContextBuilder.addUserContextObject(jsonBuilder, user);
  return jwtService.issueJwt(jsonBuilder.build(), secret);
}
origin: com.atlassian.plugins/atlassian-connect-core

public String encodeJwt(HttpMethod httpMethod, URI targetPath, URI addonBaseUrl, Map<String, String[]> params, String issuerId, String secret, Optional<UserProfile> user) {
  checkArgument(null != httpMethod, "HttpMethod argument cannot be null");
  checkArgument(null != targetPath, "URI argument cannot be null");
  checkArgument(null != addonBaseUrl, "base URI argument cannot be null");
  checkArgument(null != secret, "secret argument cannot be null");
  final long currentTime = TimeUtil.currentTimeSeconds();
  JwtJsonBuilder jsonBuilder = jwtBuilderFactory.jsonBuilder()
      .issuedAt(currentTime)
      .expirationTime(currentTime + JWT_EXPIRY_WINDOW_SECONDS)
      .issuer(issuerId);
  Map<String, String[]> completeParams = params;
  try {
    if (!StringUtils.isEmpty(targetPath.getQuery())) {
      completeParams = new HashMap<>(params);
      completeParams.putAll(constructParameterMap(targetPath));
    }
    CanonicalHttpUriRequest request = new CanonicalHttpUriRequest(httpMethod.toString(), extractRelativePath(targetPath, addonBaseUrl), "", completeParams);
    log.debug("Canonical request is: " + HttpRequestCanonicalizer.canonicalize(request));
    JwtClaimsBuilder.appendHttpRequestClaims(jsonBuilder, request);
  } catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
  JwtUserContextBuilder.addUserContextObject(jsonBuilder, user);
  return jwtService.issueJwt(jsonBuilder.build(), secret);
}
com.atlassian.jwt.coreHttpRequestCanonicalizercanonicalize

Javadoc

Assemble the components of the HTTP request into the correct format so that they can be signed or hashed.

Popular methods of HttpRequestCanonicalizer

  • computeCanonicalRequestHash
    Canonicalize the given CanonicalHttpRequest and hash it. This request hash can be included as a JWT
  • 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

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (Timer)
  • getApplicationContext (Context)
  • setContentView (Activity)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • From CI to AI: The AI layer in your organization
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