This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .horizontal_list { | |
| font-size: 14px; | |
| width: 100%; | |
| overflow: hidden; | |
| } | |
| .horizontal_list ul { | |
| margin: 3px; | |
| text-align: center; | |
| float: right; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.util.Properties; | |
| import javax.mail.Address; | |
| import javax.mail.Authenticator; | |
| import javax.mail.Message; | |
| import javax.mail.MessagingException; | |
| import javax.mail.PasswordAuthentication; | |
| import javax.mail.Session; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UserDao extends SimpleJdbcDaoSupport { | |
| private static final String CREATE_USER_SQL = "insert into users(name, created_at, updated_at) values (?,?,?)"; | |
| public int createUser(String username) { | |
| Connection cnn = null; | |
| PreparedStatement pstmt = null; | |
| ResultSet rsId = null; | |
| int id = 0; | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.ab.jersey.dto; | |
| public class AppError { | |
| private String message; | |
| public AppError() { } | |
| public AppError(String message) { | |
| this.message = message; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source :rubygems | |
| # We are not loading Active Record, nor Active Resources etc. | |
| # We can do this in any app by simply replacing the rails gem | |
| # by the parts we want to use. | |
| gem "actionpack", "~> 3.2" | |
| gem "railties", "~> 3.2" | |
| gem "tzinfo" | |
| # Let's use thin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'java' | |
| apply plugin: 'eclipse' | |
| repositories { | |
| mavenCentral() | |
| } | |
| dependencies { | |
| compile "joda-time:joda-time:2.2" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package manta | |
| import manta.routes.Users | |
| import spray.routing.HttpService | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| trait SecuredRoutes extends HttpService with Users with TokenAuthenticator { | |
| val routes = authenticate(basicTokenAuth) { implicit user => | |
| usersRoute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait TokenAuthenticator { | |
| def apiTokenAuth(implicit dbSession: Session) = new ApiTokenAuthenticator() | |
| } | |
| class ApiTokenAuthenticator(implicit val dbSession: Session, implicit val executionContext: ExecutionContext) extends HttpAuthenticator[User] { | |
| override def getChallengeHeaders(httpRequest: HttpRequest): List[HttpHeader] = | |
| `WWW-Authenticate`(HttpChallenge(scheme = "Token", realm = "Manta", params = Map.empty)) :: Nil | |
| override def authenticate(credentials: Option[HttpCredentials], ctx: RequestContext): Future[Option[User]] = | |
| Future.successful( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AuthenticationManager { | |
| // inject db: Database, repo: Users | |
| def authenticateWithToken(token: String): Option[User] = { | |
| db withTransaction { implicit session => | |
| repo.authenticateWithToken(token) | |
| } | |
| } | |
| } | |
| trait TokenAuthenticator { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.test | |
| import scala.slick.driver.PostgresDriver | |
| object UserComponentRegistry extends UserRepositoryComponent { | |
| val userRepository = new UserRepository(PostgresDriver) | |
| } |