aboutsummaryrefslogtreecommitdiff
path: root/gpg/skeybase/src/main/scala/com/github/jodersky/skeybase/Main.scala
blob: 460e221d89bb7b3aecccfcd4c7427f5a47d0b00f (plain) (blame)
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
package com.github.jodersky.skeybase

import scala.concurrent.Await
import scala.concurrent.duration._
import akka.actor.ActorSystem
import scala.language.implicitConversions
import scala.util.Success
import scala.util.Failure
import openpgp.GnuPG
import verifiers._

object Main {

  def main(args: Array[String]): Unit = {
    implicit val system = ActorSystem()
    import system.dispatcher

    val verifier = new WebsiteFileVerifier(new GnuPG()) //new GitHubVerifier(new GnuPG())

    val proofs = for (
      user <- new Keybase().lookup("jodersky");
      github = user.proofs.find(_.proofType == "generic_web_site").get;
      verification <- verifier.verify(user.primaryKey.fingerprint, github)
    ) yield {
      verification
    }

    proofs onComplete { result =>
      result match {
        case Success(proof) => println("done")
        case Failure(err: VerificationException) => println("Verification exception! Someone may be doing something evil. " + err.getMessage) 
        case Failure(err) => err.printStackTrace()
      }
      system.shutdown()
    }
  }

}