merged bergi's changed into main branch.
authorHenry Story <henry.story@bblfish.net>
Fri, 18 Nov 2011 19:55:30 +0100
changeset 190 c87c211832e2
parent 189 799504dd986b (current diff)
parent 187 98f652d92840 (diff)
child 191 3e8b27e22344
merged bergi's changed into main branch.
--- a/.hgignore	Wed Nov 16 14:30:03 2011 +0100
+++ b/.hgignore	Fri Nov 18 19:55:30 2011 +0100
@@ -1,4 +1,6 @@
 syntax: glob
-
 *.pyc
-
+tests/code/.settings/
+tests/code/bin/
+tests/code/dist/
+tests/code/target/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/.classpath	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/.project	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>WebIDTestSuite</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+	</natures>
+</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/README.txt	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,74 @@
+	WebID Test Suite
+
+1. About
+This test suite dynamicly creates functional and broken WebIDs with
+different characteristics. These WebIDs are used to login at the defined
+endpoint. The endpoint should return EARL triples like defined in the
+following vocabular:
+www.w3.org/2005/Incubator/webid/earl/RelyingParty#
+For every test case a SPARQL query is defined to check whether the endpoint
+acts as expected or not.
+
+2. Requirements
+The source code is maintend in a subversion repository. To build the test
+suite from the sources you will need a subversion client. A JDK version 5
+or above is required to build the project. Also Maven is required for
+building and fetching all required libraries from the web.
+
+2.1. Requirements for FileFOAFPublisher (optional)
+You should use the embedded web server. With the FileFOAFPublisher you
+depend on the HTTP Server which could send for example corrupted headers!!
+If you still want to use it a HTTP server with local files access is
+required.
+
+3. Compiling the test suite
+With the command line subversion client you can check out the code with
+the following command:
+"svn co https://www.axolotlfarm.org/svn/bergi/bergnet/java/tests/webid/trunk/ WebIDTestSuite".
+To compile the code with maven run: "mvn compile".
+
+4. Configuration of the test suite
+The file "default.properties" contains all default settings. Usually that
+should work for you. But if you need to change something, the file contains
+comments about all parameters.  
+
+5. Running the tests
+Use the exec:java plugin to run the test suite. Here an example: 
+"mvn exec:java -Dexec.mainClass=org.bergnet.test.webid.WebIDTests -Dexec.args="-endpoint https://foafssl.org/test/WebId/n3 -stayalive -outputformat TTL" -X".
+See the Command line parameters section for more details.
+
+5.1. Command line parameters
+Every parameter begins with a minus like "-example". If an additional
+argument is required it must follow separated by space. Here is a list of
+all parameters:
+
+	-config $: Alernative configuration file
+		default: -config default.properties
+		example: -config example.properties
+
+	-criterions: Outputs the description of the EARL tests
+		default: not set
+		example: -criterions
+
+	-outputformat $: Defines the triple output format ("RDF/XML" or "TTL")
+		default: -outputformat RDF/XML
+		example: -outputforamt TTL
+
+	-endpoint $: Url to the endpoint you want to test
+		default: see properties file
+		example: -endpoint https://foafssl.org/test/WebId/n3
+
+	-baseurl $: The base directory where your FOAF will be published
+		(only host and port is used for embedded Jetty server)
+		default: -baseurl http://localhost:8080/
+		example: -baseurl http://mypc:1234/
+
+	-stayalive: Program doesn't terminate after tests are finished
+		(if	you want to access the files from the embedded server)
+		default: not set
+		example: -stayalive
+
+5.2. Repeating and verifying a test with curl
+You can use curl to repeat a test. The output folder contains the
+certificate (webid.pem) for every test case. So you just have to type:
+"curl -k -E webid.pem:password -H "Accept: text/turtle" https://foafssl.org/test/WebId/n3 > out.n3"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/build.xml	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,110 @@
+<!--
+test-webid
+Copyright (C) 2011 Thomas Bergwinkl
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+<project name="WebIDTests" default="webid-tool-dist" basedir=".">
+	<property name="src" location="src"/>
+	<property name="lib" location="lib"/>
+	<property name="build" location="build"/>
+	<property name="dist" location="dist"/>
+
+	<target name="init">
+		<tstamp/>
+		<mkdir dir="${build}"/>
+	</target>
+
+	<target name="compile" depends="init">
+		<javac srcdir="${src}" destdir="${build}">
+			<classpath>
+				<pathelement location="${lib}/arq-2.8.7.jar"/>
+				<pathelement location="${lib}/bcprov-ext-jdk16-145.jar"/>
+				<pathelement location="${lib}/httpclient-4.1.jar"/>
+				<pathelement location="${lib}/httpcore-4.1.jar"/>
+				<pathelement location="${lib}/jena-2.6.4.jar"/>
+				<pathelement location="${lib}/junit-4.8.2.jar"/>				
+			</classpath>
+		</javac>
+	</target>
+
+	<target name="webid-tool-dist" depends="compile">
+		<fileset dir="${lib}" id="webid-tool-libs">
+			<filename name="bcprov-ext-jdk16-145.jar"/>
+		</fileset>
+
+		<mkdir dir="${dist}/webid-tool/lib"/>
+
+		<copy todir="${dist}/webid-tool/lib">
+			<fileset refid="webid-tool-libs"/>
+		</copy>
+
+	    <pathconvert property="webid-tool-classpath" refid="webid-tool-libs" pathsep=" " dirsep="/">
+			<mapper>
+				<chainedmapper>
+					<flattenmapper/>
+					<globmapper from="*" to="lib/*"/>
+				</chainedmapper>
+			</mapper>
+		</pathconvert>
+
+		<jar jarfile="${dist}/webid-tool/WebIDTool-${DSTAMP}.jar">
+			<fileset dir="${build}">
+				<include name="org/bergnet/commons/webid/**.class"/>
+			</fileset>
+			<manifest>
+				<attribute name="Main-Class" value="org.bergnet.commons.webid.WebIDTool"/>
+				<attribute name="Class-Path" value="${webid-tool-classpath}"/>
+			</manifest>
+		</jar>
+	</target>
+
+	<target name="test-webid-dist" depends="compile">
+		<fileset dir="${lib}" id="test-webid-libs"/>
+
+		<mkdir dir="${dist}/test-webid/lib"/>
+
+		<copy todir="${dist}/test-webid/lib">
+			<fileset refid="test-webid-libs"/>
+		</copy>
+
+		<copy todir="${dist}/test-webid">
+			<fileset dir=".">
+				<include name="default.properties"/>
+			</fileset>
+		</copy>
+
+	    <pathconvert property="test-webid-classpath" refid="test-webid-libs" pathsep=" " dirsep="/">
+			<mapper>
+				<chainedmapper>
+					<flattenmapper/>
+					<globmapper from="*" to="lib/*"/>
+				</chainedmapper>
+			</mapper>
+		</pathconvert>
+
+		<jar jarfile="${dist}/test-webid/test-webid-${DSTAMP}.jar">
+			<fileset dir="${build}"/>
+			<manifest>
+				<attribute name="Main-Class" value="org.bergnet.commons.test.webid.WebIDTests"/>
+				<attribute name="Class-Path" value="${test-webid-classpath}"/>
+			</manifest>
+		</jar>
+	</target>
+
+	<target name="clean">
+		<delete dir="${build}"/>
+		<delete dir="${dist}"/>
+	</target>
+</project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/default.properties	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,58 @@
+# test-webid
+# Copyright (C) 2011 Thomas Bergwinkl
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+# This class will publish the FOAF file. The JettyFOAFPublisher is the
+# embedded server. Only with this publisher you have full control of the
+# sent headers. The FileFAOFPublisher can be used if you are not reachable
+# by the endpoint, but you have file system access to folder published via
+# a HTTP server.
+org.bergnet.commons.test.webid.publish.class=org.bergnet.test.webid.publishers.JettyFOAFPublisher
+#org.bergnet.commons.test.webid.publish.class=org.bergnet.test.webid.publishers.FileFOAFPublisher
+
+# The base directory where your FOAF file will be published. The
+# JettyFOAFPublisher uses onlythe host name and port. For the
+# FileFOAFPublisher this should point to the public URL for the defined
+# path.  
+org.bergnet.commons.test.webid.publish.baseUrl=http://localhost:8080/
+#org.bergnet.commons.test.webid.publish.baseUrl=http://bergnet.dyndns.org/~bergnet/webid_test/
+
+
+# Only used by the FileFOAFPublisher: Defines the path in the file system
+# where the FOAF file will be written.
+org.bergnet.commons.test.webid.publish.filepublisher.basePath=X:/webid_test/
+
+# RSA key size for the WebID
+org.bergnet.commons.test.webid.keySize=1024
+
+# URL to the endpoint which produces test results in WebID EARL format 
+#org.bergnet.commons.test.webid.endpoint=https://resourceme.bergnet.org/test.php
+org.bergnet.commons.test.webid.endpoint=https://foafssl.org/test/WebId/n3
+
+# Write some debug information to stderr
+org.bergnet.commons.test.webid.debug=true
+
+org.bergnet.commons.test.webid.testclasses=\
+	org.bergnet.test.webid.testcases.MissingFOAF,\
+	org.bergnet.test.webid.testcases.MultipleURIs,\
+	org.bergnet.test.webid.testcases.Simple,\
+	org.bergnet.test.webid.testcases.SimpleTurtle,\
+	org.bergnet.test.webid.testcases.WrongModulus,\
+	org.bergnet.test.webid.testcases.WrongPublicExponent
+
+# TODO: Testcase: missing #me
+# TODO: Testcase: content types!
+# TODO: change baseUrl to -> foafDirUrl
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/gpl-3.0.txt	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/pom.xml	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,49 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.bergnet.test</groupId>
+  <artifactId>WebIDTestSuite</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <dependencies>
+  	<dependency>
+  		<groupId>com.hp.hpl.jena</groupId>
+  		<artifactId>arq</artifactId>
+  		<version>2.8.8</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>com.hp.hpl.jena</groupId>
+  		<artifactId>jena</artifactId>
+  		<version>2.6.4</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>junit</groupId>
+  		<artifactId>junit</artifactId>
+  		<version>4.9</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>org.apache.httpcomponents</groupId>
+  		<artifactId>httpclient</artifactId>
+  		<version>4.1.2</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>org.bouncycastle</groupId>
+  		<artifactId>bcprov-jdk16</artifactId>
+  		<version>1.46</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>org.eclipse.jetty</groupId>
+  		<artifactId>jetty-server</artifactId>
+  		<version>8.0.0.M3</version>
+  	</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+</project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/sparql/missingFoaf.rq	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,12 @@
+PREFIX earl: <http://www.w3.org/ns/earl#>
+PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>
+ASK WHERE {
+	?profileGetAssertion
+		earl:test wit:profileGet;
+		earl:result ?profileGetResult;
+		earl:subject ?webid.
+	?profileGetResult earl:outcome earl:failed.
+	?webidAuthenticationAssertion
+		earl:test wit:webidAuthentication;
+		earl:result ?webidAuthenticationResult.
+	?webidAuthenticationResult earl:outcome earl:failed }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/sparql/multipleUris.rq	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,19 @@
+PREFIX earl: <http://www.w3.org/ns/earl#>
+PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>
+ASK WHERE {
+	?webidClaimAssertion1
+		earl:test wit:webidClaim;
+		earl:result ?webidClaimResult1;
+		earl:subject ?webidClaimSubject1.
+	?webidClaimResult1 earl:outcome earl:passed.
+	?webidClaimSubject1 wit:claimedIdentity ?webid1String.
+	?webidClaimAssertion2
+		earl:test wit:webidClaim;
+		earl:result ?webidClaimResult2;
+		earl:subject ?webidClaimSubject2.
+	?webidClaimResult2 earl:outcome earl:passed.
+	?webidClaimSubject2 wit:claimedIdentity ?webid2String.
+	?webidAuthenticationAssertion
+		earl:test wit:webidAuthentication;
+		earl:result ?webidAuthenticationResult.
+	?webidAuthenticationResult earl:outcome earl:passed }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/sparql/simple.rq	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,10 @@
+PREFIX earl: <http://www.w3.org/ns/earl#>
+PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>
+ASK WHERE {
+	?webidAuthenticationAssertion
+		earl:test wit:webidAuthentication;
+		earl:result ?webidAuthenticationResult.
+	?webidAuthenticationResult
+		earl:outcome earl:passed;
+		earl:pointer ?webidClaim.
+	?webidClaim wit:claimedIdentity ?webidString }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/sparql/simpleTurtle.rq	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,10 @@
+PREFIX earl: <http://www.w3.org/ns/earl#>
+PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>
+ASK WHERE {
+	?webidAuthenticationAssertion
+		earl:test wit:webidAuthentication;
+		earl:result ?webidAuthenticationResult.
+	?webidAuthenticationResult
+		earl:outcome earl:passed;
+		earl:pointer ?webidClaim.
+	?webidClaim wit:claimedIdentity ?webidString }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/sparql/wrongModulus.rq	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,13 @@
+PREFIX earl: <http://www.w3.org/ns/earl#>
+PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>
+ASK WHERE {
+	?webidClaimAssertion
+		earl:test wit:webidClaim;
+		earl:result ?webidClaimResult;
+		earl:subject ?webidClaimSubject.
+	?webidClaimResult earl:outcome earl:failed.
+	?webidClaimSubject wit:claimedIdentity ?webidString.
+	?webidAuthenticationAssertion
+		earl:test wit:webidAuthentication;
+		earl:result ?webidAuthenticationResult.
+	?webidAuthenticationResult earl:outcome earl:failed }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/sparql/wrongPublicExponent.rq	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,13 @@
+PREFIX earl: <http://www.w3.org/ns/earl#>
+PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>
+ASK WHERE {
+	?webidClaimAssertion
+		earl:test wit:webidClaim;
+		earl:result ?webidClaimResult;
+		earl:subject ?webidClaimSubject.
+	?webidClaimResult earl:outcome earl:failed.
+	?webidClaimSubject wit:claimedIdentity ?webidString.
+	?webidAuthenticationAssertion
+		earl:test wit:webidAuthentication;
+		earl:result ?webidAuthenticationResult.
+	?webidAuthenticationResult earl:outcome earl:failed }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/EarlJunitRunListener.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,112 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunListener;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Property;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.vocabulary.DCTerms;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+
[email protected]({"rawtypes","unchecked"})
+public class EarlJunitRunListener extends RunListener {
+	private Model model = null;
+	private String subject = null;
+	private String testUrl = null;
+
+	private Property earlResult = null;
+	private Property earlOutcome = null;
+	private Property earlSubject =  null;
+	private Property earlTest = null;
+
+	public EarlJunitRunListener()  {
+		this.model = ModelFactory.createDefaultModel();
+		this.earlResult = this.model.createProperty("http://www.w3.org/ns/earl#", "result");
+		this.earlOutcome = this.model.createProperty("http://www.w3.org/ns/earl#", "outcome");
+		this.earlSubject = this.model.createProperty("http://www.w3.org/ns/earl#", "subject");
+		this.earlTest = this.model.createProperty("http://www.w3.org/ns/earl#", "test");
+	}
+
+	public void setSubject(String currentSubject) {
+		this.subject = currentSubject;
+	}
+
+	public Model getModel() {
+		return this.model;
+	}
+
+	public void testStarted(Description description) {
+		this.testUrl = null;
+	}
+
+	public void testFinished(Description description) {
+		try {
+			Class testClass = Class.forName(description.getClassName());
+			Method testMethod = testClass.getMethod(description.getMethodName());
+
+			if(testMethod.isAnnotationPresent(EarlTestCase.class))
+				this.testUrl = ((EarlTestCase)testMethod.getAnnotation(EarlTestCase.class)).url();
+		} catch (Exception e) {}
+	}
+
+	public void testRunFinished(Result result) {
+		if(this.testUrl == null)
+			return;
+
+		String outcome = result.wasSuccessful() ? "http://www.w3.org/ns/earl#passed" : "http://www.w3.org/ns/earl#failed";
+
+		ArrayList<String> descriptions = new ArrayList<String>();
+
+		for(Failure failure : result.getFailures()) {
+			Throwable throwable = failure.getException();
+
+			if(throwable.getMessage() != null && !throwable.getMessage().isEmpty())
+				descriptions.add(throwable.getMessage());
+		}
+
+		createAssertion(this.testUrl, outcome, descriptions);
+	}
+
+	private void createAssertion(String testUrl, String outcome, List<String> descriptions) {
+		Resource testResult = null;
+
+		testResult = this.model.createResource()
+				.addProperty(RDF.type, this.model.createResource("http://www.w3.org/ns/earl#TestResult"))
+				.addProperty(this.earlOutcome, this.model.createResource(outcome));
+
+		for(String description : descriptions)
+			testResult.addProperty(DCTerms.description, description);
+
+		model.createResource()
+			.addProperty(RDF.type, this.model.createResource("http://www.w3.org/ns/earl#Assertion"))
+			.addProperty(this.earlResult, testResult)
+			.addProperty(this.earlSubject, this.model.createResource(this.subject))
+			.addProperty(this.earlTest, this.model.createResource(testUrl));
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/EarlTestCase.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,32 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
[email protected](RetentionPolicy.RUNTIME)
[email protected]({ElementType.METHOD})
+public @interface EarlTestCase {
+	public String url();
+	public String title() default "";
+	public String description() default "";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/EarlTestCriterionRDFBuilder.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,54 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test;
+
+import java.lang.reflect.Method;
+
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.vocabulary.DCTerms;
+import com.hp.hpl.jena.vocabulary.RDF;
+
+
[email protected]("rawtypes")
+public class EarlTestCriterionRDFBuilder {
+	public static Model build(Class[] testClasses) {
+		Model model = ModelFactory.createDefaultModel();
+
+		for(Class testClass : testClasses) {
+			for(Method method : testClass.getMethods()) {
+				if(method.isAnnotationPresent(EarlTestCase.class))
+					addTestCase(model, method.getAnnotation(EarlTestCase.class));
+			}
+		}
+
+		return model;
+	}
+
+	private static void addTestCase(Model model, EarlTestCase earlTestCase) {
+		Resource test = model.createResource(earlTestCase.url())
+				.addProperty(RDF.type, model.createResource("http://www.w3.org/ns/earl#TestCase"));
+
+		if(earlTestCase.title() != null && !earlTestCase.title().isEmpty())
+			test.addProperty(DCTerms.title, earlTestCase.title());
+
+		if(earlTestCase.description() != null && !earlTestCase.description().isEmpty())
+			test.addProperty(DCTerms.description, earlTestCase.description());
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/SingleCertificateTrustManager.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,41 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+public class SingleCertificateTrustManager implements X509TrustManager {
+	private X509Certificate certificate;
+
+	public SingleCertificateTrustManager(X509Certificate certificate) {
+		this.certificate = certificate;
+	}
+
+	public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+	}
+
+	public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+	}
+
+	public X509Certificate[] getAcceptedIssuers() {
+		return new X509Certificate[] { certificate };
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/TestResultCatcher.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,37 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid;
+
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.notification.RunListener;
+
+public class TestResultCatcher extends RunListener {
+	public void testRunStarted(Description description) {
+		System.out.println("running test case: " + description.getChildren().get(0).getDisplayName());
+	}
+
+	public void testRunFinished(Result result) {
+		System.out.println("test case finished with " + result.getFailureCount() + " failures");
+	}
+
+	/*public void testFinished(Description description) {
+		System.out.println(description.toString());
+		description.
+	}*/
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/TrustAllTrustManager.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,38 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+public class TrustAllTrustManager implements X509TrustManager {
+	public TrustAllTrustManager() {
+	}
+
+	public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+	}
+
+	public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+	}
+
+	public X509Certificate[] getAcceptedIssuers() {
+		return new X509Certificate[] {};
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/WebIDClientKeyManager.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,61 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid;
+
+import java.net.Socket;
+import java.security.Principal;
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509ExtendedKeyManager;
+
+import org.bergnet.webid.commons.WebID;
+
+public class WebIDClientKeyManager extends X509ExtendedKeyManager {
+	private WebID webid;
+
+	public WebIDClientKeyManager(WebID webid) {
+		this.webid = webid;
+	}
+	public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) {
+		return "webid";
+	}
+
+	public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
+		return null;
+	}
+
+	public X509Certificate[] getCertificateChain(String alias) {
+		if("webid".equals(alias))
+			return new X509Certificate[] { webid.getCertificate() };
+		else
+			return null;
+	}
+
+	public String[] getClientAliases(String keyType, Principal[] issuers) {
+		return new String[] { "webid" };
+	}
+
+	public PrivateKey getPrivateKey(String alias) {
+		return webid.getPrivateKey();
+	}
+
+	public String[] getServerAliases(String keyType, Principal[] issuers) {
+		return new String[] {};
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/WebIDTestException.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,43 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid;
+
+
+public class WebIDTestException extends Exception {
+	private static final long serialVersionUID = 8911644953461327714L;
+
+	private String message;
+	private Throwable throwable;
+
+	public WebIDTestException(String message) {
+		this.message = message;
+	}
+
+	public WebIDTestException(String message, Throwable throable) {
+		this.message = message;
+		this.throwable = throable;
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public Throwable getThrowable() {
+		return throwable;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/WebIDTests.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,325 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Properties;
+
+import org.bergnet.test.EarlJunitRunListener;
+import org.bergnet.test.EarlTestCriterionRDFBuilder;
+import org.bergnet.test.webid.publishers.FOAFPublisher;
+import org.junit.runner.JUnitCore;
+
+
[email protected]("rawtypes")
+public class WebIDTests {
+	public static final String DEFAULT_CONFIG = "default.properties";
+	public static final String OPTION_CONFIG = "config";
+	public static final String OPTION_CRITERIONS = "criterions";
+	public static final String OPTION_OUTPUT_FORMAT = "outputformat";
+	public static final String OPTION_ENDPOINT = "endpoint";
+	public static final String OPTION_BASEURL = "baseurl";
+	public static final String OPTION_STAY_ALIVE = "stayalive";
+
+	private static WebIDTests instance = null;
+
+	private Config config = null;
+	private Date startDate = new Date();
+	private String outputFolder = null;
+	private FOAFPublisher publisher = null;
+
+	private WebIDTests() throws WebIDTestException {
+		config = new Config(DEFAULT_CONFIG);
+		config.check();
+	}
+
+	private WebIDTests(String configFileName) throws WebIDTestException {
+		config = new Config(configFileName);
+	}
+
+	public static WebIDTests getInstance() throws WebIDTestException {
+		if(instance == null)
+			instance = new WebIDTests();
+
+		return instance;
+	}
+
+	public void setConfig(Config config) {
+		this.config = config;
+	}
+
+	public Config getConfig() {
+		return config;
+	}
+
+	public Date getStartDate() {
+		return startDate;
+	}
+
+	public String getOutputFolder() throws WebIDTestException {
+		if(outputFolder == null) {
+			try {
+				SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+				outputFolder = dateFormat.format(getInstance().getStartDate());
+				File outputFolderFile = new File(outputFolder);
+				outputFolderFile.mkdir();
+			} catch(Exception e) {
+				throw new WebIDTestException("Can't create output folder", e);
+			}
+		}
+
+		return outputFolder;
+	}
+
+	public FOAFPublisher getPublisher() throws WebIDTestException {
+		if(publisher == null) {
+			try {
+				String publisherClassName = config.getPublisherClassName();
+
+				if(publisherClassName == null)
+					throw new WebIDTestException("No publisher class defined");
+
+				Constructor publisherConstructor = Class.forName(publisherClassName).getConstructor(new Class[]{Config.class});
+				publisher = (FOAFPublisher)publisherConstructor.newInstance(config);
+			} catch(Exception e) {
+				throw new WebIDTestException("Can't create publisher object", e);
+			}
+		}
+
+		return publisher;
+	}
+
+	public static void main(String[] args) throws Exception {
+		String configFileName = DEFAULT_CONFIG;
+		boolean criterions = false;
+		String outputFormat = "RDF/XML";
+		URL endpoint = null;
+		URL baseUrl = null;
+		boolean stayAlive = false;
+
+		int argIndex = 0;
+
+		while(args.length > argIndex) {
+			String arg = args[argIndex];
+
+			if(!arg.startsWith("-"))
+				continue;
+
+			arg = arg.substring(1);
+
+			if(OPTION_CONFIG.equals(arg)) {
+				configFileName = args[++argIndex];
+			} else if(OPTION_CRITERIONS.equals(arg)) {
+				criterions = true;
+			} else if(OPTION_OUTPUT_FORMAT.equals(arg)) {
+				outputFormat = args[++argIndex];
+
+				if(!"RDF/XML".equals(outputFormat) && !"TTL".equals(outputFormat))
+					throw new WebIDTestException("Valid values for outputformat: RDF/XML, TTL");
+			} else if(OPTION_ENDPOINT.equals(arg)) {
+				endpoint = new URL(args[++argIndex]);
+			} else if(OPTION_BASEURL.equals(arg)) {
+				baseUrl = new URL(args[++argIndex]);
+			} else if(OPTION_STAY_ALIVE.equals(arg)) {
+				stayAlive = true;
+			} else {
+				throw new WebIDTestException("Unknown paramter: " + arg);
+			}
+
+			argIndex++;
+		}
+
+		instance = new WebIDTests(configFileName);
+
+		if(endpoint != null)
+			instance.getConfig().setEndpoints(new URL[]{endpoint});
+
+		if(baseUrl != null)
+			instance.getConfig().setBaseUrl(baseUrl);
+
+		if(stayAlive)
+			instance.getConfig().setStayAlive(stayAlive);
+
+		instance.getConfig().check();
+
+		Class[] testClasses = instance.getTestClasses();
+
+		if(!criterions) {
+			instance.runTests(testClasses, outputFormat);
+		} else {
+			instance.buildCriterions(testClasses, outputFormat);
+		}
+	}
+
+	private void runTests(Class[] testClasses, String outputFormat) throws WebIDTestException {
+		JUnitCore junitCore = new JUnitCore();
+
+		EarlJunitRunListener earlJunitListener = new EarlJunitRunListener();
+		junitCore.addListener(earlJunitListener);
+
+		for(URL endpoint : getInstance().getConfig().getEndpoints()) {
+			getInstance().getConfig().setEndpoint(endpoint);
+			earlJunitListener.setSubject(endpoint.toString());
+
+			for(Class testClass : testClasses) {
+				if(instance.getConfig().isDebugEnabled())
+					System.err.println("start test: " + testClass.getSimpleName());
+					
+				junitCore.run(testClass);
+			}
+		}
+
+		if(!getInstance().getConfig().getStayAlive())
+			getInstance().getPublisher().stop();
+
+		earlJunitListener.getModel().write(System.out, outputFormat);
+	}
+
+	private void buildCriterions(Class[] testClasses, String outputFormat) throws WebIDTestException {
+		EarlTestCriterionRDFBuilder.build(testClasses).write(System.out, outputFormat);
+	}
+
+	private Class[] getTestClasses() throws Exception {
+		String[] testClassNames = config.getTestClassNames();
+
+		ArrayList<Class> testClasses = new ArrayList<Class>();
+
+		for(String testClassName : testClassNames)
+			testClasses.add(Class.forName(testClassName));
+
+		return testClasses.toArray(new Class[]{});
+	}
+
+	public static class Config {
+		public static final String PROPERTY_BASE_URL = "org.bergnet.commons.test.webid.publish.baseUrl";
+		public static final String PROPERTY_ENDPOINT = "org.bergnet.commons.test.webid.endpoint";
+		public static final String PROPERTY_DEBUG = "org.bergnet.commons.test.webid.debug";
+		public static final String PROPERTY_PUBLISHER_CLASS = "org.bergnet.commons.test.webid.publish.class";
+		public static final String PROPERTY_TEST_CLASSES = "org.bergnet.commons.test.webid.testclasses";
+		public static final String PROPERTY_STAY_ALIVE = "org.bergnet.test.webid.stayalive";
+
+		private Properties properties = null;
+		private URL endpoint = null;
+
+		public Config(String fileName) throws WebIDTestException {
+			try {
+				properties = new Properties();
+				properties.load(new FileInputStream(fileName));
+			} catch(Exception e) {
+				throw new WebIDTestException("Can't load properties from file");
+			}
+		}
+
+		public void check() throws WebIDTestException {
+			if(getBaseUrl() == null)
+				throw new WebIDTestException("Base url not defined");
+
+			if(getEndpoints() == null || getEndpoints().length == 0)
+				throw new WebIDTestException("No endpoinds defined");
+
+			if(getPublisherClassName() == null)
+				throw new WebIDTestException("No publisher defined");
+		}
+
+		public Properties getProperties() {
+			return properties;
+		}
+
+		public boolean isDebugEnabled() {
+			String debug = properties.getProperty(PROPERTY_DEBUG);
+
+			return ("true".equals(debug));
+		}
+
+		public void setBaseUrl(URL baseUrl) {
+			properties.setProperty(PROPERTY_BASE_URL, baseUrl.toString());
+		}
+
+		public URL getBaseUrl() {
+			try {
+				return new URL(properties.getProperty(PROPERTY_BASE_URL));
+			} catch(Exception e) {}
+
+			return null;
+		}
+
+		public void setEndpoints(URL[] endpoints) {
+			String endpointsString = null;
+
+			for(URL endpoint : endpoints) {
+				if(endpointsString == null)
+					endpointsString = endpoint.toString();
+				else
+					endpointsString += "," + endpoint.toString();
+			}
+
+			properties.setProperty(PROPERTY_ENDPOINT, endpointsString);
+		}
+
+		public URL[] getEndpoints() {
+			try {
+				String[] endpointStrings = properties.getProperty(PROPERTY_ENDPOINT).split(",");
+				URL[] endpoints = new URL[endpointStrings.length];
+
+				for(int i=0; i<endpointStrings.length; i++)
+					endpoints[i] = new URL(endpointStrings[i]);
+
+				return endpoints;
+			} catch(Exception e) {}
+
+			return null;
+		}
+
+		public void setEndpoint(URL endpoint) {
+			this.endpoint = endpoint;
+		}
+
+		public URL getEndpoint() {
+			if(endpoint == null) {
+				URL[] endpoints = getEndpoints();
+
+				if(endpoints.length > 0)
+				endpoint = endpoints[0];
+			}
+
+			return endpoint;
+		}
+
+		public String getPublisherClassName() {
+			return properties.getProperty(PROPERTY_PUBLISHER_CLASS);
+		}
+
+		public String[] getTestClassNames() {
+			return properties.getProperty(PROPERTY_TEST_CLASSES).split(",");
+		}
+
+		public void setStayAlive(boolean stayAlive) {
+			properties.setProperty(PROPERTY_STAY_ALIVE, stayAlive ? "true" : "false");
+		}
+
+		public boolean getStayAlive() {
+			return ("true".equals(properties.getProperty(PROPERTY_STAY_ALIVE)));
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/XsdAnyUriDatatype.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,24 @@
+package org.bergnet.test.webid;
+
+import com.hp.hpl.jena.datatypes.BaseDatatype;
+import com.hp.hpl.jena.datatypes.TypeMapper;
+
+
+public class XsdAnyUriDatatype extends BaseDatatype {
+	public static final String URI = "http://www.w3.org/2001/XMLSchema#anyURI";
+
+	private static XsdAnyUriDatatype instance = null;
+
+	private XsdAnyUriDatatype() {
+		super(URI);
+	}
+
+	public static XsdAnyUriDatatype getInstance() {
+		if(instance == null) {
+			instance = new XsdAnyUriDatatype();
+			TypeMapper.getInstance().registerDatatype(instance);			
+		}
+
+		return instance;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/publishers/FOAFPublisher.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,14 @@
+package org.bergnet.test.webid.publishers;
+
+import java.net.URL;
+
+import org.bergnet.test.webid.WebIDTestException;
+
+
+public interface FOAFPublisher {
+	public void stop() throws WebIDTestException;
+
+	public URL getBaseUrl();
+
+	public void publish(String id, String foaf, String contentType) throws WebIDTestException;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/publishers/FileFOAFPublisher.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,42 @@
+package org.bergnet.test.webid.publishers;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.net.URL;
+
+import org.bergnet.test.webid.WebIDTestException;
+import org.bergnet.test.webid.WebIDTests;
+
+
+public class FileFOAFPublisher implements FOAFPublisher {
+	public static final String PROPERTY_BASE_PATH = "org.bergnet.commons.test.webid.publish.filepublisher.basePath";
+
+	private String basePath;
+	private URL baseUrl;
+
+	public FileFOAFPublisher(WebIDTests.Config configuration) throws WebIDTestException {
+		basePath = configuration.getProperties().get(PROPERTY_BASE_PATH).toString();
+
+		if(basePath == null)
+			throw new WebIDTestException("Base path not defined");
+
+		baseUrl = configuration.getBaseUrl();
+	}
+
+	public void stop() throws WebIDTestException {
+	}
+
+	public URL getBaseUrl() {
+		return baseUrl;
+	}
+
+	public void publish(String id, String foaf, String contentType) throws WebIDTestException {
+		try {
+			BufferedWriter writer = new BufferedWriter(new FileWriter(this.basePath + id));
+			writer.write(foaf);
+			writer.close();
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't write FOAF file", e);
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/publishers/JettyFOAFPublisher.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,94 @@
+package org.bergnet.test.webid.publishers;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.URL;
+import java.util.HashMap;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.bergnet.test.webid.WebIDTestException;
+import org.bergnet.test.webid.WebIDTests;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+
+
+public class JettyFOAFPublisher implements FOAFPublisher {
+	Server server = null;
+	EmbeddedServer embeddedServer = null;
+	URL baseUrl = null;
+
+	public JettyFOAFPublisher(WebIDTests.Config configuration) throws WebIDTestException {
+		try {
+			baseUrl = configuration.getBaseUrl();
+			InetSocketAddress socketAddress = new InetSocketAddress(baseUrl.getHost(), baseUrl.getPort());
+			server = new Server(socketAddress);
+			embeddedServer = new EmbeddedServer();
+			server.setHandler(embeddedServer);
+			server.start();
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't start Jetty WebServer");
+		}
+
+		/*try {
+			InetAddress inetAddress = InetAddress.getLocalHost();
+			String hostName = inetAddress.getHostName();
+			//baseUrl = "http://" + hostname + ":8080/";
+		} catch (Exception e) {
+			throw new WebIDTestException("Can't resolv own hostname");
+		}*/
+	}
+
+	public void stop() throws WebIDTestException {
+		try {
+			server.stop();
+		} catch(Exception e) {}
+	}
+
+	public URL getBaseUrl() {
+		return baseUrl;
+	}
+
+	public void publish(String id, String foaf, String contentType) throws WebIDTestException {
+		embeddedServer.setContent(baseUrl + id, foaf, contentType);
+	}
+
+	private static class EmbeddedServer extends AbstractHandler {
+		HashMap<String, String> contentMap = new HashMap<String, String>();
+		HashMap<String, String> contentTypeMap = new HashMap<String, String>();
+
+		public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+			String url = getRequestUrl(request);
+			String content = contentMap.get(url);
+			String contentType = contentTypeMap.get(url);
+
+			if(content != null) {
+				response.setStatus(200);
+				response.setContentType(contentType);
+				response.getWriter().write(content);
+			} else {
+				response.setStatus(404);
+			}
+
+			baseRequest.setHandled(true);
+		}
+
+		public void setContent(String uri, String content, String contentType) {
+			contentMap.put(uri, content);
+			contentTypeMap.put(uri, contentType);
+		}
+
+		private String getRequestUrl(HttpServletRequest request) {
+			String scheme = request.getScheme();
+			String serverName = request.getServerName();
+			String serverPort = (scheme == "http" && request.getServerPort() == 80 ? "" : (scheme == "https" && request.getServerPort() == 443 ? "" : ":" + request.getServerPort()));
+			String path = request.getRequestURI();
+
+			return scheme + "://" + serverName + serverPort + path;
+		}
+	}
+}
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/testcases/AbstractTestCase.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,243 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid.testcases;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.StringReader;
+import java.lang.reflect.Method;
+import java.net.URL;
+
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.util.EntityUtils;
+import org.bergnet.test.EarlTestCase;
+import org.bergnet.test.webid.WebIDTestException;
+import org.bergnet.test.webid.WebIDTests;
+import org.bergnet.test.webid.XsdAnyUriDatatype;
+import org.bergnet.webid.commons.CryptoUtils;
+import org.bergnet.webid.commons.FOAFBuilder;
+import org.bergnet.webid.commons.WebID;
+import org.bergnet.webid.commons.WebIDHttpClient;
+import org.junit.Test;
+
+import com.hp.hpl.jena.query.Query;
+import com.hp.hpl.jena.query.QueryExecution;
+import com.hp.hpl.jena.query.QueryExecutionFactory;
+import com.hp.hpl.jena.query.QueryFactory;
+import com.hp.hpl.jena.query.QuerySolutionMap;
+import com.hp.hpl.jena.rdf.model.Model;
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+
+
+public abstract class AbstractTestCase {
+	public static final String PROPERTY_KEY_SIZE = "org.bergnet.commons.test.webid.keySize";
+
+	protected int keySize;
+	protected URL endpoint;
+
+	protected String id = null;
+	protected String fragment = "#me";
+
+	protected WebID webid = null;
+	protected String foaf = null;
+	protected URL baseUrl = null;
+	protected String output = null;
+	protected String outputFormat = null;
+	protected String verificationQuery = null;
+	protected QuerySolutionMap verificationVariables = new QuerySolutionMap();
+	protected boolean result = false;
+
+	protected void init() throws WebIDTestException {
+		String keySizeString = WebIDTests.getInstance().getConfig().getProperties().getProperty(PROPERTY_KEY_SIZE);
+
+		if(keySizeString == null)
+			throw new WebIDTestException("Key size not defined");
+
+		keySize = Integer.parseInt(keySizeString);
+
+		endpoint = WebIDTests.getInstance().getConfig().getEndpoint();
+
+		if(id != null) {
+			String webid = getFullUrl(id + fragment);
+
+			verificationVariables.add("webid", ResourceFactory.createResource(webid));
+			verificationVariables.add("webidString", ResourceFactory.createTypedLiteral(webid, XsdAnyUriDatatype.getInstance()));
+		}
+	}
+
+	public WebID generateWebID() throws WebIDTestException {
+		try {
+			webid = WebID.generate(keySize, getFullUrl(id + fragment), WebID.createDeltaDate(-1), WebID.createDeltaDate(1));;
+
+			CryptoUtils.writePemFile(webid, getOutputFolder() + "/webid.pem");
+
+			return webid; 
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't generate WebID", e);
+		}
+	}
+
+	public String buildFOAF() throws WebIDTestException {
+		try {
+			foaf = FOAFBuilder.build(webid, FOAFBuilder.FORMAT_RDF_XML);
+
+			dump("foaf.rdf", foaf);
+
+			return foaf;
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't build FOAF file", e);
+		}
+	}
+
+	public void publishFOAF() throws WebIDTestException {
+		WebIDTests.getInstance().getPublisher().publish(id, foaf, FOAFBuilder.FORMAT_RDF_XML);
+	}
+
+	public String login() throws WebIDTestException {
+		try {
+			int port = (endpoint.getPort() != -1 ? endpoint.getPort() : 443);
+
+			WebIDHttpClient httpClient = new WebIDHttpClient(webid, port);
+
+			try {
+				HttpGet httpGet = new HttpGet(endpoint.toString());
+				httpGet.setHeader("Accept", "application/rdf+xml,text/turtle,text/n3;q=0.9,*/*;q=0.1");
+
+				HttpResponse response = httpClient.execute(httpGet);
+
+				outputFormat = "RDF/XML";
+
+				for(Header contentType : response.getHeaders("Content-Type")) {
+					if("text/n3".equals(contentType.getValue()))
+						outputFormat = "N3";
+					else if("text/turtle".equals(contentType.getValue()))
+						outputFormat = "TTL";
+				}
+
+				// TODO: handle redirects
+				baseUrl = endpoint;
+
+				output = EntityUtils.toString(response.getEntity());
+			} finally {
+				httpClient.getConnectionManager().shutdown();
+			}
+
+			dump("response.txt", output);		
+		} catch(Exception e) {
+			throw new WebIDTestException("Error during login", e);
+		}
+
+		return output;
+	}
+
+	public boolean verifyOutput() throws WebIDTestException {
+		try {
+			Model model = ModelFactory.createDefaultModel();
+			model.read(new StringReader(output), baseUrl.toString(), outputFormat);
+
+			Query query = QueryFactory.create(verificationQuery);
+			
+			QueryExecution queryExecution = QueryExecutionFactory.create(query, model, verificationVariables);
+
+			return result = queryExecution.execAsk();
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't verify output", e);
+		}
+	}
+
+	protected String getFullUrl(String file) throws WebIDTestException {
+		 return WebIDTests.getInstance().getPublisher().getBaseUrl() + file;
+	}
+
+	protected String getTestCaseShortName() throws WebIDTestException {
+		try {
+			return new URL(getEarlTestCase().url()).getRef();
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't find test case short name", e);
+		}
+	}
+
+	protected String getOutputFolder() throws WebIDTestException {
+		String baseOutputFolder = WebIDTests.getInstance().getOutputFolder();
+		String shortName = getTestCaseShortName();
+		String outputFolder = baseOutputFolder + "/" + shortName;
+
+		File outputFolderFile = new File(outputFolder);
+
+		if(!outputFolderFile.exists())
+			outputFolderFile.mkdir();
+
+		return outputFolder;
+	}
+
+	protected void dump(String fileName, String content) throws WebIDTestException {
+		try {
+			String outputFolder = getOutputFolder();
+
+			FileWriter writer = new FileWriter(outputFolder + "/" + fileName);
+			writer.write(content);
+			writer.close();
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't dump debug file", e);
+		}
+	}
+
+	private EarlTestCase getEarlTestCase() {
+		Method method = getTestMethod();
+
+		if(method != null && method.isAnnotationPresent(EarlTestCase.class))
+			return method.getAnnotation(EarlTestCase.class);
+
+		return null;
+	}
+
+	private Method getTestMethod() {
+		int index = 0; 
+
+		StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+
+		while(index < stackTraceElements.length && !isTestMethod(stackTraceElements[index]))
+			index++;
+
+		String className = stackTraceElements[index].getClassName();
+		String methodName = stackTraceElements[index].getMethodName();
+
+		try {
+			return Class.forName(className).getMethod(methodName);
+		} catch(Exception e) {}
+
+		return null;
+	}
+
+	private boolean isTestMethod(String className, String methodName) {
+		try {
+			Method method = Class.forName(className).getMethod(methodName);
+
+			return method.isAnnotationPresent(Test.class);
+		} catch(Exception e) {}
+
+		return false;
+	}
+
+	private boolean isTestMethod(StackTraceElement stackTraceElement) {
+		return isTestMethod(stackTraceElement.getClassName(), stackTraceElement.getMethodName());
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/testcases/MissingFOAF.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,56 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid.testcases;
+
+import org.bergnet.test.EarlTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class MissingFOAF extends AbstractTestCase {
+	public MissingFOAF() throws Exception {
+		id = "missingfoaf.rdf";
+		verificationQuery = "PREFIX earl: <http://www.w3.org/ns/earl#>\n" +
+				"PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>\n" +
+				"ASK WHERE {\n" +
+				"	?profileGetAssertion\n" +
+				"		earl:test wit:profileGet;\n" +
+				"		earl:result ?profileGetResult;\n" +
+				"		earl:subject ?webid.\n" +
+				"	?profileGetResult earl:outcome earl:failed.\n" +
+				"	?webidAuthenticationAssertion\n" +
+				"		earl:test wit:webidAuthentication;\n" +
+				"		earl:result ?webidAuthenticationResult.\n" +
+				"	?webidAuthenticationResult earl:outcome earl:failed }";
+
+		init();
+	}
+
+	@EarlTestCase(
+			url="http://www.w3.org/2005/Incubator/webid/earl/TestSuite#missingFoaf",
+			title="Does the endpoint detect a missing FOAF file?",
+			description="Use a valid certificate and private key for authentication, but don't publish the FOAF file 404 http error).")
+	@Test
+	public void test() throws Exception {
+		generateWebID();
+		login();
+		verifyOutput();
+
+		Assert.assertTrue(result);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/testcases/MultipleURIs.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,107 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid.testcases;
+
+import java.util.ArrayList;
+
+import org.bergnet.test.EarlTestCase;
+import org.bergnet.test.webid.WebIDTestException;
+import org.bergnet.test.webid.WebIDTests;
+import org.bergnet.test.webid.XsdAnyUriDatatype;
+import org.bergnet.webid.commons.CryptoUtils;
+import org.bergnet.webid.commons.FOAFBuilder;
+import org.bergnet.webid.commons.WebID;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
+
+
+public class MultipleURIs extends AbstractTestCase {
+	private String[] ids; 
+			
+	public MultipleURIs() throws Exception {
+		init();
+
+		ids = new String[] {"multipleuris1.rdf", "multipleuris2.rdf"};
+		verificationQuery = "PREFIX earl: <http://www.w3.org/ns/earl#>\n" +
+				"PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>\n" +
+				"ASK WHERE {\n" +
+				"	?webidClaimAssertion1\n" +
+				"		earl:test wit:webidClaim;\n" +
+				"		earl:result ?webidClaimResult1;\n" +
+				"		earl:subject ?webidClaimSubject1.\n" +
+				"	?webidClaimResult1 earl:outcome earl:passed.\n" +
+				"	?webidClaimSubject1 wit:claimedIdentity ?webid1String.\n" +
+				"	?webidClaimAssertion2\n" +
+				"		earl:test wit:webidClaim;\n" +
+				"		earl:result ?webidClaimResult2;\n" +
+				"		earl:subject ?webidClaimSubject2.\n" +
+				"	?webidClaimResult2 earl:outcome earl:passed.\n" +
+				"	?webidClaimSubject2 wit:claimedIdentity ?webid2String.\n" +
+				"	?webidAuthenticationAssertion\n" +
+				"		earl:test wit:webidAuthentication;\n" +
+				"		earl:result ?webidAuthenticationResult.\n" +
+				"	?webidAuthenticationResult earl:outcome earl:passed }";
+
+		verificationVariables.clear();
+		verificationVariables.add("webid1String", ResourceFactory.createTypedLiteral(getFullUrl(ids[0] + fragment), XsdAnyUriDatatype.getInstance()));		
+		verificationVariables.add("webid2String", ResourceFactory.createTypedLiteral(getFullUrl(ids[1] + fragment), XsdAnyUriDatatype.getInstance()));
+	}
+
+	public WebID generateWebID() throws WebIDTestException {		
+		try {
+			ArrayList<String> uriArray = new ArrayList<String>();
+
+			for(String id : ids)
+				uriArray.add(getFullUrl(id + "#me"));
+
+			webid = WebID.generate(keySize, uriArray.toArray(new String[] {}),  WebID.createDeltaDate(-1), WebID.createDeltaDate(1));
+
+			CryptoUtils.writePemFile(webid, getOutputFolder() + "/webid.pem");
+
+			return webid;
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't generate WebID", e);
+		}
+	}
+
+	public void publishFOAF() throws WebIDTestException {
+		try {
+			for(String id : ids)
+				WebIDTests.getInstance().getPublisher().publish(id, foaf, FOAFBuilder.FORMAT_RDF_XML);
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't publish foaf file");
+		}
+	}
+
+	@EarlTestCase(
+			url="http://www.w3.org/2005/Incubator/webid/earl/TestSuite#multipleUris",
+			title="Does the endpoint support multiple URIs?",
+			description="Creates a WebID with multiple URIs and publishes FOAF files for all URIs.")
+	@Test
+	public void test() throws Exception {
+		generateWebID();
+		buildFOAF();
+		publishFOAF();
+		login();
+		verifyOutput();
+
+		Assert.assertTrue(result);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/testcases/Simple.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,57 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid.testcases;
+
+import org.bergnet.test.EarlTestCase;
+import org.bergnet.test.webid.WebIDTestException;
+import org.junit.Test;
+
+
+public class Simple extends AbstractTestCase {
+	public Simple() throws Exception {
+		id = "simple.rdf";
+		verificationQuery = "PREFIX earl: <http://www.w3.org/ns/earl#>\n" +
+				"PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>\n" +
+				"ASK WHERE {\n" +
+				"	?webidAuthenticationAssertion\n" +
+				"		earl:test wit:webidAuthentication;\n" +
+				"		earl:result ?webidAuthenticationResult.\n" +
+				"	?webidAuthenticationResult\n" +
+				"		earl:outcome earl:passed;\n" +
+				"		earl:pointer ?webidClaim.\n" +
+				"	?webidClaim wit:claimedIdentity ?webidString }";
+
+		init();
+	}
+
+	@EarlTestCase(
+			url="http://www.w3.org/2005/Incubator/webid/earl/TestSuite#simple",
+			title="Simple authentication works?",
+			description="Simple test using RDF/XML FOAF and single URI.")
+	@Test
+	public void test() throws Exception {
+		generateWebID();
+		buildFOAF();
+		publishFOAF();
+		login();
+		verifyOutput();
+
+		if(!this.result)
+			throw new WebIDTestException("Error during simpled authentication test");
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/testcases/SimpleTurtle.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,75 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid.testcases;
+
+import org.bergnet.test.EarlTestCase;
+import org.bergnet.test.webid.WebIDTestException;
+import org.bergnet.test.webid.WebIDTests;
+import org.bergnet.webid.commons.FOAFBuilder;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class SimpleTurtle extends AbstractTestCase {
+	public SimpleTurtle() throws Exception {
+		id = "simple.ttl";
+		verificationQuery = "PREFIX earl: <http://www.w3.org/ns/earl#>\n" +
+				"PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>\n" +
+				"ASK WHERE {\n" +
+				"	?webidAuthenticationAssertion\n" +
+				"		earl:test wit:webidAuthentication;\n" +
+				"		earl:result ?webidAuthenticationResult.\n" +
+				"	?webidAuthenticationResult\n" +
+				"		earl:outcome earl:passed;\n" +
+				"		earl:pointer ?webidClaim.\n" +
+				"	?webidClaim wit:claimedIdentity ?webidString }";
+
+		init();
+	}
+
+	public String buildFOAF() throws WebIDTestException {
+		try {
+			foaf = FOAFBuilder.build(this.webid, FOAFBuilder.FORMAT_TURTLE);
+
+			dump("foaf.ttl", foaf);
+
+			return foaf;
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't build FOAF file", e);
+		}
+	}
+
+	public void publishFOAF() throws WebIDTestException {
+		WebIDTests.getInstance().getPublisher().publish(id, foaf, FOAFBuilder.FORMAT_TURTLE);
+	}
+
+	@EarlTestCase(
+			url="http://www.w3.org/2005/Incubator/webid/earl/TestSuite#simpleTurtle",
+			title="Simple authentication with turtle FOAF file works?",
+			description="Simple test using Turtle FOAF and single URI")
+	@Test
+	public void test() throws Exception {
+		generateWebID();
+		buildFOAF();
+		publishFOAF();
+		login();
+		verifyOutput();
+
+		Assert.assertTrue(result);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/testcases/WrongModulus.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,74 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid.testcases;
+
+import java.math.BigInteger;
+
+import org.bergnet.test.EarlTestCase;
+import org.bergnet.test.webid.WebIDTestException;
+import org.bergnet.webid.commons.FOAFBuilder;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class WrongModulus extends AbstractTestCase {
+	public WrongModulus() throws Exception {
+		init();
+
+		id = "wrongmodulus.rdf";
+		verificationQuery = "PREFIX earl: <http://www.w3.org/ns/earl#>\n" +
+				"PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>\n" +
+				"ASK WHERE {\n" +
+				"	?webidClaimAssertion\n" +
+				"		earl:test wit:webidClaim;\n" +
+				"		earl:result ?webidClaimResult;\n" +
+				"		earl:subject ?webidClaimSubject.\n" +
+				"	?webidClaimResult earl:outcome earl:failed.\n" +
+				"	?webidClaimSubject wit:claimedIdentity ?webidString.\n" +
+				"	?webidAuthenticationAssertion\n" +
+				"		earl:test wit:webidAuthentication;\n" +
+				"		earl:result ?webidAuthenticationResult.\n" +
+				"	?webidAuthenticationResult earl:outcome earl:failed }";
+	}
+
+	public String buildFOAF() throws WebIDTestException {
+		try {
+			foaf = FOAFBuilder.build(webid.getUris(), webid.getModulus().add(new BigInteger("1")), webid.getPublicExponent(), FOAFBuilder.FORMAT_RDF_XML);
+
+			dump("foaf.rdf", foaf);
+
+			return foaf;
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't build FOAF file", e);
+		}
+	}
+
+	@EarlTestCase(
+			url="http://www.w3.org/2005/Incubator/webid/earl/TestSuite#wrongModulus",
+			title="Does the endpoint compare the modulus of the certificate and FOAF file?",
+			description="Use a valid certificate and private key for authentication, but add 1 to the modulus in published FOAF file.")
+	@Test
+	public void test() throws Exception {
+		generateWebID();
+		buildFOAF();
+		publishFOAF();
+		login();
+		verifyOutput();
+
+		Assert.assertTrue(result);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/test/webid/testcases/WrongPublicExponent.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,75 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.test.webid.testcases;
+
+import java.math.BigInteger;
+
+import org.bergnet.test.EarlTestCase;
+import org.bergnet.test.webid.WebIDTestException;
+import org.bergnet.webid.commons.FOAFBuilder;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class WrongPublicExponent extends AbstractTestCase {
+	public WrongPublicExponent() throws Exception {
+		init();
+
+		id = "wrongpublicexponent.rdf";
+		verificationQuery = "PREFIX earl: <http://www.w3.org/ns/earl#>\n" +
+				"PREFIX wit: <http://www.w3.org/2005/Incubator/webid/earl/RelyingParty#>\n" +
+				"ASK WHERE {\n" +
+				"	?webidClaimAssertion\n" +
+				"		earl:test wit:webidClaim;\n" +
+				"		earl:result ?webidClaimResult;\n" +
+				"		earl:subject ?webidClaimSubject.\n" +
+				"	?webidClaimResult earl:outcome earl:failed.\n" +
+				"	?webidClaimSubject wit:claimedIdentity ?webidString.\n" +
+				"	?webidAuthenticationAssertion\n" +
+				"		earl:test wit:webidAuthentication;\n" +
+				"		earl:result ?webidAuthenticationResult.\n" +
+				"	?webidAuthenticationResult earl:outcome earl:failed }";
+	}
+
+	public String buildFOAF() throws WebIDTestException {
+		try {
+			foaf = FOAFBuilder.build(webid.getUris(), webid.getModulus(), webid.getPublicExponent().add(new BigInteger("1")), FOAFBuilder.FORMAT_RDF_XML);
+
+			dump("foaf.rdf", foaf);
+
+			return foaf;
+		} catch(Exception e) {
+			throw new WebIDTestException("Can't build FOAF file", e);
+		}
+	}
+
+	@EarlTestCase(
+			url="http://www.w3.org/2005/Incubator/webid/earl/TestSuite#wrongPublicExponent",
+			title="Does the endpoint compare the public exponent of the certificate and FOAF file?",
+			description="Use a valid certificate and private key for authentication, but add 1 to the public exponent in published FOAF file.")
+	@Test
+	public void test() throws Exception {
+		generateWebID();
+		buildFOAF();
+		publishFOAF();
+		login();
+		verifyOutput();
+
+		Assert.assertTrue(result);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/webid/commons/CryptoUtils.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,89 @@
+package org.bergnet.webid.commons;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.security.Key;
+import java.security.KeyStore;
+import java.security.PrivateKey;
+import java.security.Security;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+
+import org.bouncycastle.jce.provider.X509CertParser;
+import org.bouncycastle.openssl.PEMWriter;
+
+public class CryptoUtils {
+	public static void writePemFile(WebID webid, String fileName) throws WebIDException {
+		try {
+			FileWriter fileWriter = new FileWriter(fileName);
+			PEMWriter pemWriter = new PEMWriter(fileWriter);
+
+			pemWriter.writeObject(webid.getCertificate());
+			pemWriter.writeObject(webid.getPrivateKey());
+
+			pemWriter.close();
+			fileWriter.close();
+		} catch(Exception e) {
+			throw new WebIDException("Can't write WebID to PEM file", e);
+		}
+	}
+
+	public static void writePkcs12File(WebID webid, String fileName, String alias, String password) throws WebIDException {
+		try {
+			KeyStore.Builder ksBuilder = KeyStore.Builder.newInstance("PKCS12", Security.getProvider("BC"), new KeyStore.PasswordProtection(password.toCharArray()));
+			KeyStore ks = ksBuilder.getKeyStore();
+
+			ks.setKeyEntry(alias, webid.getPrivateKey(), password.toCharArray(), new Certificate[] { webid.getCertificate() });
+
+			FileOutputStream fileOutputStream = new FileOutputStream(fileName);
+			ks.store(fileOutputStream, password.toCharArray());
+			fileOutputStream.close();
+		} catch(Exception e) {
+			throw new WebIDException("Can't write WebID to PKCS12 file", e);
+		}
+	}
+
+	public static WebID readPkcs12File(String fileName, String alias, String password) throws WebIDException {
+		try {
+			KeyStore ks = KeyStore.getInstance("PKCS12");
+
+			FileInputStream fileInputStream = new FileInputStream(fileName);
+			ks.load(fileInputStream, password.toCharArray());
+			fileInputStream.close();
+
+			if(alias == null) {
+				if(ks.aliases().hasMoreElements())
+					alias = ks.aliases().nextElement();
+				else
+					throw new WebIDException("Can't find an alias");
+			}
+
+			Key key = ks.getKey(alias, password.toCharArray());
+			Certificate certificate = ks.getCertificate(alias);
+
+			if(key instanceof PrivateKey && certificate instanceof X509Certificate)
+				return new WebID((PrivateKey)key, (X509Certificate)certificate);
+			else
+				return null;
+		} catch(Exception e) {
+			throw new WebIDException("Can't read WebID from PKCS12 file", e);
+		}
+	}
+
+	public static X509Certificate readX509File(String fileName) throws WebIDException {
+		try {
+			X509CertParser certParser = new X509CertParser();
+			certParser.engineInit(new FileInputStream(fileName));
+
+			Object X509Object = certParser.engineRead();
+
+			if(X509Object instanceof X509Certificate)
+				return (X509Certificate)X509Object;
+			else
+				throw new WebIDException("File doesn't contain a X509 certificate");
+		} catch(Exception e) {
+			throw new WebIDException("Can't read X509 certificate from file", e);
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/webid/commons/FOAFBuilder.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,73 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.webid.commons;
+
+import java.math.BigInteger;
+
+public class FOAFBuilder {
+	public static final String FORMAT_RDF_XML = "application/rdf+xml";
+	public static final String FORMAT_TURTLE = "text/turtle";
+
+	public static String build(WebID webid, String format) throws WebIDException {
+		return build(webid.getUris(), webid.getModulus(), webid.getPublicExponent(), format);
+	}
+
+	public static String build(String[] uris, BigInteger modulus, BigInteger publicExponent, String format) {
+		if(FORMAT_TURTLE.equals(format))
+			return buildTurtle(uris, modulus, publicExponent);
+		else
+			return buildRdfXml(uris, modulus, publicExponent);
+	}
+
+	public static String buildRdfXml(String[] uris, BigInteger modulus, BigInteger publicExponent) {
+		StringBuilder rdfStringBuilder = new StringBuilder();
+
+		rdfStringBuilder.append("<rdf:RDF xmlns:cert=\"http://www.w3.org/ns/auth/cert#\" xmlns:foaf=\"http://xmlns.com/foaf/0.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:rsa=\"http://www.w3.org/ns/auth/rsa#\">\n");
+		rdfStringBuilder.append("<rsa:RSAPublicKey>\n");
+		rdfStringBuilder.append("<rsa:modulus rdf:datatype=\"http://www.w3.org/ns/auth/cert#hex\">" + modulus.toString(16) + "</rsa:modulus>\n");
+		rdfStringBuilder.append("<rsa:public_exponent rdf:datatype=\"http://www.w3.org/ns/auth/cert#decimal\">" + publicExponent.toString(10) + "</rsa:public_exponent>\n");
+
+		for(String uri : uris)
+			rdfStringBuilder.append("<cert:identity rdf:resource=\"" + uri + "\" />\n");
+
+		rdfStringBuilder.append("</rsa:RSAPublicKey>\n");
+		rdfStringBuilder.append("</rdf:RDF>");
+
+		return rdfStringBuilder.toString();
+	}
+	
+	public static String buildTurtle(String[] uris, BigInteger modulus, BigInteger publicExponent) {
+		StringBuilder rdfStringBuilder = new StringBuilder();
+
+		rdfStringBuilder.append("@prefix cert: <http://www.w3.org/ns/auth/cert#>.\n");
+		rdfStringBuilder.append("@prefix rsa: <http://www.w3.org/ns/auth/rsa#>.\n");
+		rdfStringBuilder.append("\n");
+		rdfStringBuilder.append("[] a rsa:RSAPublicKey;\n");
+		rdfStringBuilder.append("\trsa:modulus \"" + modulus.toString(16) + "\"^^cert:hex;\n");
+		rdfStringBuilder.append("\trsa:public_exponent \"" + publicExponent.toString(10) + "\"^^cert:int;\n");
+
+		for(int i=0; i<uris.length; i++) {
+			if(i != uris.length-1)
+				rdfStringBuilder.append("\tcert:identity <" + uris[i] + ">;\n");
+			else
+				rdfStringBuilder.append("\tcert:identity <" + uris[i] + ">.\n");
+		}
+
+		return rdfStringBuilder.toString();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/webid/commons/WebID.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,188 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.webid.commons;
+
+import java.math.BigInteger;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PrivateKey;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.cert.CertificateParsingException;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.RSAPublicKey;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import javax.security.auth.x500.X500Principal;
+
+import org.bouncycastle.asn1.ASN1Encodable;
+import org.bouncycastle.asn1.DERSequence;
+import org.bouncycastle.asn1.x509.GeneralName;
+import org.bouncycastle.asn1.x509.GeneralNames;
+import org.bouncycastle.asn1.x509.X509Extensions;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.x509.X509V3CertificateGenerator;
+
+
+public class WebID {
+	private PrivateKey privateKey;
+	private X509Certificate certificate;
+	private ArrayList<String> uris;
+
+	@SuppressWarnings("rawtypes")
+	public WebID(PrivateKey privateKey, X509Certificate certificate) throws WebIDException {
+		this.privateKey = privateKey;
+		this.certificate = certificate;
+		this.uris = new ArrayList<String>();
+
+		try {
+			for(Object sanObject : certificate.getSubjectAlternativeNames()) {
+				if(sanObject instanceof List && ((List)sanObject).size() >= 2) {				
+					List sanObjectList = (List)sanObject;
+
+					if(sanObjectList.get(0).equals(GeneralName.uniformResourceIdentifier))
+						this.uris.add(sanObjectList.get(1).toString());
+				}
+			}
+		} catch(CertificateParsingException e) {
+			throw new WebIDException("Couldn't read SubjectAlternativeNames", e);
+		}
+	}
+
+	public PrivateKey getPrivateKey() {
+		return privateKey;
+	}
+
+	public X509Certificate getCertificate() {
+		return certificate;
+	}
+
+	public String[] getUris() {
+		return uris.toArray(new String[]{});
+	}
+
+	public BigInteger getModulus() {
+		if(!(this.certificate.getPublicKey() instanceof RSAPublicKey))
+			return null;
+
+		RSAPublicKey rsaPublicKey = (RSAPublicKey)this.certificate.getPublicKey();
+
+		return rsaPublicKey.getModulus();
+	}
+
+	public BigInteger getPublicExponent() {
+		if(!(this.certificate.getPublicKey() instanceof RSAPublicKey))
+			return null;
+
+		RSAPublicKey rsaPublicKey = (RSAPublicKey)this.certificate.getPublicKey();
+
+		return rsaPublicKey.getPublicExponent();
+	}
+	
+	public static KeyPair generateRsaKeyPair(int keySize) throws WebIDException {
+		initBouncyCastleProvider();
+
+		KeyPairGenerator keyPairGenerator;
+
+		try {
+			keyPairGenerator = KeyPairGenerator.getInstance("RSA", "BC");
+		} catch (Exception e) {
+			throw new WebIDException("Couldn't access rsa key pair generator", e);
+		}
+
+		keyPairGenerator.initialize(keySize, new SecureRandom());
+
+		return keyPairGenerator.generateKeyPair();		
+	}
+
+	public static WebID generate(KeyPair keyPair, String[] uris, Date validFrom, Date validTill) throws WebIDException {
+		initBouncyCastleProvider();
+
+		X509V3CertificateGenerator certificateGenerator = new X509V3CertificateGenerator();
+
+		certificateGenerator.setSerialNumber(BigInteger.valueOf(validFrom.getTime()));
+		certificateGenerator.setIssuerDN(new X500Principal("CN=Me"));
+		certificateGenerator.setNotBefore(validFrom);
+		certificateGenerator.setNotAfter(validTill);
+		certificateGenerator.setSubjectDN(new X500Principal("CN=Me"));
+		certificateGenerator.setPublicKey(keyPair.getPublic());
+		certificateGenerator.setSignatureAlgorithm("SHA256WithRSAEncryption");
+
+		ArrayList<ASN1Encodable> sanList = new ArrayList<ASN1Encodable>();
+
+		for(String uri : uris)
+			sanList.add(new GeneralName(GeneralName.uniformResourceIdentifier, uri));
+		
+	    try {
+	    	/*certificateGenerator.addExtension(
+	    			X509Extensions.BasicConstraints,
+	    			true,
+	    			new BasicConstraints(false));
+	    	certificateGenerator.addExtension(
+	    			X509Extensions.KeyUsage,
+	    			true,
+	    			new KeyUsage(KeyUsage.cRLSign | KeyUsage.digitalSignature | KeyUsage.keyAgreement | KeyUsage.keyEncipherment | KeyUsage.nonRepudiation));
+	    	certificateGenerator.addExtension(
+	    			MiscObjectIdentifiers.netscapeCertType,
+	    			true,
+	    			new NetscapeCertType(NetscapeCertType.smime | NetscapeCertType.sslClient));
+	    	certificateGenerator.addExtension(
+	    			X509Extensions.SubjectKeyIdentifier,
+	    			true,
+	    			new SubjectKeyIdentifierStructure(keyPair.getPublic()));*/
+	    	/*certificateGenerator.addExtension(
+	    			X509Extensions.SubjectAlternativeName,
+	    			true,
+	    			new GeneralNames(new GeneralName(GeneralName.uniformResourceIdentifier, uriStringBuffer.toString())));*/
+
+	    	certificateGenerator.addExtension(
+	    			X509Extensions.SubjectAlternativeName,
+	    			true,
+	    			new GeneralNames(new DERSequence(sanList.toArray(new ASN1Encodable[]{}))));
+
+			return new WebID(keyPair.getPrivate(), certificateGenerator.generate(keyPair.getPrivate(), new SecureRandom()));
+		} catch (Exception e) {
+			throw new WebIDException("Couldn't generate x509 certificate", e);
+		}
+	}
+
+	public static WebID generate(int keySize, String[] uris, Date validFrom, Date validTill) throws WebIDException {
+		KeyPair keyPair = generateRsaKeyPair(keySize);
+
+		return generate(keyPair, uris, validFrom, validTill);
+	}
+
+	public static WebID generate(int keySize, String uri, Date validFrom, Date validTill) throws WebIDException {
+		return generate(keySize, new String[] { uri }, validFrom, validTill);
+	}
+
+	public static Date createDeltaDate(int days) {
+		Calendar calendar = Calendar.getInstance();
+		calendar.add(Calendar.DAY_OF_YEAR, days);
+
+		return calendar.getTime();
+	}
+
+	private static void initBouncyCastleProvider() {
+		if(Security.getProvider("BC") == null)
+			Security.addProvider(new BouncyCastleProvider());
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/webid/commons/WebIDException.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,30 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.webid.commons;
+
+public class WebIDException extends Exception {
+	private static final long serialVersionUID = 8804176764383614796L;
+
+	public WebIDException(String message) {
+		super(message);
+	}
+
+	public WebIDException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/webid/commons/WebIDHttpClient.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,62 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.webid.commons;
+
+import java.security.SecureRandom;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.ssl.AllowAllHostnameVerifier;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.bergnet.test.webid.TrustAllTrustManager;
+import org.bergnet.test.webid.WebIDClientKeyManager;
+
+
+public class WebIDHttpClient extends DefaultHttpClient {
+	public WebIDHttpClient(WebID webid) throws WebIDException {
+		init(webid, 443);
+	}
+
+	public WebIDHttpClient(WebID webid, int port) throws WebIDException {
+		init(webid, port);
+	}
+
+	private void init(WebID webid, int port) throws WebIDException {
+		try {
+			SSLContext sslContext = SSLContext.getInstance("TLS");
+			sslContext.init(
+					new KeyManager[] { new WebIDClientKeyManager(webid) },
+					new TrustManager[] { new TrustAllTrustManager() }, // TODO: built in X509 trust manager and configure CAs
+					new SecureRandom());
+
+			//TODO: verifier
+			//SSLSocketFactory sslSocketFactory = new SSLSocketFactory(sslContext);
+			SSLSocketFactory sslSocketFactory = new SSLSocketFactory(sslContext, new AllowAllHostnameVerifier());
+
+			Scheme scheme = new Scheme("https", port, sslSocketFactory);
+			getConnectionManager().getSchemeRegistry().register(scheme);
+			//this.getConnectionManager().
+		} catch(Exception e) {
+			throw new WebIDException("error during initialization of WebIDHttpClient", e);
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/webid/commons/WebIDTool.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,114 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.webid.commons;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Date;
+
+
+public class WebIDTool {
+	public static final String OPTION_ALIAS = "alias";
+	public static final String OPTION_GENERATE = "generate";
+	public static final String OPTION_IN = "in";
+	public static final String OPTION_KEY_SIZE = "keysize";
+	public static final String OPTION_MAX_AGE = "maxage";
+	public static final String OPTION_OUT = "out";
+	public static final String OPTION_OUT_FOAF = "outfoaf";
+	public static final String OPTION_PASSWORD = "password";
+	public static final String OPTION_URIS = "uris";
+
+
+	public static void writeFoafFile(WebID webid, String fileName, String format) throws WebIDException {
+		try {
+			FileWriter fileWriter = new FileWriter(fileName);
+			fileWriter.write(FOAFBuilder.build(webid, format));
+			fileWriter.close();
+		} catch (IOException e) {
+			throw new WebIDException("Couldn't write FOAF file", e);
+		}
+	}
+
+	public static void main(String[] args) throws Exception {
+		String alias = null;
+		boolean generate = false;
+		String in = null;
+		int keySize = 1024;
+		int maxAge = 365;
+		String out = null;
+		String outFoaf = null;
+		String password = null;
+		String uris[] = null;
+		String foafFormat = FOAFBuilder.FORMAT_RDF_XML;
+
+		WebID webid = null;
+
+		int argIndex = 0;
+
+		while(args.length > argIndex) {
+			String arg = args[argIndex];
+
+			if(!arg.startsWith("-"))
+				continue;
+
+			arg = arg.substring(1);
+
+			if(OPTION_ALIAS.equals(arg)) {
+				alias = args[++argIndex];
+			} else if(OPTION_GENERATE.equals(arg)) {
+				generate = true;
+			} else if(OPTION_IN.equals(arg)) {
+				in = args[++argIndex];
+			} else if(OPTION_KEY_SIZE.equals(arg)) {
+				keySize = Integer.valueOf(args[++argIndex], 10);
+			} else if(OPTION_MAX_AGE.equals(arg)) {
+				maxAge = Integer.valueOf(args[++argIndex], 10);
+			} else if(OPTION_OUT.equals(arg)) {
+				out = args[++argIndex];
+			} else if(OPTION_OUT_FOAF.equals(arg)) {
+				outFoaf = args[++argIndex];
+			} else if(OPTION_PASSWORD.equals(arg)) {
+				password = args[++argIndex];
+			} else if(OPTION_URIS.equals(arg)) {
+				uris = args[++argIndex].split(",");
+			} else {
+				throw new Exception("unknown paramter: " + arg);
+			}
+
+			argIndex++;
+		}
+		
+		if(generate) {
+			webid = WebID.generate(keySize, uris, new Date(), WebID.createDeltaDate(maxAge));
+		} else if(in != null) {
+			webid = CryptoUtils.readPkcs12File(in, alias, password);
+		} else {
+			WebIDToolSwingGUI.main(new String[] {});
+		}
+
+		if(webid != null && out != null)
+			CryptoUtils.writePkcs12File(webid, out, alias, password);
+
+		if(webid != null && outFoaf != null) {
+			if(uris != null && uris.length > 0)
+				writeFoafFile(webid, outFoaf, foafFormat);
+			else
+				writeFoafFile(webid, outFoaf, foafFormat);
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/code/src/main/java/org/bergnet/webid/commons/WebIDToolSwingGUI.java	Fri Nov 18 19:55:30 2011 +0100
@@ -0,0 +1,387 @@
+/**
+ * test-webid
+ * Copyright (C) 2011 Thomas Bergwinkl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.bergnet.webid.commons;
+
+import java.awt.EventQueue;
+
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.JPasswordField;
+import javax.swing.JButton;
+import javax.swing.JTextField;
+import javax.swing.JTextPane;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.filechooser.FileFilter;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.swing.border.EtchedBorder;
+import javax.swing.JComboBox;
+import javax.swing.DefaultComboBoxModel;
+
+
+public class WebIDToolSwingGUI implements ActionListener {
+	private JFrame frameWebIDTool;
+	private JButton buttonCreateWebid = new JButton("Create WebID");
+	private JButton buttonSaveFoaf = new JButton("Save FOAF");
+	private JButton buttonOpenPkcs12 = new JButton("Open PKCS12");
+	private JButton buttonSavePkcs12 = new JButton("Save PKCS12");
+	private JButton buttonClear = new JButton("Clear");
+	private JTextField textFieldWebID = new JTextField();
+	private JTextPane textPaneModulus = new JTextPane();
+	private JTextField textFieldPublicExponent = new JTextField();
+	private JComboBox comboBoxKeySize = new JComboBox();
+	private JTextField textFieldValidFrom;
+	private JTextField textFieldValidTill;
+	private JComboBox comboBoxFoafFormat = new JComboBox();
+
+	private WebID webid = null;
+
+	/**
+	 * Launch the application.
+	 */
+	public static void main(String[] args) {
+		EventQueue.invokeLater(new Runnable() {
+			public void run() {
+				try {
+					WebIDToolSwingGUI window = new WebIDToolSwingGUI();
+					window.frameWebIDTool.setVisible(true);
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+		});
+	}
+
+	/**
+	 * Create the application.
+	 */
+	public WebIDToolSwingGUI() {
+		initialize();
+	}
+
+	/**
+	 * Initialize the contents of the frame.
+	 */
+	private void initialize() {
+		frameWebIDTool = new JFrame();
+		frameWebIDTool.setResizable(false);
+		frameWebIDTool.setTitle("WebIDTool");
+		frameWebIDTool.setBounds(100, 100, 469, 746);
+		frameWebIDTool.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+		frameWebIDTool.getContentPane().setLayout(null);
+
+		JLayeredPane panelButtons = new JLayeredPane();
+		panelButtons.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
+		panelButtons.setBounds(10, 11, 440, 84);
+
+		frameWebIDTool.getContentPane().add(panelButtons);
+		panelButtons.setLayout(null);
+		buttonCreateWebid.setBounds(10, 11, 130, 23);
+		panelButtons.add(buttonCreateWebid);
+		
+		buttonCreateWebid.addActionListener(this);
+		buttonSaveFoaf.setBounds(150, 11, 130, 23);
+		panelButtons.add(buttonSaveFoaf);
+		buttonSaveFoaf.addActionListener(this);
+		buttonOpenPkcs12.setBounds(10, 45, 130, 23);
+		panelButtons.add(buttonOpenPkcs12);
+		buttonOpenPkcs12.addActionListener(this);
+		buttonSavePkcs12.setBounds(150, 45, 130, 23);
+		panelButtons.add(buttonSavePkcs12);
+
+		buttonClear.setBounds(290, 45, 130, 23);
+		panelButtons.add(buttonClear);
+		buttonSavePkcs12.addActionListener(this);
+		buttonClear.addActionListener(this);
+		
+		JLayeredPane panePublicKey = new JLayeredPane();
+		panePublicKey.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
+		panePublicKey.setBounds(10, 342, 440, 365);
+		frameWebIDTool.getContentPane().add(panePublicKey);
+		panePublicKey.setLayout(null);
+				
+		JLabel labelModulus = new JLabel("Modulus");
+		labelModulus.setBounds(10, 11, 100, 30);
+		panePublicKey.add(labelModulus);
+		textPaneModulus.setEditable(false);
+		textPaneModulus.setBounds(120, 11, 300, 302);
+		panePublicKey.add(textPaneModulus);
+		
+		JLabel labelPublicExponent = new JLabel("Public Exponent");
+		labelPublicExponent.setBounds(10, 324, 100, 30);
+		panePublicKey.add(labelPublicExponent);
+		textFieldPublicExponent.setEditable(false);
+		textFieldPublicExponent.setBounds(120, 324, 300, 30);
+		panePublicKey.add(textFieldPublicExponent);
+		
+		JLayeredPane paneWebID = new JLayeredPane();
+		paneWebID.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
+		paneWebID.setBounds(10, 277, 440, 54);
+		frameWebIDTool.getContentPane().add(paneWebID);
+		
+		JLabel labelWebid = new JLabel("WebID");
+		labelWebid.setBounds(10, 11, 100, 30);
+		paneWebID.add(labelWebid);
+		textFieldWebID.setBounds(120, 11, 300, 30);
+		paneWebID.add(textFieldWebID);
+		textFieldWebID.setText("http://");
+		textFieldWebID.setColumns(10);
+
+		JLayeredPane paneKey = new JLayeredPane();
+		paneKey.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
+		paneKey.setBounds(10, 106, 167, 54);
+		frameWebIDTool.getContentPane().add(paneKey);
+
+		JLabel labelKeySize = new JLabel("Key Size");
+		labelKeySize.setBounds(10, 11, 70, 30);
+
+		paneKey.add(labelKeySize);
+
+		comboBoxKeySize.setModel(new DefaultComboBoxModel(new String[] {"1024", "2048", "4096"}));
+		comboBoxKeySize.setBounds(90, 11, 65, 30);
+		paneKey.add(comboBoxKeySize);
+
+		JLayeredPane paneValidDate = new JLayeredPane();
+		paneValidDate.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
+		paneValidDate.setBounds(10, 171, 440, 95);
+		frameWebIDTool.getContentPane().add(paneValidDate);
+
+		JLabel labelValidFrom = new JLabel("Valid from");
+		labelValidFrom.setBounds(10, 11, 100, 30);		
+		paneValidDate.add(labelValidFrom);
+
+		textFieldValidFrom = new JTextField();
+		textFieldValidFrom.setColumns(10);
+		textFieldValidFrom.setBounds(120, 11, 300, 30);
+		paneValidDate.add(textFieldValidFrom);
+		
+		JLabel labelValidTill = new JLabel("Valid Till");
+		labelValidTill.setBounds(10, 52, 100, 30);
+		paneValidDate.add(labelValidTill);
+		
+		textFieldValidTill = new JTextField();
+		textFieldValidTill.setColumns(10);
+		textFieldValidTill.setBounds(120, 52, 300, 30);
+		paneValidDate.add(textFieldValidTill);
+		
+		JLayeredPane paneFoafFormat = new JLayeredPane();
+		paneFoafFormat.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
+		paneFoafFormat.setBounds(187, 106, 263, 54);
+		frameWebIDTool.getContentPane().add(paneFoafFormat);
+		
+		JLabel labelFoafFormat = new JLabel("FOAF Format");
+		labelFoafFormat.setBounds(10, 11, 80, 30);
+		paneFoafFormat.add(labelFoafFormat);
+
+		comboBoxFoafFormat.setModel(new DefaultComboBoxModel(new String[] {"application/rdf+xml", "text/turtle"}));
+		comboBoxFoafFormat.setBounds(93, 11, 160, 30);
+		paneFoafFormat.add(comboBoxFoafFormat);
+
+		setWebId(null);
+	}
+
+	public void actionPerformed(ActionEvent event) {
+		try {
+			if(event.getSource() == buttonCreateWebid)
+				createWebid();
+			else if(event.getSource() == buttonSaveFoaf)
+				saveFoaf();
+			else if(event.getSource() == buttonOpenPkcs12)
+				openPkcs12();
+			else if(event.getSource() == buttonSavePkcs12)
+				savePkcs12();
+			else if(event.getSource() == buttonClear)
+				setWebId(null);
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public void createWebid() throws Exception {
+		int keySize = Integer.parseInt(comboBoxKeySize.getSelectedItem().toString(), 10);
+
+		String[] uris = textFieldWebID.getText().split(",");
+
+		Date validFrom = getDateFormat().parse(textFieldValidFrom.getText());
+		Date validTill = getDateFormat().parse(textFieldValidTill.getText());
+
+		setWebId(WebID.generate(keySize, uris, validFrom, validTill));
+	}
+
+	public void saveFoaf() throws Exception {
+		FileFilter filter = new FileExtensionFilter(new String[] {"rdf", "ttl"});
+		JFileChooser fileChooser = new JFileChooser();
+
+		fileChooser.setFileFilter(filter);
+
+		if(fileChooser.showSaveDialog(frameWebIDTool) == JFileChooser.APPROVE_OPTION) {
+			String fileName = fileChooser.getSelectedFile().getAbsolutePath();
+			String format = comboBoxFoafFormat.getSelectedItem().toString();
+
+			WebIDTool.writeFoafFile(webid, fileName, format);
+		}
+	}
+
+	public void openPkcs12() throws Exception {
+		FileFilter filter = new FileExtensionFilter(new String[] {"p12"});
+		JFileChooser fileChooser = new JFileChooser();
+
+		fileChooser.setFileFilter(filter);
+
+		if(fileChooser.showOpenDialog(frameWebIDTool) == JFileChooser.APPROVE_OPTION) {
+			String fileName = fileChooser.getSelectedFile().getAbsolutePath();
+			String password = passwordPopup();
+
+			setWebId(CryptoUtils.readPkcs12File(fileName, null, password));
+		}
+	}
+
+	public void savePkcs12() throws Exception {
+		FileFilter filter = new FileExtensionFilter(new String[] {"p12"});
+		JFileChooser fileChooser = new JFileChooser();
+
+		fileChooser.setFileFilter(filter);
+
+		if(fileChooser.showSaveDialog(frameWebIDTool) == JFileChooser.APPROVE_OPTION) {
+			String fileName = fileChooser.getSelectedFile().getAbsolutePath();
+			String password = passwordPopup();
+
+			CryptoUtils.writePkcs12File(webid, fileName, "webid", password);
+		}
+	}
+
+	public void setWebId(WebID webid) {
+		this.webid = webid;
+
+		if(webid == null) {
+			// WebID TextField
+			textFieldWebID.setEditable(true);
+			textFieldWebID.setText("http://");
+
+			// Valid From TextField
+			textFieldValidFrom.setEditable(true);
+			Date now = new Date();
+			textFieldValidFrom.setText(getDateFormat().format(now));
+
+			// Valid Till TextField
+			textFieldValidTill.setEditable(true);
+			textFieldValidTill.setText(getDateFormat().format(WebID.createDeltaDate(365)));
+
+			// Key Size ComboBox
+			comboBoxKeySize.setEditable(true);
+			comboBoxKeySize.setSelectedIndex(1);
+
+			// Modulus TextPane
+			textPaneModulus.setText(null);
+
+			// Public Exponent TextField
+			textFieldPublicExponent.setText(null);
+		} else {
+			// WebID TextField
+			textFieldWebID.setEditable(false);
+			String uriString = null;
+			for(String uri : this.webid.getUris()) {
+				if(uriString == null)
+					uriString = uri;
+				else
+					uriString += "," + uri;
+			}
+			textFieldWebID.setText(uriString);
+
+			// Valid From TextField
+			textFieldValidFrom.setEditable(false);
+			textFieldValidFrom.setText(getDateFormat().format(this.webid.getCertificate().getNotBefore()));
+
+			// Valid Till TextField
+			textFieldValidTill.setEditable(false);
+			textFieldValidTill.setText(getDateFormat().format(this.webid.getCertificate().getNotAfter()));
+
+			// Key Size ComboBox
+			comboBoxKeySize.setEditable(false);
+			int keySizeIndex = (int)Math.floor(Math.log(webid.getModulus().bitLength())/Math.log(2.0)-9.5);
+			comboBoxKeySize.setSelectedIndex(keySizeIndex);
+
+			// Modulus TextPane
+			textPaneModulus.setText(this.webid.getModulus().toString(16));
+
+			// Public Exponent TextField
+			textFieldPublicExponent.setText(this.webid.getPublicExponent().toString(10));
+		}
+	}
+
+	public static String passwordPopup() {
+		JPasswordField passwordField = new JPasswordField();
+		passwordField.setEchoChar('#');
+
+		JOptionPane.showMessageDialog(null, passwordField, "Enter password", JOptionPane.OK_OPTION);
+
+		return new String(passwordField.getPassword());
+	}
+
+	public static DateFormat getDateFormat() {
+		return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
+	}
+
+	private class FileExtensionFilter extends FileFilter {
+		private String[] extensions;
+
+		public FileExtensionFilter(String[] extensions) {
+			this. extensions = extensions;
+		}
+
+		public boolean accept(File file) {
+			if (file.isDirectory())
+				return true;
+
+			String currentExtension = getFileExtension(file.getName());
+
+		    if(currentExtension != null) {
+		    	for(String extension : this.extensions) {
+		    		if(extension.equals(currentExtension))
+		    			return true;
+		    		else
+		    			return false;
+		    	}
+		    }
+
+		    return false;
+		}
+	
+		private String getFileExtension(String fileName) {
+			String extension = null;
+			int i = fileName.lastIndexOf('.');
+
+			if(i>0 &&  i<fileName.length()-1)
+				extension = fileName.substring(i+1).toLowerCase();
+
+			return extension;
+		}
+
+		public String getDescription() {
+			return "FileExtensionFilter";
+		}
+	}
+}