/
LagomWebContext.scala
62 lines (38 loc) · 2.62 KB
/
LagomWebContext.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package org.pac4j.lagom.scaladsl
import java.util
import com.lightbend.lagom.scaladsl.api.transport.RequestHeader
import org.pac4j.core.context.session.SessionStore
import org.pac4j.core.context.{Cookie, WebContext}
import org.pac4j.core.exception.TechnicalException
/**
* <p>Implementation web context of PAC4J for Lagom framework.</p>
* <p>Context is immutable and the {@link SessionStore} is not supported.</p>
*
* @author Vladimir Kornyshev
* @since 1.0.0
*/
class LagomWebContext(requestHeader: RequestHeader) extends WebContext {
override def getSessionStore: SessionStore[_ <: WebContext] = throw new TechnicalException("Operation not supported")
override def getRequestParameter(s: String): String = throw new TechnicalException("Operation not supported")
override def getRequestParameters: util.Map[String, Array[String]] = throw new TechnicalException("Operation not supported")
override def getRequestAttribute(s: String): AnyRef = throw new TechnicalException("Operation not supported")
override def setRequestAttribute(s: String, o: Any): Unit = throw new TechnicalException("Operation not supported")
override def getRequestHeader(name: String): String = requestHeader.getHeader(name) match {
case Some(value) => value
case None => throw new TechnicalException(s"Header $name not found")
}
override def getRequestMethod: String = requestHeader.method.name
override def getRemoteAddr: String = throw new TechnicalException("Operation not supported")
override def writeResponseContent(s: String): Unit = throw new TechnicalException("Operation not supported")
override def setResponseStatus(i: Int): Unit = throw new TechnicalException("Operation not supported")
override def setResponseHeader(s: String, s1: String): Unit = throw new TechnicalException("Operation not supported")
override def setResponseContentType(s: String): Unit = throw new TechnicalException("Operation not supported")
override def getServerName: String = throw new TechnicalException("Operation not supported")
override def getServerPort: Int = throw new TechnicalException("Operation not supported")
override def getScheme: String = throw new TechnicalException("Operation not supported")
override def isSecure: Boolean = false
override def getFullRequestURL: String = throw new TechnicalException("Operation not supported")
override def getRequestCookies: util.Collection[Cookie] = throw new TechnicalException("Operation not supported")
override def addResponseCookie(cookie: Cookie): Unit = throw new TechnicalException("Operation not supported")
override def getPath: String = requestHeader.uri.getPath
}