Skip to content
This repository has been archived by the owner on Sep 12, 2021. It is now read-only.

Commit

Permalink
Drop Scala 2.10 support
Browse files Browse the repository at this point in the history
Play 2.5 drops Scala 2.10 support so we do it as well
  • Loading branch information
akkie committed Nov 8, 2015
1 parent 90f059f commit d6705bb
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 44 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
logs
project/project
project/target
target
tmp
.history
dist
/.idea
/*.iml
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sudo: false
language: scala
scala:
- 2.10.5
- 2.11.7
jdk:
- oraclejdk8
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Remove SecuredErrorHandler in favour of injectable error handler
- Pass the auth info to the profile parsers to easier query additional data from the provider API
- Add UnsecuredRequestHandler and UnsecuredAction
- Dropped Scala 2.10 support

## 3.0 (2015-07-14)

Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import sbt._
object Dependencies {

object Versions {
val crossScala = Seq("2.11.7", "2.10.5")
val crossScala = Seq("2.11.7")
val scalaVersion = crossScala.head
}

Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositor

resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.0.1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.mohiva.play.silhouette.impl.authenticators

import com.mohiva.play.silhouette._
import com.mohiva.play.silhouette.api.Authenticator.Implicits._
import com.mohiva.play.silhouette.api.exceptions._
import com.mohiva.play.silhouette.api.repositories.AuthenticatorRepository
Expand Down Expand Up @@ -108,7 +107,7 @@ class BearerTokenAuthenticatorService(
* @return Some authenticator or None if no authenticator could be found in request.
*/
override def retrieve(implicit request: RequestHeader): Future[Option[BearerTokenAuthenticator]] = {
Future.from(Try(request.headers.get(settings.headerName))).flatMap {
Future.fromTry(Try(request.headers.get(settings.headerName))).flatMap {
case Some(token) => repository.find(token)
case None => Future.successful(None)
}.recover {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
package com.mohiva.play.silhouette.impl.authenticators

import com.mohiva.play.silhouette._
import com.mohiva.play.silhouette.api.Authenticator.Implicits._
import com.mohiva.play.silhouette.api.exceptions._
import com.mohiva.play.silhouette.api.repositories.AuthenticatorRepository
Expand Down Expand Up @@ -187,7 +186,7 @@ class CookieAuthenticatorService(
* @return Some authenticator or None if no authenticator could be found in request.
*/
override def retrieve(implicit request: RequestHeader): Future[Option[CookieAuthenticator]] = {
Future.from(Try {
Future.fromTry(Try {
if (settings.useFingerprinting) Some(fingerprintGenerator.generate) else None
}).flatMap { fingerprint =>
request.cookies.get(settings.cookieName) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package com.mohiva.play.silhouette.impl.authenticators

import com.atlassian.jwt.SigningAlgorithm
import com.atlassian.jwt.core.writer.{ JsonSmartJwtJsonBuilder, NimbusJwtWriterFactory }
import com.mohiva.play.silhouette._
import com.mohiva.play.silhouette.api.Authenticator.Implicits._
import com.mohiva.play.silhouette.api.exceptions._
import com.mohiva.play.silhouette.api.repositories.AuthenticatorRepository
Expand Down Expand Up @@ -259,7 +258,7 @@ class JWTAuthenticatorService(
* @return Some authenticator or None if no authenticator could be found in request.
*/
override def retrieve(implicit request: RequestHeader): Future[Option[JWTAuthenticator]] = {
Future.from(Try(request.headers.get(settings.headerName))).flatMap {
Future.fromTry(Try(request.headers.get(settings.headerName))).flatMap {
case Some(token) => unserialize(token)(settings) match {
case Success(authenticator) => repository.fold(Future.successful(Option(authenticator)))(_.find(authenticator.id))
case Failure(e) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.mohiva.play.silhouette.impl.authenticators

import com.mohiva.play.silhouette._
import com.mohiva.play.silhouette.api.Authenticator.Implicits._
import com.mohiva.play.silhouette.api.exceptions._
import com.mohiva.play.silhouette.api.services.AuthenticatorService._
Expand Down Expand Up @@ -142,7 +141,7 @@ class SessionAuthenticatorService(
* @return An authenticator.
*/
override def create(loginInfo: LoginInfo)(implicit request: RequestHeader): Future[SessionAuthenticator] = {
Future.from(Try {
Future.fromTry(Try {
val now = clock.now
SessionAuthenticator(
loginInfo = loginInfo,
Expand All @@ -163,7 +162,7 @@ class SessionAuthenticatorService(
* @return Some authenticator or None if no authenticator could be found in request.
*/
override def retrieve(implicit request: RequestHeader): Future[Option[SessionAuthenticator]] = {
Future.from(Try {
Future.fromTry(Try {
if (settings.useFingerprinting) Some(fingerprintGenerator.generate) else None
}).map { fingerprint =>
request.session.get(settings.sessionKey).flatMap { value =>
Expand Down Expand Up @@ -246,7 +245,7 @@ class SessionAuthenticatorService(
override def update(authenticator: SessionAuthenticator, result: Result)(
implicit request: RequestHeader): Future[AuthenticatorResult] = {

Future.from(Try {
Future.fromTry(Try {
AuthenticatorResult(result.addingToSession(settings.sessionKey -> serialize(authenticator)(settings)))
}.recover {
case e => throw new AuthenticatorUpdateException(UpdateError.format(ID, authenticator), e)
Expand Down Expand Up @@ -301,7 +300,7 @@ class SessionAuthenticatorService(
override def discard(authenticator: SessionAuthenticator, result: Result)(
implicit request: RequestHeader): Future[AuthenticatorResult] = {

Future.from(Try {
Future.fromTry(Try {
AuthenticatorResult(result.removingFromSession(settings.sessionKey))
}.recover {
case e => throw new AuthenticatorDiscardingException(DiscardError.format(ID, authenticator), e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.mohiva.play.silhouette.api.exceptions._
import com.mohiva.play.silhouette.api.util.ExtractableRequest
import com.mohiva.play.silhouette.impl.exceptions.{ AccessDeniedException, UnexpectedResponseException }
import com.mohiva.play.silhouette.impl.providers.OAuth2Provider._
import com.mohiva.play.silhouette.{ impl, _ }
import play.api.libs.json._
import play.api.libs.functional.syntax._
import play.api.libs.ws.WSResponse
Expand Down Expand Up @@ -57,7 +56,7 @@ case class OAuth2Info(
object OAuth2Info {

/**
* Converts the JSON into a [[impl.providers.OAuth2Info]] object.
* Converts the JSON into a [[com.mohiva.play.silhouette.impl.providers.OAuth2Info]] object.
*/
implicit val infoReads = (
(__ \ AccessToken).read[String] and
Expand Down Expand Up @@ -150,7 +149,7 @@ trait OAuth2Provider extends SocialProvider with Logger {
Code -> Seq(code),
RedirectURI -> Seq(resolveCallbackURL(settings.redirectURL))) ++ settings.accessTokenParams.mapValues(Seq(_))).flatMap { response =>
logger.debug("[Silhouette][%s] Access token response: [%s]".format(id, response.body))
Future.from(buildInfo(response))
Future.fromTry(buildInfo(response))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package com.mohiva.play.silhouette.impl.providers.oauth2.state

import javax.inject.Inject

import com.mohiva.play.silhouette._
import com.mohiva.play.silhouette.api.util.{ ExtractableRequest, Base64, Clock, IDGenerator }
import com.mohiva.play.silhouette.impl.exceptions.OAuth2StateException
import com.mohiva.play.silhouette.impl.providers.OAuth2Provider._
Expand Down Expand Up @@ -134,7 +133,7 @@ class CookieStateProvider @Inject() (
* @return The state on success, otherwise an failure.
*/
override def validate[B](implicit request: ExtractableRequest[B], ec: ExecutionContext) = {
Future.from(clientState.flatMap(clientState => providerState.flatMap(providerState =>
Future.fromTry(clientState.flatMap(clientState => providerState.flatMap(providerState =>
if (clientState != providerState) Failure(new OAuth2StateException(StateIsNotEqual))
else if (clientState.isExpired) Failure(new OAuth2StateException(StateIsExpired))
else Success(clientState)
Expand Down
20 changes: 1 addition & 19 deletions silhouette/app/com/mohiva/play/silhouette/package.scala
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
package com.mohiva.play

import scala.concurrent.Future
import scala.util.{ Failure, Success, Try }

/**
* An authentication library for Play Framework applications that supports several authentication methods,
* including OAuth1, OAuth2, OpenID, Credentials or custom authentication schemes.
*/
package object silhouette {

/**
* Provides an `from` method on a [[scala.concurrent.Future]] which maps a [[scala.util.Try]] to
* a [[scala.concurrent.Future]].
*
* @see https://groups.google.com/forum/#!topic/scala-user/Mu4_lZAWxz0/discussion
* @see http://stackoverflow.com/questions/17907772/scala-chaining-futures-try-blocks
*/
implicit class FutureWithFromTry(f: Future.type) {
def from[T](result: Try[T]): Future[T] = result match {
case Success(v) => Future.successful(v)
case Failure(v) => Future.failed(v)
}
}
}
package object silhouette
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ package com.mohiva.play.silhouette.api

import akka.actor.{ Actor, Props }
import akka.testkit.TestProbe
import org.specs2.control.NoLanguageFeatures
import org.specs2.specification.Scope
import play.api.libs.concurrent.Akka
import play.api.test.{ FakeRequest, PlaySpecification, WithApplication }

import scala.concurrent.duration._
import scala.language.postfixOps

/**
* Test case for the [[com.mohiva.play.silhouette.api.EventBus]] class.
*/
class EventBusSpec extends PlaySpecification {
class EventBusSpec extends PlaySpecification with NoLanguageFeatures {

"The event bus" should {
"handle an subclass event" in new WithApplication with Context {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class DummyAuthenticatorSpec extends PlaySpecification with Mockito {
"return unit" in new Context {
implicit val request = FakeRequest()

await(service.init(authenticator)) must be equalTo (())
await(service.init(authenticator)) must beEqualTo(())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SocialProviderRegistrySpec extends PlaySpecification with Mockito {
"The `getSeq` method" should {
"return a list of providers by it's sub type" in new Context {
val list = registry.getSeq[OAuth2Provider]
list(0).id must be equalTo providers(0).id
list.head.id must be equalTo providers.head.id
list(1).id must be equalTo providers(1).id
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PlayCacheLayerSpec extends PlaySpecification with Mockito {

"The `remove` method" should {
"removes value from cache" in new Context {
await(layer.remove("id")) must be equalTo (())
await(layer.remove("id")) must beEqualTo(())

there was one(cacheAPI).remove("id")
}
Expand Down

0 comments on commit d6705bb

Please sign in to comment.