Author: bblfish
Date: Wed May 4 13:56:39 2011
New Revision: 1099450
URL: http://svn.apache.org/viewvc?rev=1099450&view=rev
Log:
CLEREZZA-479: WebId Test suite: it helps to have a specialised WebIDPrincipal
that maintains the memory of the WebID. In fact all principals types should
have their own class names, but that is something for another bug fix
Modified:
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/WebIDClaim.scala
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala
Modified:
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala?rev=1099450&r1=1099449&r2=1099450&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala
(original)
+++
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/FoafSslAuthentication.scala
Wed May 4 13:56:39 2011
@@ -42,7 +42,7 @@ object FoafSslAuthentication {
def createSystemUserDescription(claim: WebIDClaim): MGraph = {
val result = new SimpleMGraph()
result.add(new TripleImpl(claim.webId, PLATFORM.userName,
- new PlainLiteralImpl(claim.userName)))
+ new PlainLiteralImpl(claim.principal.getName)))
result.add(new TripleImpl(claim.webId, RDF.`type`,
FOAF.Agent))
result
Modified:
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/WebIDClaim.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/WebIDClaim.scala?rev=1099450&r1=1099449&r2=1099450&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/WebIDClaim.scala
(original)
+++
incubator/clerezza/trunk/parent/platform.security.foafssl/core/src/main/scala/org/apache/clerezza/foafssl/auth/WebIDClaim.scala
Wed May 4 13:56:39 2011
@@ -49,7 +49,7 @@ class WebIDClaim(val webId: UriRef, val
val errors = new LinkedList[java.lang.Throwable]()
- lazy val principal = new PrincipalImpl(userName)
+ lazy val principal = new WebIdPrincipal(webId)
var verified = Verification.Unverified
/*private lazy val selectQuery = {
@@ -66,14 +66,6 @@ class WebIDClaim(val webId: UriRef, val
queryParser.parse(query).asInstanceOf[SelectQuery]
}*/
- //todo: not at all a satisfactory username method. Find something
better.
- lazy val userName = for (c <- webId.getUnicodeString) yield
- c match {
- case ':' => '_';
- case '#' => '_';
- case '/' => '_';
- case _ => c
- }
/**
@@ -181,6 +173,21 @@ class WebIDVerificationError(msg: String
}
+object WebIdPrincipal {
+ //todo: not at all a satisfactory username method. Find something
better.
+ def userName(webId: UriRef) = for (c <- webId.getUnicodeString) yield
+ c match {
+ case ':' => '_';
+ case '#' => '_';
+ case '/' => '_';
+ case _ => c
+ }
+}
+
+class WebIdPrincipal(val webId: UriRef) extends
PrincipalImpl(WebIdPrincipal.userName(webId)) {
+
+}
+
object Verification extends Enumeration {
Modified:
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala?rev=1099450&r1=1099449&r2=1099450&view=diff
==============================================================================
---
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala
(original)
+++
incubator/clerezza/trunk/parent/platform.security.foafssl/test/src/main/scala/org/apache/clerezza/foafssl/test/WebIDTester.scala
Wed May 4 13:56:39 2011
@@ -203,13 +203,14 @@ class CertTester(subj: Subject, webProxy
//
// WebID authentication succeeded
//
- val principals = subj.getPrincipals.filter(p =>
p.isInstanceOf[WebIdPrincipal])
+ val principals = for (p <- subj.getPrincipals
+ if p.isInstanceOf[WebIdPrincipal]) yield
p.asInstanceOf[WebIdPrincipal]
(g.bnode â EARL.Assertion
â EARL.test â¶ TEST.webidAuthentication
â EARL.result â¶ (g.bnode â EARL.TestResult
â DC.description â¶ {"found
" + principals.size + " valid principals"}
â EARL.outcome â¶ {if
(principals.size > 0) EARL.passed else EARL.failed}
- â EARL.pointer â¶*
principals.map(p => new UriRef(p.getName))
+ â EARL.pointer â¶*
principals.map(p => p.webId)
)
â EARL.subject â¶* x509claimRefs.map(p => p._1)
)