Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
workingDog committed Dec 5, 2017
1 parent 20d341e commit dcb6e9d
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 25 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Change Log
==========

### changes in 0.2-SNAPSHOT



7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## TAXII 2.0 client library in scala

**Taxii2LibScala** is a [Scala](https://www.scala-lang.org/) library that
**taxii2Lib** is a [Scala](https://www.scala-lang.org/) library that
provides a set of classes and methods for building clients to [TAXII 2.0](https://oasis-open.github.io/cti-documentation/) servers.

[[1]](https://oasis-open.github.io/cti-documentation/)
Expand All @@ -10,7 +10,7 @@ TAXII enables organizations to share CTI by defining an API that aligns with com
[TAXII 2.0 Specification](https://oasis-open.github.io/cti-documentation/) defines the TAXII RESTful API and its resources along with the requirements for TAXII Client and Server implementations.


**Taxii2LibScala** uses asynchronous requests to fetch TAXII 2.0 server resources.
**taxii2lib** uses asynchronous requests to fetch TAXII 2.0 server resources.
It provides the following endpoints:

- *Server*, endpoint for retrieving the discovery and api roots resources.
Expand All @@ -36,9 +36,10 @@ The class *TaxiiConnection* provides the async communication to the server.

Example:

import com.kodekutters.taxii._
// a connection object with a 5 seconds timeout
val conn = new TaxiiConnection("https://test.freetaxii.com:8000", "user-me", "mypassword", 5)
val server = new Server("/taxii/", conn)
val server = new Server("/com.kodekutters.taxii/", conn)
server.discovery.map(d => println("---> discovery " + d))

See the [TAXII 2.0 Specification](https://oasis-open.github.io/cti-documentation/) for the list
Expand Down
7 changes: 4 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-ws-standalone-json" % "1.1.3",
"com.typesafe.play" %% "play-json" % "2.6.7",
"com.github.workingDog" %% "scalastix" % "0.6-SNAPSHOT",
// "ch.qos.logback" % "logback-classic" % "1.2.3",
// "com.typesafe.scala-logging" %% "scala-logging" % "3.7.2"
// "ch.qos.logback" % "logback-classic" % "1.2.3",
// "com.typesafe.scala-logging" %% "scala-logging" % "3.7.2"
"org.slf4j" % "slf4j-nop" % "1.7.25"
)

organization := "com.github.workingDog"

homepage := Some(url("https://github.com/workingDog/taxii2LibScala"))
homepage := Some(url("https://github.com/workingDog/Taxii2LibScala"))

licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0"))

scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xlint")

6 changes: 6 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@
resolvers += Resolver.sonatypeRepo("public")
resolvers += Resolver.sonatypeRepo("releases")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.6")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")

65 changes: 65 additions & 0 deletions sonatype.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

pomExtra := {
<scm>
<url>https://github.com/workingDog/Taxii2LibScala</url>
<connection>scm:git:git@github.com:workingDog/Taxii2LibScala.git</connection>
</scm>
<developers>
<developer>
<id>workingDog</id>
<name>Ringo Wathelet</name>
<url>https://github.com/workingDog</url>
</developer>
</developers>
}

pomIncludeRepository := { _ => false }

scmInfo := Some(
ScmInfo(
url("https://github.com/workingDog/Taxii2LibScala"),
"scm:git:git@github.com:workingDog/Taxii2LibScala.git"
)
)

developers := List(
Developer(
id = "workingDog",
name = "Ringo Wathelet",
email = "",
url = url("https://github.com/workingDog")
)
)

publishMavenStyle := true

publishArtifact in Test := false

publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

// Release settings
sonatypeProfileName := "com.github.workingDog"
releasePublishArtifactsAction := PgpKeys.publishSigned.value
releaseTagName := (version in ThisBuild).value

import ReleaseTransformations._

releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
releaseStepCommand("sonatypeRelease"),
releaseStepCommand("publishSigned"),
setNextVersion,
commitNextVersion,
pushChanges
)
4 changes: 2 additions & 2 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<appender-ref ref="FILE" />
</root>

<logger name="taxii" level="DEBUG"/>
<logger name="taxii.TaxiiConnection" level="DEBUG"/>
<logger name="com.kodekutters.taxii" level="DEBUG"/>
<logger name="com.kodekutters.taxii.TaxiiConnection" level="DEBUG"/>

</configuration>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package taxii
package com.kodekutters.taxii

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
Expand All @@ -9,7 +9,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
* which can be used to help users and clients decide whether and how they want to interact with it.
*
* @param api_root the api_root path of this ApiRootRequest
* @param conn the connection to the taxii server
* @param conn the connection to the com.kodekutters.taxii server
*/
case class ApiRoot(api_root: String, conn: TaxiiConnection) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package taxii
package com.kodekutters.taxii

import com.kodekutters.stix.Bundle
import play.api.libs.json.Json
Expand All @@ -10,7 +10,7 @@ import scala.concurrent.Future
* This Endpoint provides general information about a Collection, which can be used to help
* users and clients decide whether and how they want to interact with it.
*
* @param conn the connection to the taxii server
* @param conn the connection to the com.kodekutters.taxii server
*/
case class Collection(taxiiCollection: TaxiiCollection, api_root: String,
conn: TaxiiConnection = TaxiiConnection("", 0, "", "", "")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package taxii
package com.kodekutters.taxii

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global

/**
* This Endpoint provides information about the Collections hosted under this API Root.
*
* @param conn the connection to the taxii server
* @param conn the connection to the com.kodekutters.taxii server
*/
case class Collections(api_root: String, conn: TaxiiConnection) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package taxii
package com.kodekutters.taxii

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
Expand All @@ -8,7 +8,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
*
* @param conn the connection to the taxii2 server
*/
case class Server(thePath: String = "/taxii/", conn: TaxiiConnection) {
case class Server(thePath: String = "/com/kodekutters/taxii/", conn: TaxiiConnection) {

def this(url: String, user: String, password: String, timeout: Int) = this(conn = new TaxiiConnection(url, user, password, timeout))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package taxii
package com.kodekutters.taxii

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
Expand All @@ -7,7 +7,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
/**
* This Endpoint provides information about the status of a previous request.
*
* @param conn the connection to the taxii server
* @param conn the connection to the com.kodekutters.taxii server
*/
case class Status(api_root: String, status_id: String, conn: TaxiiConnection) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package taxii
package com.kodekutters.taxii

import com.kodekutters.stix.Bundle
import java.net.URL
Expand Down Expand Up @@ -74,12 +74,12 @@ case class TaxiiConnection(host: String,
val hash = Base64.getEncoder.encodeToString((user + ":" + password).getBytes(StandardCharsets.UTF_8))

val getHeaders = Map(
"Accept" -> "application/vnd.oasis.taxii+json",
"Accept" -> "application/vnd.oasis.com.kodekutters.taxii+json",
"version" -> taxiiVersion,
"Authorization" -> ("Basic " + hash)).toSeq

val postHeaders = Map(
"Accept" -> "application/vnd.oasis.taxii+json",
"Accept" -> "application/vnd.oasis.com.kodekutters.taxii+json",
"Content-Type" -> "application/vnd.oasis.stix+json",
"version" -> taxiiVersion,
"Authorization" -> ("Basic " + hash)).toSeq
Expand All @@ -93,7 +93,7 @@ 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.
* fetch data from the server. A GET with the chosen path is sent to the com.kodekutters.taxii server.
* The json server response is parsed then converted to a Taxii2 protocol resource.
*
* @param thePath the url path for the GET
Expand Down Expand Up @@ -167,7 +167,7 @@ case class TaxiiConnection(host: String,
}

/**
* post data to the server. A POST with the chosen path is sent to the taxii server.
* post data to the server. A POST with the chosen path is sent to the com.kodekutters.taxii server.
* The server response is converted a Taxii2 Status resource.
*
* @param thePath the url path for the post
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package taxii
package com.kodekutters.taxii


// todo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package taxii
package com.kodekutters.taxii

import com.kodekutters.stix.Timestamp
import play.api.libs.json._
Expand Down

0 comments on commit dcb6e9d

Please sign in to comment.