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


Java Verifier类代码示例

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


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

示例1: authorize

import org.scribe.model.Verifier; //导入依赖的package包/类
public static Auth authorize(Flickr flickr, File authDirectory, String username) throws IOException, SAXException, FlickrException {
	AuthStore authStore = new FileAuthStore(authDirectory);
	Auth auth = authStore.retrieve(flickr.getPeopleInterface().findByUsername(username).getId());
	if (auth != null) {
		RequestContext.getRequestContext().setAuth(auth);
		return auth;
	}

	AuthInterface authInterface = flickr.getAuthInterface();
	Token accessToken = authInterface.getRequestToken();

	String url = authInterface.getAuthorizationUrl(accessToken, Permission.READ);
	System.out.println("Please visit the following URL to get your authorization token:");
	System.out.println();
	System.out.println(url);
	System.out.println();
	System.out.print("Enter your token: ");
	String tokenKey = new Scanner(System.in).nextLine();

	Token requestToken = authInterface.getAccessToken(accessToken, new Verifier(tokenKey));

	auth = authInterface.checkToken(requestToken);
	RequestContext.getRequestContext().setAuth(auth);
	authStore.store(auth);
	return auth;
}
 
开发者ID:masneyb,项目名称:flickrdownload,代码行数:27,代码来源:Authentication.java

示例2: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
public Token getAccessToken(Token requestToken, Verifier verifier) {
    OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
    switch (api.getAccessTokenVerb()) {
    case POST:
        request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
        request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
        request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
        request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
        request.addBodyParameter(GRANT_TYPE, GRANT_TYPE_AUTHORIZATION_CODE);
        break;
    case GET:
    default:
        request.addQuerystringParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
        request.addQuerystringParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
        request.addQuerystringParameter(OAuthConstants.CODE, verifier.getValue());
        request.addQuerystringParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
        if(config.hasScope()) request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope());
    }
    Response response = request.send();
    return api.getAccessTokenExtractor().extract(response.getBody());
}
 
开发者ID:elimu-ai,项目名称:webapp,代码行数:23,代码来源:Google2Api.java

示例3: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
protected String getAccessToken()
{
    Verifier verifier = new Verifier(request.getParameter("oauth_verifier"));
    Token requestToken = (Token) request.getSession().getAttribute("requestToken");
    request.getSession().removeAttribute("requestToken");

    OAuthService service = createOAuthScribeService();
    Token accessTokenObj = null;
    try
    {
        accessTokenObj = service.getAccessToken(requestToken, verifier);
    } catch (OAuthConnectionException e)
    {
        Organization organizationInstance = organizationService.get(Integer.parseInt(organization), false);
        throw new SourceControlException("Error obtaining access token. Cannot access " + organizationInstance.getHostUrl() + " from Jira.", e);
    } finally
    {
        httpClientProvider.closeIdleConnections();
    }

    return BitbucketOAuthAuthentication.generateAccessTokenString(accessTokenObj);
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:24,代码来源:RegenerateBitbucketOauthToken.java

示例4: doFinish

import org.scribe.model.Verifier; //导入依赖的package包/类
public String doFinish()
{
    // now get the access token
    Verifier verifier = new Verifier(request.getParameter("oauth_verifier"));
    Token requestToken = (Token) request.getSession().getAttribute(SESSION_KEY_REQUEST_TOKEN);

    if (requestToken == null)
    {
        log.debug("Request token is NULL. It has been removed in the previous attempt of adding organization. Now we will stop.");
        return getRedirect("ConfigureDvcsOrganizations.jspa?atl_token=" + CustomStringUtils.encode(getXsrfToken()));
    }

    request.getSession().removeAttribute(SESSION_KEY_REQUEST_TOKEN);

    OAuthService service = createOAuthScribeService();
    Token accessTokenObj = service.getAccessToken(requestToken, verifier);
    accessToken = BitbucketOAuthAuthentication.generateAccessTokenString(accessTokenObj);

    httpClientProvider.closeIdleConnections();

    return doAddOrganization();
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:23,代码来源:AddBitbucketOrganization.java

示例5: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
public Token getAccessToken(Token token, Verifier verifier) {
  OAuthRequest request =
      new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
  request.addHeader("Authorization", prepareAuthorizationHeaderValue());
  request.addBodyParameter(GRANT_TYPE, GRANT_TYPE_VALUE);
  request.addBodyParameter(CODE, verifier.getValue());
  Response response = request.send();
  if (response.getCode() == SC_OK) {
    Token t = api.getAccessTokenExtractor().extract(response.getBody());
    return new Token(t.getToken(), config.getApiSecret());
  }

  throw new OAuthException(
      String.format(
          "Error response received: %s, HTTP status: %s",
          response.getBody(), response.getCode()));
}
 
开发者ID:davido,项目名称:gerrit-oauth-provider,代码行数:19,代码来源:BitbucketApi.java

示例6: signupViaFacebook

import org.scribe.model.Verifier; //导入依赖的package包/类
@Get("/sign-up/facebook/")
public void signupViaFacebook(String code, String state) {
	if (code == null) {
		includeAsList("mamuteMessages", i18n("error", "error.signup.facebook.unknown"));
		redirectTo(SignupController.class).signupForm();
		return;
	}
	
	Token token = service.getAccessToken(null, new Verifier(code));
	
	SocialAPI facebookAPI = new FacebookAPI(service, token);
	
	boolean success = loginManager.merge(MethodType.FACEBOOK, facebookAPI);
	if(!success) {
		includeAsList("mamuteMessages", i18n("error", "signup.errors.facebook.invalid_email", state));
		result.redirectTo(AuthController.class).loginForm(state);
		return;
	}
	redirectToRightUrl(state);
}
 
开发者ID:caelum,项目名称:mamute,代码行数:21,代码来源:FacebookAuthController.java

示例7: getSwiftAccess

import org.scribe.model.Verifier; //导入依赖的package包/类
public static SwiftAccess getSwiftAccess ()
{
   	final HasAuthenticationSettings authSettings = Configuration.INSTANCE.getAuthenticationSettings() ;
	String apiKey = authSettings.getClientId() ;
	String apiSecret = authSettings.getClientSecret() ;

	HubicOAuth20ServiceImpl service = (HubicOAuth20ServiceImpl) new ServiceBuilder()
			.provider(HubicApi.class).apiKey(apiKey).apiSecret(apiSecret)
			//.scope("account.r,links.rw,usage.r,credentials.r").callback(HubicApi.CALLBACK_URL)
			.scope(scope).callback(HubicApi.CALLBACK_URL)
			.build();
	
	Verifier verif = service.obtainVerifier();
	
	if (verif == null)
		return null ;
	
	Token accessToken = service.getAccessToken(null, verif);
	return getSwiftAccess (service, accessToken) ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:21,代码来源:HubicSwift.java

示例8: doAuth

import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
protected void doAuth( Intent intent )
{
    final String code = intent.getStringExtra( SitesLoginHandler.VERIFIER_KEY );
    Token accessToken = null;
    String userName = null;
    try
    {
        OAuthService service = new ServiceBuilder()
                .provider( InstagramApi.class )
                .callback( InstagramLoginActivity.CALLBACK_URL )
                .apiKey( InstagramConfig.INSTAGRAM_CLIENT_ID )
                .apiSecret( InstagramConfig.INSTAGRAM_CLIENT_SECRET )
                .scope( InstagramConfig.INSTAGRAM_SCOPE )
                .build();
        accessToken = service.getAccessToken( null, new Verifier( code ) );
        userName = Helper.extractInstagramUserName( accessToken.getRawResponse() );
    }
    catch ( Exception e )
    {
        Helper.debug( "Error while obtaining Instagram access token : " + e.getMessage() );
    }
    boolean success = null != accessToken;
    // Subscriber : InstagramLoginHandler : onInstagramAuthDone()
    HashtaggerApp.bus.post( new InstagramAuthDoneEvent( success, accessToken, userName ) );
}
 
开发者ID:iTwenty,项目名称:Hashtagger,代码行数:27,代码来源:InstagramService.java

示例9: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
/**
 * Step 4: Get the access Token.
 * 
 * @param verifier Provided by the service and entered by the user
 */
public Token getAccessToken(final String verifier) {
	lock.writeLock().lock();
	try {
		if (state != OAuthState.GET_ACCESS_TOKEN) {
			throw new IllegalStateException("Request token not found!");
		}

		accessToken = service.getAccessToken(requestToken, new Verifier(verifier));
		state = OAuthState.READY;

		return accessToken;

	} finally {
		lock.writeLock().unlock();
	}
}
 
开发者ID:rockihack,项目名称:Stud.IP-FileSync,代码行数:22,代码来源:OAuth.java

示例10: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
@Override
public Token getAccessToken(Token requestToken, Verifier verifier) {
    OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
    switch (api.getAccessTokenVerb()) {
        case POST:
            request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
            request.addBodyParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
            request.addBodyParameter(OAuthConstants.CODE, verifier.getValue());
            request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
            request.addBodyParameter(GRANT_TYPE, GRANT_TYPE_AUTHORIZATION_CODE);
            break;
        case GET:
        default:
            request.addQuerystringParameter(OAuthConstants.CLIENT_ID, config.getApiKey());
            request.addQuerystringParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret());
            request.addQuerystringParameter(OAuthConstants.CODE, verifier.getValue());
            request.addQuerystringParameter(OAuthConstants.REDIRECT_URI, config.getCallback());
            if(config.hasScope()) request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope());
    }
    Response response = request.send();
    return api.getAccessTokenExtractor().extract(response.getBody());
}
 
开发者ID:kurukurupapa,项目名称:TryAndroid,代码行数:23,代码来源:Google2Api.java

示例11: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
/**
 * アクセストークン(access Token)を取得
 */
private boolean getAccessToken() {
    Log.v(TAG, "getAccessToken called");
    if (mAccessToken != null) {
        return true;
    }

    AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
        @Override
        protected Boolean doInBackground(Void... voids) {
            // HTTP通信を行うため、非UIスレッドで実行します。
            Verifier verifier = new Verifier(mOAuthPin);
            mAccessToken = mService.getAccessToken(mRequestToken, verifier); // the requestToken you had from step 2
            return true;
        }
        @Override
        protected void onPostExecute(Boolean aBoolean) {
            start();
        }
    };
    task.execute();
    return false;
}
 
开发者ID:kurukurupapa,项目名称:TryAndroid,代码行数:26,代码来源:BrowserPinTwitter10aOAuthHelper.java

示例12: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
/**
 * アクセストークン(access Token)を取得
 */
private boolean getAccessToken() {
    Log.v(TAG, "getAccessToken called");
    if (mAccessToken != null) {
        return true;
    }

    AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
        @Override
        protected Boolean doInBackground(Void... voids) {
            // HTTP通信を行うため、非UIスレッドで実行します。
            Verifier verifier = new Verifier(mOAuthPin);
            mAccessToken = mService.getAccessToken(null, verifier);
            Log.v(TAG, "mAccessToken=" + mAccessToken);
            return true;
        }
        @Override
        protected void onPostExecute(Boolean aBoolean) {
            start();
        }
    };
    task.execute();
    return false;
}
 
开发者ID:kurukurupapa,项目名称:TryAndroid,代码行数:27,代码来源:BrowserPinGoogle20OAuthHelper.java

示例13: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
/**
 * アクセストークン(access Token)を取得
 */
private boolean getAccessToken() {
    Log.v(TAG, "getAccessToken called");
    if (mAccessToken != null) {
        return true;
    }

    AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
        @Override
        protected Boolean doInBackground(Void... voids) {
            // HTTP通信を行うため、非UIスレッドで実行します。
            Verifier verifier = new Verifier(mOAuthVerifier);
            mAccessToken = mService.getAccessToken(mRequestToken, verifier); // the requestToken you had from step 2
            return true;
        }
        @Override
        protected void onPostExecute(Boolean aBoolean) {
            start();
        }
    };
    task.execute();
    return false;
}
 
开发者ID:kurukurupapa,项目名称:TryAndroid,代码行数:26,代码来源:WebViewTwitter10aOAuthHelper.java

示例14: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
/**
 * アクセストークン(access Token)を取得
 */
private boolean getAccessToken() {
    Log.v(TAG, "getAccessToken called");
    if (mAccessToken != null) {
        return true;
    }

    AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
        @Override
        protected Boolean doInBackground(Void... voids) {
            // HTTP通信を行うため、非UIスレッドで実行します。
            Verifier verifier = new Verifier(mOAuthVerifier);
            mAccessToken = mService.getAccessToken(null, verifier);
            Log.v(TAG, "mAccessToken=" + mAccessToken);
            return true;
        }
        @Override
        protected void onPostExecute(Boolean aBoolean) {
            start();
        }
    };
    task.execute();
    return false;
}
 
开发者ID:kurukurupapa,项目名称:TryAndroid,代码行数:27,代码来源:BrowserIntentGoogle20OAuthHelper.java

示例15: getAccessToken

import org.scribe.model.Verifier; //导入依赖的package包/类
/**
 * アクセストークン(access Token)を取得
 */
private boolean getAccessToken() {
    if (mAccessToken != null) {
        return true;
    }
    Log.v(TAG, "getAccessToken called");

    AsyncTask<Void, Void, Boolean> task = new AsyncTask<Void, Void, Boolean>() {
        @Override
        protected Boolean doInBackground(Void... voids) {
            // HTTP通信を行うため、非UIスレッドで実行します。
            Verifier verifier = new Verifier(mOAuthVerifier);
            mAccessToken = mService.getAccessToken(null, verifier);
            Log.v(TAG, "mAccessToken=" + mAccessToken);
            return true;
        }
        @Override
        protected void onPostExecute(Boolean aBoolean) {
            start();
        }
    };
    task.execute();
    return false;
}
 
开发者ID:kurukurupapa,项目名称:TryAndroid,代码行数:27,代码来源:WebViewGoogle20OAuthHelper.java


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