当前位置: 首页>>代码示例>>Java>>正文


Java Verb类代码示例

本文整理汇总了Java中com.github.scribejava.core.model.Verb的典型用法代码示例。如果您正苦于以下问题:Java Verb类的具体用法?Java Verb怎么用?Java Verb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Verb类属于com.github.scribejava.core.model包,在下文中一共展示了Verb类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureOAuth20Client

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
private void configureOAuth20Client(final Collection<BaseClient> properties) {
    final AtomicInteger index = new AtomicInteger();
    casProperties.getAuthn().getPac4j().getOauth2()
            .stream()
            .filter(oauth -> StringUtils.isNotBlank(oauth.getId()) && StringUtils.isNotBlank(oauth.getSecret()))
            .forEach(oauth -> {
                final GenericOAuth20Client client = new GenericOAuth20Client();
                client.setKey(oauth.getId());
                client.setSecret(oauth.getSecret());
                client.setProfileAttrs(oauth.getProfileAttrs());
                client.setProfileNodePath(oauth.getProfilePath());
                client.setProfileUrl(oauth.getProfileUrl());
                client.setProfileVerb(Verb.valueOf(oauth.getProfileVerb().toUpperCase()));
                client.setTokenUrl(oauth.getTokenUrl());
                client.setAuthUrl(oauth.getAuthUrl());
                client.setCustomParams(oauth.getCustomParams());
                final int count = index.intValue();
                if (count > 0) {
                    client.setName(client.getClass().getSimpleName() + count);
                }
                index.incrementAndGet();
                LOGGER.debug("Created client [{}]", client);
                properties.add(client);
            });
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:26,代码来源:Pac4jAuthenticationEventExecutionPlanConfiguration.java

示例2: main

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
public static void main (String[] args) {
    ResourceBundle secrets = ResourceBundle.getBundle("facebookutil/secret");
    final OAuth20Service service = new ServiceBuilder()
            .apiKey(secrets.getString("clientId"))
            .apiSecret(secrets.getString("clientSecret"))
            .callback("https://duke.edu/")
            .grantType("client_credentials")
            .build(FacebookApi.instance());
    String url = "https://graph.facebook.com/oauth/access_token?";
    url = url + "&client_id" + "=" + secrets.getString("clientId");
    url = url + "&client_secret" + "=" + secrets.getString("clientSecret");
    url = url + "&grant_type" + "=" + "client_credentials";
    final OAuthRequest request =
            new OAuthRequest(Verb.GET, url, service);
    service.signRequest(new OAuth2AccessToken(""), request);
    System.out.println(request.getBodyContents());
    System.out.println(request.getUrl());
    Response response = request.send();
    System.out.println(response.getBody());
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:21,代码来源:TestAppLogin.java

示例3: validate

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
@Override
public CredentialValidationResult validate(Credential credential) {
    if (credential instanceof TokenResponseCredential) {
        TokenResponseCredential tokenCredential = (TokenResponseCredential) credential;

        OAuthRequest request = new OAuthRequest(Verb.GET, "https://www.googleapis.com/oauth2/v3/userinfo");

        OAuth20Service service = tokenCredential.getService();
        OAuth2AccessToken token = tokenCredential.getTokenResponse();
        service.signRequest(token, request);

        try {
            Response oResp = service.execute(request);
            String body = oResp.getBody();

            OAuth2User oAuth2User = jsonProcessor.extractUserInfo(body);

            return new CredentialValidationResult(oAuth2User);

        } catch (InterruptedException | ExecutionException | IOException e) {
            e.printStackTrace(); // FIXME
        }

    }
    return CredentialValidationResult.NOT_VALIDATED_RESULT;
}
 
开发者ID:atbashEE,项目名称:jsr375-extensions,代码行数:27,代码来源:DemoIdentityStore.java

示例4: sendRequestForData

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
/**
 * Make a request to get the data of the authenticated user for the provider.
 *
 * @param accessToken the access token
 * @param dataUrl     url of the data
 * @param verb        method used to request data
 * @return the user data response
 */
protected CompletableFuture<String> sendRequestForData(final T accessToken, final String dataUrl, Verb verb) {
    logger.debug("accessToken: {} / dataUrl: {}", accessToken, dataUrl);
    final long t0 = System.currentTimeMillis();
    final OAuthRequestAsync request = createOAuthRequest(dataUrl, verb);
    signRequest(accessToken, request);
    final CompletableFuture<Response> responseFuture = new CompletableFuture<>();
    request.sendAsync(ScribeCallbackAdapter.toScribeOAuthRequestCallback(responseFuture));
    return responseFuture.thenApply(response -> {
        final int code = response.getCode();
        final String body;
        try {
            body = response.getBody();
        } catch (final IOException ex) {
            throw new HttpCommunicationException("Error getting body: " + ex.getMessage());
        }
        final long t1 = System.currentTimeMillis();
        logger.debug("Request took: " + (t1 - t0) + " ms for: " + dataUrl);
        logger.debug("response code: {} / response body: {}", code, body);
        if (code != 200) {
            throw new HttpCommunicationException(code, body);
        }
        return body;
    });
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:33,代码来源:AsyncOAuthProfileCreator.java

示例5: loadOAuthProviderAccount

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
public OAuthProviderAccount loadOAuthProviderAccount(Token accessToken, OAuthProviderName provider) {
	OAuthService service = this.getService();

	// getting user profile
	OAuthRequest oauthRequest = new OAuthRequest(Verb.GET, config.getProfileUrl(), service);
	service.signRequest(accessToken, oauthRequest); // the access token from step 4

	Response oauthResponse = oauthRequest.send();

	String jsonString = oauthResponse.getBody();
	JSONObject root = new JSONObject(jsonString);

	String accountId = String.valueOf(root.getInt(TWITTER_ACCTID_PROPERTY)); 
	String displayName = root.getString(TWITTER_DISPLAYNAME_PROPERTY);
	String publicId = root.getString(TWITTER_SCREENNAME_PROPERTY); 
	String profilePath = provider.getIdProviderUrl() + "/" + publicId; 
	
	OAuthProviderAccount profile = 
			new OAuthProviderAccount(accessToken, provider, displayName, accountId, publicId , profilePath);

	return profile;
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:23,代码来源:TwitterOAuthProvider.java

示例6: doInBackground

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
protected AccountData doInBackground(Void... voids) {
    AccountData aData = new AccountData();

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getFullAccountInfo(), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    //parse json
    try {
        aData = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        aData.setError(e.toString());
    }

    return aData;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:26,代码来源:ParseAccountData.java

示例7: doInBackground

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
protected StockQuote doInBackground(Void... voids){
    //pause for a second so we don't get rate limited
    SystemClock.sleep(1000);

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getMarketQuote(symbol), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    StockQuote quote = new StockQuote(symbol);
    try {
        quote = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        quote.setError(e.toString());
    }

    return quote;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:27,代码来源:ParseStockQuote.java

示例8: doInBackground

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
protected Double doInBackground(Void... voids){
    double ret = 0.0;

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.GET, tk.getOptionStrikePrices(symbol), service);
    service.signRequest(accessToken, request);
    Response response = request.send();

    try {
        ret = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return ret;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:24,代码来源:ParseOptionStrikePrice.java

示例9: doInBackground

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
protected OptionOrder doInBackground(Void... voids){
    OptionOrder order = new OptionOrder();

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.POST, tk.getMarketOptionLive(), service);
    //request.addHeader("TKI_OVERRIDE", "true");
    request.addPayload(fixml.getLimitFixmlString());
    service.signRequest(accessToken, request);
    Response response = request.send();

    try {
        order = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        order.setError(e.toString());
    }

    return order;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:27,代码来源:ParseOptionOrder.java

示例10: doInBackground

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
protected OptionOrderPreview doInBackground(Void... voids){
    OptionOrderPreview order = new OptionOrderPreview();

    //Build the OAuth service
    final OAuth10aService service = new ServiceBuilder()
            .apiKey(apiKeys.CONSUMER_KEY)
            .apiSecret(apiKeys.CONSUMER_SECRET)
            .build(TradeKingApi.instance());
    Token accessToken = new Token(apiKeys.OAUTH_TOKEN, apiKeys.OAUTH_TOKEN_SECRET);

    // Fetch the JSON data
    OAuthRequest request = new OAuthRequest(Verb.POST, tk.getMarketOptionPreview(), service);
    request.addPayload(fixml.getMarketFixmlString());
    service.signRequest(accessToken, request);
    Response response = request.send();

    try {
        order = parseJSON(response);
    } catch (JSONException e) {
        e.printStackTrace();
        order.setError(e.toString());
    }

    return order;
}
 
开发者ID:mikemey01,项目名称:Markets,代码行数:26,代码来源:ParseOptionOrderPreview.java

示例11: processRequest

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
private void processRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException {
	String code = req.getParameter("code");
	LOGGER.info("OAuth2 code: [{}]", code);
	String provider = StringUtils.substringAfterLast(req.getRequestURI(), "/");
	LOGGER.info("Provider: [{}]", provider);
	OAuth20Service oAuth2Service = this.providerFactory.getOAuth2Service(provider);
	OAuth2AccessToken token = null;
	try {
		token = oAuth2Service.getAccessToken(code);
		LOGGER.info("OAuth2AccessToken: [{}]", token);
		OAuthRequest oReq = new OAuthRequest(Verb.GET, "https://api.linkedin.com/v1/people/~?format=json");
		oAuth2Service.signRequest(token, oReq);
		Response oResp = oAuth2Service.execute(oReq);
		LOGGER.info("Linkedin Profile: [{}]", oResp.getBody());
		resp.getOutputStream().write(oResp.getBody().getBytes(StandardCharsets.UTF_8));
	} catch (InterruptedException | ExecutionException ex) {
	}
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:19,代码来源:OAuth2CallbackServlet.java

示例12: verfiyAccountCredentials

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
/**
 * Verify account credentials against the Twitter API
 */
private void verfiyAccountCredentials() throws TwitterException {
    OAuthRequest verifyRequest = createOAuthRequest(Verb.GET, VERIFY_CREDENTIALS_URL);
    signRequest(verifyRequest);

    try {
        Response response = service.execute(verifyRequest);
        if (response.getMessage().toLowerCase().equals("Too Many Requests")) {
            throw new TwitterException("Too many requests for this account.");
        } else if (!response.getMessage().toLowerCase().equals("ok")) {
            throw new TwitterException("Invalid twitter configuration");
        }
    } catch (IOException | ExecutionException | InterruptedException e) {
        throw new TwitterException("Could not verify account credentials.");
    }
}
 
开发者ID:DorsetProject,项目名称:dorset-framework,代码行数:19,代码来源:TwitterAgent.java

示例13: getRequestForProvider

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
static public OAuthRequest getRequestForProvider(
  final String providerName,
  final Verb httpVerb,
  final OAuth1AccessToken oa1token,
  final URL url,
  final HashMap<String,Object> cfg,
  @Nullable final ReadableMap params
) {
  final OAuth10aService service =
        OAuthManagerProviders.getApiFor10aProvider(providerName, cfg, null, null);

  String token = oa1token.getToken();
  OAuthConfig config = service.getConfig();
  OAuthRequest request = new OAuthRequest(httpVerb, url.toString(), config);

  request = OAuthManagerProviders.addParametersToRequest(request, token, params);
  // Nothing special for Twitter
  return request;
}
 
开发者ID:fullstackreact,项目名称:react-native-oauth,代码行数:20,代码来源:OAuthManagerProviders.java

示例14: isOrganizationMember

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
/**
 * Check to see that login is a member of organization.
 *
 * A 204 response code indicates organization membership.  302 and 404 codes are not treated as exceptional,
 * they indicate various ways in which a login is not a member of the organization.
 *
 * @see <a href="https://developer.github.com/v3/orgs/members/#response-if-requester-is-an-organization-member-and-user-is-a-member">GitHub members API</a>
 */
private boolean isOrganizationMember(OAuth2AccessToken accessToken, String organization, String login) throws IOException, ExecutionException, InterruptedException {
  String requestUrl = settings.apiURL() + format("orgs/%s/members/%s", organization, login);
  OAuth20Service scribe = new ServiceBuilder(settings.clientId())
    .apiSecret(settings.clientSecret())
    .build(scribeApi);
  OAuthRequest request = new OAuthRequest(Verb.GET, requestUrl);
  scribe.signRequest(accessToken, request);

  Response response = scribe.execute(request);
  int code = response.getCode();
  switch (code) {
    case HttpURLConnection.HTTP_MOVED_TEMP:
    case HttpURLConnection.HTTP_NOT_FOUND:
    case HttpURLConnection.HTTP_NO_CONTENT:
      LOGGER.trace("Orgs response received : {}", code);
      return code == HttpURLConnection.HTTP_NO_CONTENT;
    default:
      throw unexpectedResponseCode(requestUrl, response);
  }
}
 
开发者ID:SonarSource,项目名称:sonar-auth-github,代码行数:29,代码来源:GitHubIdentityProvider.java

示例15: getSingleUseToken

import com.github.scribejava.core.model.Verb; //导入依赖的package包/类
public String getSingleUseToken() {
    OAuth10aService service = JamAuthConfig.instance().getOAuth10aService();
    final OAuthRequest request = new OAuthRequest(Verb.POST,
            JamAuthConfig.instance().getServerUrl() + "/v1/single_use_tokens",
            service);
    service.signRequest(JamAuthConfig.instance().getOAuth10aAccessToken(), request);

    final Response response = request.send();
    String body = response.getBody();

    Matcher matcher = SINGLE_USE_TOKEN_PATTERN.matcher(body);
    if (matcher.find()) {
        return matcher.group(0);
    }
    return null;
}
 
开发者ID:SAP,项目名称:SAPJamSampleCode,代码行数:17,代码来源:JamAuthConfig.java


注:本文中的com.github.scribejava.core.model.Verb类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。