From be28b2ef91c20949a10fc6f7d3a154522b11f1b4 Mon Sep 17 00:00:00 2001 From: Joe Conley Date: Fri, 6 Feb 2015 13:29:34 -0500 Subject: [PATCH 1/2] initial setup --- .../app/securesocial/core/RuntimeEnvironment.scala | 1 + module-code/build.sbt | 1 + samples/scala/demo/conf/securesocial.conf | 8 ++++++++ 3 files changed, 10 insertions(+) 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/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/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 From 0562255e6ac4825ecda81dc60a0187315fa25d58 Mon Sep 17 00:00:00 2001 From: Joe Conley Date: Fri, 6 Feb 2015 13:31:12 -0500 Subject: [PATCH 2/2] initial evernote impl --- .../core/providers/EvernoteProvider.scala | 55 ++++++++++++++++++ .../images/providers/evernote.png | Bin 0 -> 1038 bytes samples/java/demo/conf/securesocial.conf | 8 +++ 3 files changed, 63 insertions(+) create mode 100644 module-code/app/securesocial/core/providers/EvernoteProvider.scala create mode 100644 module-code/public/securesocial/images/providers/evernote.png 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/public/securesocial/images/providers/evernote.png b/module-code/public/securesocial/images/providers/evernote.png new file mode 100644 index 0000000000000000000000000000000000000000..c5501d261aa50a8a9d222923b58dd9bbd8069fbe GIT binary patch literal 1038 zcmex=2qOn4Cl42oI1i7w zfr7Mx0m?FU=d^$QZ#gA6AnydS1J@SYMi)`L)mHLLD8U#A5@H! zikdjN#Ka{erBv0_H8izMOwG(KEUlbfT;1F~JiUTLLc_u%BBPR1Qq$5iGP89XZ3R<7E#dCS&q+js2Tb?ESsqsNY)IC<*Q z52H4wl7)pfYTn^y|H;WA0-xiEC`;q-C9@pc$x3AqknfU z*njJoOMlktr}Lc{EoI8qO*yuD$uoPY zU;Y|7<*D~7{uM#>E7nyee%#j2ws`r=U1@VmWp8^d`+m+*S-E-|OD)HvUH$AY(;Yu- xij4J@zPs;by2efE^9j`t80@*e8QavTwoI{{oOf+=-0s-97PBsV%RBS`CIE2%m8k## literal 0 HcmV?d00001 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