@RequestMapping(value = "/token")
  public String getToken(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException, OAuthMessageSignerException,
          OAuthNotAuthorizedException, OAuthExpectationFailedException,
          OAuthCommunicationException {

    String oauthCallback = env.get("homeBaseUrl") + "freshbooks/upgradeToken";
    if (request.getParameter("guestId") != null)
      oauthCallback += "?guestId=" + request.getParameter("guestId");

    String userUrl = "palacehotelsoftware";

    OAuthConsumer consumer = new DefaultOAuthConsumer(userUrl, getConsumerSecret());
    consumer.setMessageSigner(new PlainTextMessageSigner());

    OAuthProvider provider =
        new DefaultOAuthProvider(
            "https://" + userUrl + ".freshbooks.com/oauth/oauth_request.php",
            "https://" + userUrl + ".freshbooks.com/oauth/oauth_access.php",
            "https://" + userUrl + ".freshbooks.com/oauth/oauth_authorize.php");

    request.getSession().setAttribute(FRESHBOOKS_OAUTH_CONSUMER, consumer);
    request.getSession().setAttribute(FRESHBOOKS_OAUTH_PROVIDER, provider);
    System.out.println("the token secret is: " + consumer.getTokenSecret());

    provider.setOAuth10a(true);
    String approvalPageUrl = provider.retrieveRequestToken(consumer, oauthCallback);

    return "redirect:" + approvalPageUrl;
  }
Пример #2
0
 public String getToodledoUserKey(Configuration env, String password, String sessionToken)
     throws NoSuchAlgorithmException {
   String hashed = hash(password);
   String appToken = env.get("toodledo.appToken");
   String toHash = hashed + appToken + sessionToken;
   return hash(toHash);
 }
Пример #3
0
 /** Returns a hash that serves as a client-side caching key; it is release-based */
 private String getTimeHash(final Configuration env, final String configKey) {
   final String toHash = env.get("release") + getStart() + getEnd() + configKey;
   return Utils.hash(toHash);
 }
 String getConsumerSecret() {
   return env.get("freshbooksConsumerSecret");
 }
 String getConsumerKey() {
   return env.get("freshbooksConsumerKey");
 }