@@ -0,0 +1,2682 @@
+package net.ttddyy.evernote.rest;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.social.evernote.connect.EvernoteConnectionFactory;%0Aimport org.springframework.social.evernote.connect.EvernoteOAuthToken;%0Aimport org.springframework.social.oauth1.AuthorizedRequestToken;%0Aimport org.springframework.social.oauth1.OAuth1Operations;%0Aimport org.springframework.social.oauth1.OAuth1Parameters;%0Aimport org.springframework.social.oauth1.OAuthToken;%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0Aimport org.springframework.web.bind.annotation.RequestParam;%0Aimport org.springframework.web.bind.annotation.RestController;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * @author Tadaya Tsuyukubo%0A */%0A@RestController%0A@RequestMapping(%22/oauth%22)%0Apublic class OAuthController %7B%0A%0A%09@Autowired%0A%09private EvernoteConnectionFactory evernoteConnectionFactory;%0A%0A%09@RequestMapping(%22/auth%22)%0A%09public Map%3CString, String%3E authorization(@RequestParam String callbackUrl,%0A%09                                         @RequestParam(required = false) boolean preferRegistration) %7B%0A%0A%09%09// obtain request token (temporal credential)%0A%09%09final OAuth1Operations oauthOperations = this.evernoteConnectionFactory.getOAuthOperations();%0A%09%09final OAuthToken requestToken = oauthOperations.fetchRequestToken(callbackUrl, null); // no additional param%0A%0A%09%09// construct authorization url with callback url for client to redirect%0A%09%09final OAuth1Parameters parameters = new OAuth1Parameters();%0A%09%09if (preferRegistration) %7B%0A%09%09%09parameters.set(%22preferRegistration%22, %22true%22);  // create account%0A%09%09%7D%0A%09%09final String authorizeUrl = oauthOperations.buildAuthorizeUrl(requestToken.getValue(), parameters);%0A%0A%09%09final Map%3CString, String%3E map = new HashMap%3CString, String%3E();%0A%09%09map.put(%22authorizeUrl%22, authorizeUrl);%0A%09%09map.put(%22requestTokenValue%22, requestToken.getValue());%0A%09%09map.put(%22requestTokenSecret%22, requestToken.getSecret());%0A%09%09return map;%0A%09%7D%0A%0A%0A%09@RequestMapping(%22/accessToken%22)%0A%09public EvernoteOAuthToken obtainAccessToken(@RequestParam String oauthToken, @RequestParam String oauthVerifier,%0A%09                                            @RequestParam String requestTokenSecret) %7B%0A%09%09final OAuthToken requestToken = new OAuthToken(oauthToken, requestTokenSecret);%0A%09%09final AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(requestToken, oauthVerifier);%0A%0A%09%09final OAuth1Operations oAuth1Operations = this.evernoteConnectionFactory.getOAuthOperations();  // EvernoteOAuth1Operations%0A%09%09final OAuthToken accessToken = oAuth1Operations.exchangeForAccessToken(authorizedRequestToken, null);  // no additional param%0A%09%09return (EvernoteOAuthToken) accessToken;%0A%09%7D%0A%0A%7D%0A

add controller for evernote oauth dance