Skip to content

Instantly share code, notes, and snippets.

View bblfish's full-sized avatar

Henry Story bblfish

View GitHub Profile
@bblfish
bblfish / RequestHeader.scala
Created September 19, 2012 20:50
Claim Monad for X509 Certificates - having trouble running map on it
import java.net.URI
import scalaz.concurrent.Promise
import scalaz._
import Scalaz._
import language.implicitConversions
import language.higherKinds
case class Cert(cn: String, pubKey: BigInt, webids: List[URI] )
trait RequestHeader {
@bblfish
bblfish / RequestHeader.scala
Created September 19, 2012 20:27
ClaimMondad version 1 - does not compile
import java.net.URI
import scalaz.concurrent.Promise
import scalaz._
import Scalaz._
import language.implicitConversions
case class Cert(cn: String, pubKey: BigInt, webids: List[URI] )
trait RequestHeader {
@bblfish
bblfish / WebIDAuthN.scala
Created July 29, 2012 09:24
Claim logic
package org.w3.play.auth
import akka.actor.Actor
import org.openrdf.model.URI
import java.security.cert.X509Certificate
import org.w3.play.rdf.GraphCache
import scalaz._
import scala.Some
import scalaz.Scalaz._
import org.w3.banana.RDF
@bblfish
bblfish / RDFReaderFactory.scala
Created June 7, 2012 17:23
make rdReaderFactory a bit more flexible
package org.w3.banana
import java.io._
import scalaz.Validation
import scalaz.Validation._
trait RDFReaderFactory[Rdf <: RDF] {
def format(ser: RDFSerialization) = ser match {
case RDFXML => RDFXMLReader
@bblfish
bblfish / AuthZ.scala
Created May 30, 2012 11:59
Authorization action
package org.w3.readwriteweb.play.auth
import play.api.mvc._
import javax.security.auth.Subject
import java.security.Principal
import play.api.libs.concurrent.Promise
import java.security.cert.Certificate
/**
@bblfish
bblfish / AuthZ test
Created May 29, 2012 22:19
Funcional AuthZ
case class AuthZ[A](act: Action[A])(implicit findGuard: RequestHeader => Guard) extends Action[A] {
def apply(req: Request): Result = {
val guard = findGuard(req)
if (guard.allow(guard.subject(req))) act(req)
else Results.Unauthorized
}
override
@bblfish
bblfish / gist:1870493
Created February 20, 2012 18:24
Nomo Turtle recurion issue - (see PN_PREFIX_1, PN_PREFIX_2, ...)
/*
* Copyright (c) 2012 Henry Story
* under the Open Source MIT Licence http://www.opensource.org/licenses/MIT
*/
package org.w3.rdf
import nomo._
import nomo.Errors.{TreeError, Single}
import scala.collection.mutable
@bblfish
bblfish / gist:1780802
Created February 9, 2012 16:00
RDF with simple IRI model
package org.w3.rdf
import org.w3.algebraic._
trait Module {
val xsdString = IRI("http://www.w3.org/2001/XMLSchema#string")
val rdfLangString = IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")
trait GraphInterface extends Iterable[Triple] { self =>
package org.w3.rdf
import org.w3.algebraic._
trait Module {
val xsdString = IRI("http://www.w3.org/2001/XMLSchema#string")
val rdfLangString = IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")
trait GraphInterface extends Iterable[Triple] { self =>
@bblfish
bblfish / gist:1780147
Created February 9, 2012 14:00
pimp my rdf
package org.w3.rdf
import org.w3.algebraic._
trait Module {
val xsdString = IRI("http://www.w3.org/2001/XMLSchema#string")
val rdfLangString = IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString")
trait GraphInterface extends Iterable[Triple] { self =>