2010-10-26 09:29:04 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
exec scala "$0" "$@"
|
|
|
|
|
!#
|
|
|
|
|
|
|
|
|
|
/**
|
2012-01-19 18:21:06 +01:00
|
|
|
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
2010-10-26 09:29:04 +02:00
|
|
|
*/
|
|
|
|
|
import java.security.{MessageDigest, SecureRandom}
|
|
|
|
|
|
2010-10-27 13:22:38 +02:00
|
|
|
object Crypt {
|
|
|
|
|
val hex = "0123456789ABCDEF"
|
|
|
|
|
val lineSeparator = System.getProperty("line.separator")
|
|
|
|
|
|
|
|
|
|
lazy val random = SecureRandom.getInstance("SHA1PRNG")
|
|
|
|
|
|
|
|
|
|
def md5(text: String): String = md5(unifyLineSeparator(text).getBytes("ASCII"))
|
2010-10-26 09:29:04 +02:00
|
|
|
|
2010-10-27 13:22:38 +02:00
|
|
|
def md5(bytes: Array[Byte]): String = digest(bytes, MessageDigest.getInstance("MD5"))
|
2011-12-09 18:44:59 +01:00
|
|
|
|
|
|
|
|
def sha1(text: String): String = sha1(unifyLineSeparator(text).getBytes("ASCII"))
|
2010-10-26 09:29:04 +02:00
|
|
|
|
2010-10-27 13:22:38 +02:00
|
|
|
def sha1(bytes: Array[Byte]): String = digest(bytes, MessageDigest.getInstance("SHA1"))
|
|
|
|
|
|
|
|
|
|
def generateSecureCookie: String = {
|
|
|
|
|
val bytes = Array.fill(32)(0.byteValue)
|
|
|
|
|
random.nextBytes(bytes)
|
|
|
|
|
sha1(bytes)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def digest(bytes: Array[Byte], md: MessageDigest): String = {
|
|
|
|
|
md.update(bytes)
|
|
|
|
|
hexify(md.digest)
|
2011-12-09 18:44:59 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-27 13:22:38 +02:00
|
|
|
def hexify(bytes: Array[Byte]): String = {
|
|
|
|
|
val builder = new StringBuilder
|
|
|
|
|
bytes.foreach { byte => builder.append(hex.charAt((byte & 0xF) >> 4)).append(hex.charAt(byte & 0xF)) }
|
|
|
|
|
builder.toString
|
|
|
|
|
}
|
2010-10-26 09:29:04 +02:00
|
|
|
|
2010-10-27 13:22:38 +02:00
|
|
|
private def unifyLineSeparator(text: String): String = text.replaceAll(lineSeparator, "\n")
|
2010-10-26 09:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
2010-10-26 23:43:16 +02:00
|
|
|
print("""
|
|
|
|
|
# This config imports the Akka reference configuration.
|
|
|
|
|
include "akka-reference.conf"
|
|
|
|
|
|
|
|
|
|
# In this file you can override any option defined in the 'akka-reference.conf' file.
|
|
|
|
|
# Copy in all or parts of the 'akka-reference.conf' file and modify as you please.
|
|
|
|
|
|
|
|
|
|
akka {
|
|
|
|
|
remote {
|
2012-02-15 20:21:59 +01:00
|
|
|
netty {
|
|
|
|
|
secure-cookie = """")
|
2010-10-27 13:22:38 +02:00
|
|
|
print(Crypt.generateSecureCookie)
|
2010-10-26 23:43:16 +02:00
|
|
|
print(""""
|
2012-02-15 20:21:59 +01:00
|
|
|
require-cookie = on
|
|
|
|
|
}
|
2010-10-26 23:43:16 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|