本文整理汇总了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;
}
}
示例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);
}
示例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;
}
示例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);
}