Tabnine Logo
Request
Code IndexAdd Tabnine to your IDE (free)

How to use
Request
in
com.atlassian.oauth

Best Java code snippets using com.atlassian.oauth.Request (Showing top 13 results out of 315)

origin: com.atlassian.applinks/applinks-oauth-plugin

/**
 * Converts the {@code Request} to an {@code OAuthMessage}.
 *
 * @param request {@code Request} to be converted to an {@code OAuthMessage}
 * @return {@code OAuthMessage} converted from the {@code Request}
 */
public static OAuthMessage asOAuthMessage(final com.atlassian.oauth.Request request) {
  checkNotNull(request, "request");
  return new OAuthMessage(
      request.getMethod().name(),
      request.getUri().toString(),
      // We'd rather not do the copy, but since we need a Collection of these things we don't have much choice
      ImmutableList.copyOf(asOAuthParameters(request.getParameters()))
  );
}
origin: com.atlassian.oauth/atlassian-oauth-api

public Request(HttpMethod method, URI uri, Iterable<Parameter> parameters) {
  this.method = checkNotNull(method, "method");
  this.uri = checkNotNull(uri, "uri");
  this.parameters = copy(parameters);
}
origin: com.atlassian.oauth/atlassian-oauth-api

/**
 * Returns the value of the parameter.  If there are multiple parameters for the value, only the first is returned.
 *
 * @return the value of the parameter
 */
public String getParameter(String parameterName) {
  Iterable<String> values = getParameterMap().get(parameterName);
  if (values == null) {
    return null;
  }
  Iterator<String> it = values.iterator();
  if (!it.hasNext()) {
    return null;
  }
  return it.next();
}
origin: com.atlassian.oauth/atlassian-oauth-api

private Map<String, Iterable<String>> getParameterMap() {
  if (parameterMap == null) {
    parameterMap = makeUnmodifiableMap(makeParameterMap());
  }
  return parameterMap;
}
origin: com.atlassian.oauth/atlassian-oauth-consumer-core

private Request sign(Request request, OAuthAccessor accessor) {
  try {
    final URI requestUri = request.getUri();
    Preconditions.checkArgument(requestUri.normalize().getPath().equals(requestUri.getPath()),
        "Refusing to sign non-normalized URL: " + requestUri);
    OAuthMessage oauthMessage = accessor.newRequestMessage(
        request.getMethod().name(),
        requestUri.toString(),
        asOAuthParameters(request.getParameters())
    );
    log.debug("Signed request {}", oauthMessage);
    return new Request(request.getMethod(), requestUri, fromOAuthParameters(oauthMessage.getParameters()));
  } catch (net.oauth.OAuthException e) {
    throw new OAuthSigningException("Failed to sign the request", e);
  } catch (IOException e) {
    // this shouldn't happen as the message is not being read from any IO streams, but the OAuth library throws
    // these around like they're candy, but far less sweet and tasty.
    throw new RuntimeException(e);
  } catch (URISyntaxException e) {
    // this shouldn't happen unless the caller somehow passed us an invalid URI object
    throw new RuntimeException(e);
  }
}
origin: com.atlassian.applinks/applinks-oauth-plugin

  @Override
  protected Request createUnsignedRequest() {
    // 2LO means oauth_token must be empty string
    return new com.atlassian.oauth.Request(toOAuthMethodType(methodType), URI.create(url), toOAuthParameters(""));
  }
}
origin: com.atlassian.applinks/applinks-oauth-plugin

public ConsumerToken getRequestToken(ServiceProvider serviceProvider, final String consumerKey, String callback) throws ResponseException {
  final Request oAuthRequest = new Request(Request.HttpMethod.POST, serviceProvider.getRequestTokenUri(),
      Collections.singleton(new Request.Parameter(OAuth.OAUTH_CALLBACK, callback)));
  final Request signedRequest = consumerService.sign(oAuthRequest, consumerKey, serviceProvider);
  final com.atlassian.sal.api.net.Request tokenRequest = requestFactory.createRequest(
      com.atlassian.sal.api.net.Request.MethodType.POST, serviceProvider.getRequestTokenUri().toString());
  tokenRequest.addRequestParameters(parameterToStringArray(signedRequest.getParameters()));
  final TokenAndSecret tokenAndSecret = requestToken(serviceProvider.getRequestTokenUri().toString(), signedRequest);
  final ConsumerToken requestToken = ConsumerToken.newRequestToken(tokenAndSecret.token)
      .tokenSecret(tokenAndSecret.secret)
      .consumer(getConsumer(consumerKey))
      .build();
  assert (requestToken.isRequestToken());
  return requestToken;
}
origin: com.atlassian.applinks/applinks-oauth-plugin

private TokenAndSecret requestToken(String url, Request signedRequest)
    throws ResponseException {
  final com.atlassian.sal.api.net.Request tokenRequest = requestFactory.createRequest(com.atlassian.sal.api.net.Request.MethodType.POST, url);
  tokenRequest.addRequestParameters(parameterToStringArray(signedRequest.getParameters()));
origin: com.atlassian.oauth/atlassian-oauth-signature-generator-plugin

private Request asOAuthRequest(final HttpServletRequest request) {
  Iterable<Parameter> parameters = filter(transform(Arrays.asList(request.getParameterValues("p")), new Function<String, Parameter>() {
    public Parameter apply(String parameterNumber) {
      if (isBlank(request.getParameter("p" + parameterNumber))) {
        return null;
      }
      return new Parameter(request.getParameter("p" + parameterNumber), request.getParameter("v" + parameterNumber));
    }
  }), notNull());
  if (!isBlank(request.getParameter("timestamp"))) {
    parameters = concat(parameters, ImmutableList.of(new Parameter("oauth_timestamp", request.getParameter("timestamp"))));
  }
  if (!isBlank(request.getParameter("nonce"))) {
    parameters = concat(parameters, ImmutableList.of(new Parameter("oauth_nonce", request.getParameter("nonce"))));
  }
  return new Request(HttpMethod.valueOf(request.getParameter("method")), URI.create(request.getParameter("uri")), parameters);
}
origin: com.atlassian.oauth/atlassian-oauth-bridge

/**
 * Converts the {@code Request} to an {@code OAuthMessage}.
 *
 * @param request {@code Request} to be converted to an {@code OAuthMessage}
 * @return {@code OAuthMessage} converted from the {@code Request}
 */
public static OAuthMessage asOAuthMessage(Request request) {
  checkNotNull(request, "request");
  return new OAuthMessage(
      request.getMethod().name(),
      request.getUri().toString(),
      // We'd rather not do the copy, but since we need a Collection of these things we don't have much choice
      ImmutableList.copyOf(asOAuthParameters(request.getParameters()))
  );
}
origin: com.atlassian.oauth/atlassian-oauth-bridge

/**
 * Converts the {@code OAuthMessage} to an {@code Request}.
 *
 * @param message {@code OAuthMessage} to be converted to an {@code Request}
 * @return {@code Request} converted from {@code OAuthMessage}
 */
public static Request fromOAuthMessage(OAuthMessage message) {
  checkNotNull(message, "message");
  try {
    return new Request(
        HttpMethod.valueOf(message.method.toUpperCase()),
        URI.create(message.URL),
        fromOAuthParameters(message.getParameters())
    );
  } catch (IOException e) {
    throw new RuntimeException("Failed to convert from OAuthMessage", e);
  }
}
origin: com.atlassian.applinks/applinks-oauth-plugin

@Override
protected Request createUnsignedRequest() {
  // a 3LO request needs a valid OAuth token.
  return new com.atlassian.oauth.Request(toOAuthMethodType(methodType), URI.create(url),
      toOAuthParameters(consumerToken.getToken()));
}
origin: com.atlassian.applinks/applinks-oauth-plugin

public ConsumerToken getAccessToken(ServiceProvider serviceProvider, ConsumerToken requestTokenPair, String requestVerifier, final String consumerKey)
    throws ResponseException {
  final List<Request.Parameter> parameters = new ArrayList<Request.Parameter>();
  parameters.add(new Request.Parameter(OAuth.OAUTH_TOKEN, requestTokenPair.getToken()));
  if (StringUtils.isNotBlank(requestVerifier)) // Added in OAuth 1.0a
  {
    parameters.add(new Request.Parameter(OAuth.OAUTH_VERIFIER, requestVerifier));
  }
  final Request oAuthRequest = new Request(Request.HttpMethod.POST, serviceProvider.getAccessTokenUri(), parameters);
  final Request signedRequest = consumerService.sign(oAuthRequest, serviceProvider, requestTokenPair);
  final TokenAndSecret tokenAndSecret = requestToken(serviceProvider.getAccessTokenUri().toString(), signedRequest);
  ConsumerToken accessToken = ConsumerToken.newAccessToken(tokenAndSecret.token).tokenSecret(tokenAndSecret.secret).consumer(getConsumer(consumerKey)).build();
  assert (accessToken.isAccessToken());
  return accessToken;
}
com.atlassian.oauthRequest

Javadoc

Represents an HTTP request. An HTTP request consists of the HTTP method - GET or POST in this case, the URI, and any parameters to be sent.

Most used methods

  • <init>
  • getMethod
    Returns the HTTP method to use when making the request - either GET or POST.
  • getParameters
    Returns the parameters to be sent as part of the request.
  • getUri
    Returns the URI to make the request to.
  • copy
  • getParameterMap
  • makeParameterMap
  • makeUnmodifiableMap

Popular in Java

  • Finding current android device location
  • getSupportFragmentManager (FragmentActivity)
  • startActivity (Activity)
  • onRequestPermissionsResult (Fragment)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • 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