diff --git a/module-code/app/securesocial/core/RuntimeEnvironment.scala b/module-code/app/securesocial/core/RuntimeEnvironment.scala index c7cc0f454..df149e98b 100644 --- a/module-code/app/securesocial/core/RuntimeEnvironment.scala +++ b/module-code/app/securesocial/core/RuntimeEnvironment.scala @@ -94,6 +94,7 @@ object RuntimeEnvironment { include(new LinkedInProvider(routes, cacheService, oauth1ClientFor(LinkedInProvider.LinkedIn))), include(new TwitterProvider(routes, cacheService, oauth1ClientFor(TwitterProvider.Twitter))), include(new XingProvider(routes, cacheService, oauth1ClientFor(XingProvider.Xing))), + include(new EvernoteProvider(routes, cacheService, oauth1ClientFor(EvernoteProvider.Evernote))), // username password include(new UsernamePasswordProvider[U](userService, avatarService, viewTemplates, passwordHashers)) ) diff --git a/module-code/app/securesocial/core/providers/EvernoteProvider.scala b/module-code/app/securesocial/core/providers/EvernoteProvider.scala new file mode 100644 index 000000000..f4bd67991 --- /dev/null +++ b/module-code/app/securesocial/core/providers/EvernoteProvider.scala @@ -0,0 +1,55 @@ +/** + * Copyright 2012-2014 Jorge Aliss (jaliss at gmail dot com) - twitter: @jaliss + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package securesocial.core.providers + +import com.evernote.edam.userstore.UserStore +import com.evernote.thrift.protocol.TBinaryProtocol +import com.evernote.thrift.transport.THttpClient +import securesocial.core._ +import securesocial.core.services.{ CacheService, RoutesService } + +import scala.concurrent.Future + +/** + * An Evernote Provider + */ +class EvernoteProvider( + routesService: RoutesService, + cacheService: CacheService, + client: OAuth1Client) extends OAuth1Provider( + routesService, + cacheService, + client +) { + override val id = EvernoteProvider.Evernote + + override def fillProfile(info: OAuth1Info): Future[BasicProfile] = Future.successful { + val userStoreTrans: THttpClient = new THttpClient(EvernoteProvider.UserInfo) + val userStoreProt: TBinaryProtocol = new TBinaryProtocol(userStoreTrans) + val userStore: UserStore.Client = new UserStore.Client(userStoreProt, userStoreProt) + val user = userStore.getUser(info.token) + + BasicProfile(id, user.getId.toString, None, None, Option(user.getName), None, None, authMethod, Some(info)) + } +} + +object EvernoteProvider { + val Evernote = "evernote" + val UserInfo = "https://sandbox.evernote.com/edam/user" + +} + diff --git a/module-code/build.sbt b/module-code/build.sbt index a52139acd..31cde53fd 100644 --- a/module-code/build.sbt +++ b/module-code/build.sbt @@ -16,6 +16,7 @@ libraryDependencies ++= Seq( filters, "com.typesafe.play.plugins" %% "play-plugins-util" % "2.3.0", "com.typesafe.play.plugins" %% "play-plugins-mailer" % "2.3.0", + "com.evernote" % "evernote-api" % "1.25.1", "org.mindrot" % "jbcrypt" % "0.3m", "org.specs2" %% "specs2" % "2.3.12" % "test", "org.mockito" % "mockito-all" % "1.9.5" % "test" diff --git a/module-code/public/securesocial/images/providers/evernote.png b/module-code/public/securesocial/images/providers/evernote.png new file mode 100644 index 000000000..c5501d261 Binary files /dev/null and b/module-code/public/securesocial/images/providers/evernote.png differ diff --git a/samples/java/demo/conf/securesocial.conf b/samples/java/demo/conf/securesocial.conf index a80ae3159..76bf3eb9c 100644 --- a/samples/java/demo/conf/securesocial.conf +++ b/samples/java/demo/conf/securesocial.conf @@ -219,6 +219,14 @@ securesocial { scope="non-expiring" } + evernote { + requestTokenUrl = "https://sandbox.evernote.com/oauth" + accessTokenUrl = "https://sandbox.evernote.com/oauth" + authorizationUrl = "https://sandbox.evernote.com/OAuth.action" + consumerKey=your_consumer_key + consumerSecret=your_consumer_secret + } + userpass { # # Enable username support, otherwise SecureSocial will use the emails as user names diff --git a/samples/scala/demo/conf/securesocial.conf b/samples/scala/demo/conf/securesocial.conf index 433edd5c8..c6b5ea753 100644 --- a/samples/scala/demo/conf/securesocial.conf +++ b/samples/scala/demo/conf/securesocial.conf @@ -236,6 +236,14 @@ securesocial { scope = "non-expiring" } + evernote { + requestTokenUrl = "https://sandbox.evernote.com/oauth" + accessTokenUrl = "https://sandbox.evernote.com/oauth" + authorizationUrl = "https://sandbox.evernote.com/OAuth.action" + consumerKey=your_consumer_key + consumerSecret=your_consumer_secret + } + userpass { # # Enable username support, otherwise SecureSocial will use the emails as user names