Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OpenIdAuthApi(
Utils.respondWithWebServerHeaders() {
if (code.isEmpty && state.isEmpty) {
// Initial request: generate nonce and set cookie
val nonce = java.util.UUID.randomUUID().toString
val nonce = UUID.randomUUID().toString
val encodedNonce =
Base64.getEncoder.encodeToString(nonce.getBytes(StandardCharsets.UTF_8))
setCookie(HttpCookie("temp", encodedNonce)) {
Expand Down
53 changes: 53 additions & 0 deletions admin/src/main/scala/com/neu/core/Core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.neu.web.StaticResources
import com.typesafe.config.{ Config, ConfigValueFactory }
import com.typesafe.config.ConfigFactory.*
import com.typesafe.scalalogging.LazyLogging
import org.apache.log4j.PropertyConfigurator
Comment thread
lsongsuse marked this conversation as resolved.
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.http.scaladsl.ConnectionContext
import org.apache.pekko.http.scaladsl.Http
Expand All @@ -14,6 +15,7 @@ import org.apache.pekko.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.settings.ServerSettings
import org.apache.pekko.stream.Materializer

import java.util.Properties
import scala.concurrent.ExecutionContextExecutor
import scala.concurrent.Future

Expand All @@ -31,11 +33,62 @@ trait BootedCore
given materializer: Materializer = Materializer(system)
given executionContext: ExecutionContextExecutor = system.dispatcher

private def configureLog4j(): Unit = {
val logFormat = sys.env.getOrElse("NV_LOG_FORMAT", "string").trim.toLowerCase
val layoutClass = logFormat match {
case "json" => "net.logstash.log4j.JSONEventLayoutV1"
case "string" | "plain" => "org.apache.log4j.PatternLayout"
case _ =>
logger.warn(s"Unsupported NV_LOG_FORMAT=$logFormat; defaulting to string format")
"org.apache.log4j.PatternLayout"
}
val props = new Properties()
val stream = Option(getClass.getClassLoader.getResourceAsStream("log4j.properties"))
stream.foreach { in =>
props.load(in)
in.close()
}

props.setProperty("log4j.rootLogger", "INFO, stdout")
props.setProperty("log4j.appender.stdout.layout", layoutClass)
if (layoutClass != "org.apache.log4j.PatternLayout") {
props.remove("log4j.appender.stdout.layout.ConversionPattern")
}

props.setProperty("log4j.appender.adminAppender.layout", layoutClass)
if (layoutClass != "org.apache.log4j.PatternLayout") {
props.remove("log4j.appender.adminAppender.layout.ConversionPattern")
}

props.setProperty("log4j.appender.kafkaAppender.layout", layoutClass)
if (layoutClass != "org.apache.log4j.PatternLayout") {
props.remove("log4j.appender.kafkaAppender.layout.ConversionPattern")
}

props.setProperty("log4j.appender.pekkoAppender.layout", layoutClass)
if (layoutClass != "org.apache.log4j.PatternLayout") {
props.remove("log4j.appender.pekkoAppender.layout.ConversionPattern")
}

props.setProperty("log4j.appender.sourceAppender.layout", layoutClass)
if (layoutClass != "org.apache.log4j.PatternLayout") {
props.remove("log4j.appender.sourceAppender.layout.ConversionPattern")
}

props.setProperty("log4j.appender.sinkAppender.layout", layoutClass)
if (layoutClass != "org.apache.log4j.PatternLayout") {
props.remove("log4j.appender.sinkAppender.layout.ConversionPattern")
}

PropertyConfigurator.configure(props)
}

private val rootService: Route = routes ~ staticResources

IpGeoManager
CisNISTManager
System.setProperty("net.sf.ehcache.enableShutdownHook", "true")
configureLog4j()

private val useSSL: String = sys.env.getOrElse("MANAGER_SSL", "on")
private val httpMaxHeaderLength: String = sys.env.getOrElse("HTTP_MAX_HEADER_LENGTH", "32k")
Expand Down
12 changes: 7 additions & 5 deletions admin/src/main/scala/com/neu/service/Services.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ class RoutedHttpService() extends Actor with ActorLogging with Directives {

def receive: Receive = Actor.emptyBehavior // No need to handle messages directly

def handleConnection: Receive = {
case b: Bound =>
log.info("***REST Server Started***")
case failed: CommandFailed =>
log.warning("***REST Server Could not be Started***" + failed.cmd.failureMessage)
def handleConnection: Receive = { case x: Matchable =>
x match {
case b: Bound =>
log.info("***REST Server Started***")
case failed: CommandFailed =>
log.warning("***REST Server Could not be Started***" + failed.cmd.failureMessage)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import com.neu.core.AuthenticationManager
import com.neu.model.AuthTokenJsonProtocol.{ *, given }
import com.neu.model.*
import org.apache.pekko.http.scaladsl.model.*
import org.apache.pekko.http.scaladsl.model.headers.HttpCookie
import org.apache.pekko.http.scaladsl.server.RequestContext
import org.apache.pekko.http.scaladsl.server.Route
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal
import org.apache.pekko.stream.Materializer
import spray.json.*

import java.nio.charset.StandardCharsets
import java.util.Base64
import scala.concurrent.Await
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
Expand Down
20 changes: 11 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ lazy val buildSettings = Seq(

lazy val commonDependencies = Seq(
scalaTest,
"javax.activation" % "activation" % "1.1.1",
"org.glassfish.jaxb" % "jaxb-runtime" % "4.0.5",
"javax.xml.bind" % "jaxb-api" % "2.3.1",
"com.sun.xml.ws" % "jaxws-ri" % "4.0.3",
"javax.xml.soap" % "javax.xml.soap-api" % "1.4.0",
"org.json4s" %% "json4s-native" % "4.0.7",
"org.bouncycastle" % "bcprov-jdk18on" % "1.79",
"org.bouncycastle" % "bcpkix-jdk18on" % "1.79",
"org.bouncycastle" % "bctls-jdk18on" % "1.79",
"javax.activation" % "activation" % "1.1.1",
"org.glassfish.jaxb" % "jaxb-runtime" % "4.0.5",
"javax.xml.bind" % "jaxb-api" % "2.3.1",
"com.sun.xml.ws" % "jaxws-ri" % "4.0.3",
"javax.xml.soap" % "javax.xml.soap-api" % "1.4.0",
"ch.qos.reload4j" % "reload4j" % "1.2.25",
"net.logstash.log4j" % "jsonevent-layout" % "1.7",
"org.json4s" %% "json4s-native" % "4.0.7",
"org.bouncycastle" % "bcprov-jdk18on" % "1.79",
"org.bouncycastle" % "bcpkix-jdk18on" % "1.79",
"org.bouncycastle" % "bctls-jdk18on" % "1.79",
pekkoActor,
typesafeConfig,
joda,
Expand Down
Loading