@Override public Token getAccessToken() { OAuthSession session = getSession(); return session.getAccessToken(); }
@Override public synchronized void endDance() { OAuthSession currentSession = getCurrentSession(); System.out.println("Verifier ("+ getVerifierParamName() + ") : " + currentSession.getVerifier()); // FIXME replace with logger or disable if (currentSession.getAccessToken() == null) { currentSession.setAccessToken(getCurrentService().getAccessToken(currentSession.getRequestToken(), currentSession.getVerifier())); } if (currentSession.getAccessToken() != null) { currentSession.setRequestToken(null); currentSession.setUserProfile(getCurrentUserProfileService().getUserProfile()); currentSession.getRepo().add(currentSession); completeEvt.select(currentSession.getServiceQualifier()).fire(new OAuthComplete(SocialEvent.Status.SUCCESS, "", currentSession)); //TODO: reactivate logger } else { // FIXME Launch an exception !! } }
@Override public void authenticate() { if (session.isConnected()) { UserProfile userProfile = session.getUserProfile(); credentials.setCredential(session.getAccessToken()); setStatus(AuthenticationStatus.SUCCESS); setAccount(new AgoravaUser(userProfile)); } else { String authorizationUrl = lifeCycleService.startDanceFor(settings.getQualifier()); try { response.get().sendRedirect(authorizationUrl); } catch (IOException e) { throw new AgoravaException("Unable to redirect user to: " + authorizationUrl); } credentials.setStatus(Status.IN_PROGRESS); setStatus(AuthenticationStatus.DEFERRED); } } }
/** * Configure this builder with an existing {@link org.agorava.api.oauth.OAuthSession}. Convenient to clone a session * or to create an unproxified version of a session * * @param session the session to read values from * @return this builder */ public Builder readFromOAuthSession(OAuthSession session) { qualifier(session.getServiceQualifier()) .requestToken(session.getRequestToken()) .accessToken(session.getAccessToken()) .verifier(session.getVerifier()) .userProfile(session.getUserProfile()) .repo(session.getRepo()) .id(session.getId()); return this; }