Skip to content

Commit

Permalink
dependencies update
Browse files Browse the repository at this point in the history
  • Loading branch information
workingDog committed May 13, 2018
1 parent 9882022 commit 760287d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ scalaVersion := "2.12.6"
version := (version in ThisBuild).value

libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-ahc-ws-standalone" % "1.1.6",
"com.typesafe.play" %% "play-ws-standalone-json" % "1.1.6",
"com.typesafe.play" %% "play-ahc-ws-standalone" % "1.1.8",
"com.typesafe.play" %% "play-ws-standalone-json" % "1.1.8",
"com.typesafe.play" %% "play-json" % "2.6.9",
"com.github.workingDog" %% "scalastix" % "0.7",
// "ch.qos.logback" % "logback-classic" % "1.2.3",
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/kodekutters/taxii/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

/**
* This Endpoint provides general information about a TAXII Server, including the advertised API Roots.
* This Endpoint provides general information about a Taxii-2.0 Server, including the advertised API Roots.
*
* @param thePath the path to the server discovery endpoint, default "/taxii/"
* @param conn the connection to the taxii2 server
* @param conn the connection to the Taxii-2.0 server
*/
case class Server(thePath: String = "/taxii/", conn: TaxiiConnection) {

Expand Down
22 changes: 12 additions & 10 deletions src/main/scala/com/kodekutters/taxii/TaxiiConnection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ import play.api.libs.ws.WSAuthScheme

import scala.language.implicitConversions
import reflect.runtime.universe._
import play.api.libs.ws.DefaultBodyReadables._

import scala.concurrent.ExecutionContext.Implicits._



object TaxiiConnection {
var taxiiVersion = "2.0"

val mediaType_stix = "application/vnd.oasis.stix+json"
val mediaType_taxii = "application/vnd.oasis.taxii+json"

Expand All @@ -44,7 +45,7 @@ object TaxiiConnection {
}

/**
* an https connection to a Taxii2 server
* an https connection to a Taxii-2.0 server
*
* for example: https://test.freetaxii.com:8000
*
Expand Down Expand Up @@ -96,12 +97,12 @@ case class TaxiiConnection(host: String,
val wsClient = StandaloneAhcWSClient()

/**
* fetch data from the server. A GET with the chosen path is sent to the taxii server.
* The json server response is parsed then converted to a Taxii2 protocol resource.
* fetch data from the server. A GET with the chosen path is sent to the Taxii-2.0 server.
* The json server response is parsed then converted to a Taxii-2.0 protocol resource.
*
* @param thePath the url path for the GET
* @tparam T the type of taxii2 resource to GET
* @return either a future Taxii2 error message or a future Taxii2 [T] type resource.
* @tparam T the type of Taxii-2.0 resource to GET
* @return either a future Taxii-2.0 error message or a future Taxii-2.0 [T] type resource.
*/
def fetch[T: TypeTag](thePath: String, theHeaders: Seq[(String, String)] = getHeaders,
filter: Option[Seq[(String, String)]] = None): Future[Either[TaxiiErrorMessage, T]] = {
Expand All @@ -113,6 +114,7 @@ case class TaxiiConnection(host: String,
.withRequestTimeout(timeout second)
.withQueryStringParameters(filter.getOrElse(Seq.empty): _*)
.get().map { response =>
println("------> response: "+response)
response.status match {
// partial content
case 206 => getTaxiiObject[T](response)
Expand Down Expand Up @@ -146,7 +148,7 @@ case class TaxiiConnection(host: String,
}

/**
* convert a json value to a Taxii2 or Bundle STIX object
* convert a json value to a Taxii-2.0 or Bundle STIX object
*/
private def jsonToTaxii[T: TypeTag](js: JsValue) = {
typeOf[T] match {
Expand All @@ -165,11 +167,11 @@ case class TaxiiConnection(host: String,

/**
* post data to the server. A POST with the chosen path is sent to the taxii server.
* The server response is converted a Taxii2 Status resource.
* The server response is converted a Taxii-2.0 Status resource.
*
* @param thePath the url path for the post
* @param jsonValue the JsValue data to send as a json Taxii resource.
* @return either a future Taxii2 error message or a future Taxii2 Status resource.
* @param jsonValue the JsValue data to send as a json Taxii-2.0 resource.
* @return either a future Taxii-2.0 error message or a future Taxii-2.0 Status resource.
*
*/
def post(thePath: String, jsonValue: JsValue): Future[Either[TaxiiErrorMessage, TaxiiStatus]] = {
Expand Down
7 changes: 0 additions & 7 deletions src/main/scala/com/kodekutters/taxii/TaxiiErrors.scala

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/scala/com/kodekutters/taxii/TaxiiProtocol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import play.api.libs.json._
* [1] Trusted Automated Exchange of Intelligence Information (TAXII™) is an application layer protocol
* for the communication of cyber threat information in a simple and scalable manner.
*
* Taxii-2.0
*
* reference[1]: https://oasis-open.github.io/cti-documentation/
*/

Expand Down

0 comments on commit 760287d

Please sign in to comment.