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


Java OAuthClientRequest.authorizationLocation方法代码示例

本文整理汇总了Java中org.apache.oltu.oauth2.client.request.OAuthClientRequest.authorizationLocation方法的典型用法代码示例。如果您正苦于以下问题:Java OAuthClientRequest.authorizationLocation方法的具体用法?Java OAuthClientRequest.authorizationLocation怎么用?Java OAuthClientRequest.authorizationLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.oltu.oauth2.client.request.OAuthClientRequest的用法示例。


在下文中一共展示了OAuthClientRequest.authorizationLocation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: downloadUrl

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
private String downloadUrl() throws IOException { // we can probably return null
    InputStream is = null;
    String contentAsString = "";

    try {
        OAuthClientRequest.AuthenticationRequestBuilder requestBuilder = OAuthClientRequest.authorizationLocation(MainActivity.AUTHORIZATION_URL);
        requestBuilder.setClientId(GPXKeeperOAuthData.CLIENT_ID);
        requestBuilder.setResponseType("code");
        requestBuilder.setRedirectURI(GPX_KEEPER_URI);
        OAuthClientRequest request = requestBuilder.buildQueryMessage();
        Intent authenticate = new Intent(Intent.ACTION_VIEW, Uri.parse(request.getLocationUri()));
        startActivityForResult(authenticate, 0);
    } catch (OAuthSystemException e) {
        e.printStackTrace();
    } finally {
        if (is != null) {
            is.close();
        }
        return contentAsString;

    }
}
 
开发者ID:flooose,项目名称:gpxkept,代码行数:23,代码来源:MainActivity.java

示例2: OAuth2Client

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
/**
 * Default constructor. Accepts Sonar {@link Settings} in order to bootstrap
 * the class.
 * @param settings The {@link Settings} from the currently running Sonar instance.
 * @throws OAuthSystemException If there is insufficient or conflicting configurations.
 */
public OAuth2Client(Settings settings) throws OAuthSystemException {
  this.settings = settings;
  final String provider = settings.getString(PROPERTY_PROVIDER);
  if (provider!=null) {
    providerType = OAuthProviderType.valueOf(provider.toUpperCase());
  }
  if (providerType==null) {
    authLocation = settings.getString(PROPERTY_AUTH_LOCATION);
    tokenLocation = settings.getString(PROPERTY_TOKEN_LOCATION);
    if (authLocation==null) {
      throw new OAuthSystemException("You must specify either an OAuth2 "
            + "provider or an authentication location.");
    }
  } else {
    authLocation = providerType.getAuthzEndpoint();
    tokenLocation = providerType.getTokenEndpoint();
  }
  redirReqBuilder = OAuthClientRequest.authorizationLocation(authLocation);
  final String baseUrl = settings.getString(PROPERTY_SONAR_URL);
  final String clientId = settings.getString(PROPERTY_CLIENT_ID);
  clientSecret = settings.getString(PROPERTY_SECRET);
  if (baseUrl==null || clientId==null || clientSecret==null) {
    throw new OAuthSystemException("'"+PROPERTY_SONAR_URL+"', '"+PROPERTY_CLIENT_ID+"', AND '"+PROPERTY_SECRET
          +"' MUST be set to configure OAuthClientRequest.");
  }
  final String callback = baseUrl+(baseUrl.endsWith("/")?"":"/")+"oauth2/callback";
  redirReqBuilder
            .setClientId(clientId)
            .setScope(OAUTH2_SCOPE_EMAIL);
  redirReqBuilder.setRedirectURI(callback);
}
 
开发者ID:InfoSec812,项目名称:sonar-oauth2,代码行数:38,代码来源:OAuth2Client.java

示例3: getUrl

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
public String getUrl(HttpServletRequest req)
{
  try
  {
    URL url = new URL(req.getScheme(), req.getServerName(), req.getServerPort(), req.getContextPath());

    String redirect = url.toString() + "/session/ologin";

    JSONObject state = new JSONObject();
    state.put(OauthServerIF.SERVER_ID, this.getId());

    AuthenticationRequestBuilder builder = OAuthClientRequest.authorizationLocation(this.getAuthorizationLocation());
    builder.setClientId(this.getClientId());
    builder.setRedirectURI(redirect);
    builder.setResponseType("code");
    builder.setState(state.toString());

    OAuthClientRequest request = builder.buildQueryMessage();

    return request.getLocationUri();
  }
  catch (OAuthSystemException | JSONException | MalformedURLException e )
  {
    e.printStackTrace();
  }

  return null;
}
 
开发者ID:terraframe,项目名称:geoprism,代码行数:29,代码来源:OauthServerDTO.java

示例4: OAuth

import org.apache.oltu.oauth2.client.request.OAuthClientRequest; //导入方法依赖的package包/类
public OAuth(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) {
    this(OAuthClientRequest.tokenLocation(tokenUrl).setScope(scopes));
    setFlow(flow);
    authenticationRequestBuilder = OAuthClientRequest.authorizationLocation(authorizationUrl);
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:6,代码来源:OAuth.java


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