Merge ssh://git-cacert.it-sls.de/var/cache/git/cacert-birdshack
authorMarkus Warg <mw@it-sls.de>
Mon, 23 Aug 2010 12:15:20 +0000 (14:15 +0200)
committerMarkus Warg <mw@it-sls.de>
Mon, 23 Aug 2010 12:15:20 +0000 (14:15 +0200)
32 files changed:
Business Logic/trunk/build.xml [new file with mode: 0644]
Business Logic/trunk/docs/Thoughts about API.txt [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/api/Controller.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Application.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/AssurableEntity.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/AssurableEntityVerifiable.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Assurance.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/BirdShackObject.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Credential.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Delegation.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Domain.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Email.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Event.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Member.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Name.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Notification.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Permission.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Profile.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Role.java [new file with mode: 0644]
Business Logic/trunk/src/org/cacert/birdshack/bl/model/Token.java [new file with mode: 0644]
Business Logic/trunk/webapps/ROOT/WEB-INF/web.xml [new file with mode: 0644]
TailFeather/trunk/copyright.txt [new file with mode: 0644]
TailFeather/trunk/src/bscp/Makefile [new file with mode: 0644]
TailFeather/trunk/src/bscp/comm.c [new file with mode: 0644]
TailFeather/trunk/src/bscp/comm.h [new file with mode: 0644]
TailFeather/trunk/src/bscp/crc.c [new file with mode: 0644]
TailFeather/trunk/src/bscp/crc.h [new file with mode: 0644]
TailFeather/trunk/src/bscp/packet.c [new file with mode: 0644]
TailFeather/trunk/src/bscp/packet.h [new file with mode: 0644]
TailFeather/trunk/src/bscp/recovertest.c [new file with mode: 0644]
TailFeather/trunk/src/bscp/simpletest.c [new file with mode: 0644]
TailFeather/trunk/src/bscp/stdpipe.c [new file with mode: 0644]

diff --git a/Business Logic/trunk/build.xml b/Business Logic/trunk/build.xml
new file mode 100644 (file)
index 0000000..dd912ad
--- /dev/null
@@ -0,0 +1,514 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--
+     General purpose build script for web applications and web services,
+     including enhanced support for deploying directly to a Tomcat 6
+     based server.
+
+     This build script assumes that the source code of your web application
+     is organized into the following subdirectories underneath the source
+     code directory from which you execute the build script:
+
+        docs                 Static documentation files to be copied to
+                             the "docs" subdirectory of your distribution.
+
+        src                  Java source code (and associated resource files)
+                             to be compiled to the "WEB-INF/classes"
+                             subdirectory of your web applicaiton.
+
+        web                  Static HTML, JSP, and other content (such as
+                             image files), including the WEB-INF subdirectory
+                             and its configuration file contents.
+
+     $Id: build.xml.txt 562814 2007-08-05 03:52:04Z markt $
+-->
+
+
+<!-- A "project" describes a set of targets that may be requested
+     when Ant is executed.  The "default" attribute defines the
+     target which is executed if no specific target is requested,
+     and the "basedir" attribute defines the current working directory
+     from which Ant executes the requested task.  This is normally
+     set to the current working directory.
+-->
+
+<project name="BirdShack Business Logic" default="compile" basedir=".">
+
+
+
+<!-- ===================== Property Definitions =========================== -->
+
+
+<!--
+
+  Each of the following properties are used in the build script.
+  Values for these properties are set by the first place they are
+  defined, from the following list:
+
+  * Definitions on the "ant" command line (ant -Dfoo=bar compile).
+
+  * Definitions from a "build.properties" file in the top level
+    source directory of this application.
+
+  * Definitions from a "build.properties" file in the developer's
+    home directory.
+
+  * Default definitions in this build.xml file.
+
+  You will note below that property values can be composed based on the
+  contents of previously defined properties.  This is a powerful technique
+  that helps you minimize the number of changes required when your development
+  environment is modified.  Note that property composition is allowed within
+  "build.properties" files as well as in the "build.xml" script.
+
+-->
+
+  <property file="build.properties"/>
+<!--  <property file="${user.home}/build.properties"/> -->
+
+
+<!-- ==================== File and Directory Names ======================== -->
+
+
+<!--
+
+  These properties generally define file and directory names (or paths) that
+  affect where the build process stores its outputs.
+
+  app.name             Base name of this application, used to
+                       construct filenames and directories.
+                       Defaults to "myapp".
+
+  app.path             Context path to which this application should be
+                       deployed (defaults to "/" plus the value of the
+                       "app.name" property).
+
+  app.version          Version number of this iteration of the application.
+
+  build.home           The directory into which the "prepare" and
+                       "compile" targets will generate their output.
+                       Defaults to "build".
+
+  catalina.home        The directory in which you have installed
+                       a binary distribution of Tomcat 6.  This will
+                       be used by the "deploy" target.
+
+  dist.home            The name of the base directory in which
+                       distribution files are created.
+                       Defaults to "dist".
+
+  manager.password     The login password of a user that is assigned the
+                       "manager" role (so that he or she can execute
+                       commands via the "/manager" web application)
+
+  manager.url          The URL of the "/manager" web application on the
+                       Tomcat installation to which we will deploy web
+                       applications and web services.
+
+  manager.username     The login username of a user that is assigned the
+                       "manager" role (so that he or she can execute
+                       commands via the "/manager" web application)
+
+-->
+
+  <property name="app.name"      value="bl"/>
+  <property name="app.path"      value="/"/>
+  <property name="app.version"   value="0.1-dev"/>
+  <property name="build.home"    value="${basedir}/build"/>
+  <property name="catalina.home" value="/Users/law/Downloads/apache-tomcat-6.0.18"/> <!-- UPDATE THIS! -->
+  <property name="dist.home"     value="${basedir}/dist"/>
+  <property name="docs.home"     value="${basedir}/docs"/>
+  <property name="manager.url"   value="http://localhost:8080/manager"/>
+  <property name="src.home"      value="${basedir}/src"/>
+  <property name="web.home"      value="${basedir}/webapps"/>
+
+
+<!-- ==================== External Dependencies =========================== -->
+
+
+<!--
+
+  Use property values to define the locations of external JAR files on which
+  your application will depend.  In general, these values will be used for
+  two purposes:
+  * Inclusion on the classpath that is passed to the Javac compiler
+  * Being copied into the "/WEB-INF/lib" directory during execution
+    of the "deploy" target.
+
+  Because we will automatically include all of the Java classes that Tomcat 6
+  exposes to web applications, we will not need to explicitly list any of those
+  dependencies.  You only need to worry about external dependencies for JAR
+  files that you are going to include inside your "/WEB-INF/lib" directory.
+
+-->
+
+<!-- Dummy external dependency -->
+<!--
+  <property name="foo.jar"
+           value="/path/to/foo.jar"/>
+-->
+
+
+<!-- ==================== Compilation Classpath =========================== -->
+
+<!--
+
+  Rather than relying on the CLASSPATH environment variable, Ant includes
+  features that makes it easy to dynamically construct the classpath you
+  need for each compilation.  The example below constructs the compile
+  classpath to include the servlet.jar file, as well as the other components
+  that Tomcat makes available to web applications automatically, plus anything
+  that you explicitly added.
+
+-->
+
+  <path id="compile.classpath">
+
+    <!-- Include all JAR files that will be included in /WEB-INF/lib -->
+    <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
+<!--
+    <pathelement location="${foo.jar}"/>
+-->
+
+    <!-- Include all elements that Tomcat exposes to applications -->
+    <fileset dir="${catalina.home}/bin">
+      <include name="*.jar"/>
+    </fileset>
+    <pathelement location="${catalina.home}/lib"/>
+    <fileset dir="${catalina.home}/lib">
+      <include name="*.jar"/>
+    </fileset>
+
+  </path>
+
+
+
+<!-- ================== Custom Ant Task Definitions ======================= -->
+
+
+<!--
+
+  These properties define custom tasks for the Ant build tool that interact
+  with the "/manager" web application installed with Tomcat 6.  Before they
+  can be successfully utilized, you must perform the following steps:
+
+  - Copy the file "lib/catalina-ant.jar" from your Tomcat 6
+    installation into the "lib" directory of your Ant installation.
+
+  - Create a "build.properties" file in your application's top-level
+    source directory (or your user login home directory) that defines
+    appropriate values for the "manager.password", "manager.url", and
+    "manager.username" properties described above.
+
+  For more information about the Manager web application, and the functionality
+  of these tasks, see <http://localhost:8080/tomcat-docs/manager-howto.html>.
+
+-->
+
+  <taskdef resource="org/apache/catalina/ant/catalina.tasks"
+           classpathref="compile.classpath"/>
+
+
+<!--  ==================== Compilation Control Options ==================== -->
+
+<!--
+
+  These properties control option settings on the Javac compiler when it
+  is invoked using the <javac> task.
+
+  compile.debug        Should compilation include the debug option?
+
+  compile.deprecation  Should compilation include the deprecation option?
+
+  compile.optimize     Should compilation include the optimize option?
+
+-->
+
+  <property name="compile.debug"       value="true"/>
+  <property name="compile.deprecation" value="false"/>
+  <property name="compile.optimize"    value="true"/>
+
+
+
+<!-- ==================== All Target ====================================== -->
+
+<!--
+
+  The "all" target is a shortcut for running the "clean" target followed
+  by the "compile" target, to force a complete recompile.
+
+-->
+
+  <target name="all" depends="clean,compile"
+   description="Clean build and dist directories, then compile"/>
+
+
+
+<!-- ==================== Clean Target ==================================== -->
+
+<!--
+
+  The "clean" target deletes any previous "build" and "dist" directory,
+  so that you can be ensured the application can be built from scratch.
+
+-->
+
+  <target name="clean"
+   description="Delete old build and dist directories">
+    <delete dir="${build.home}"/>
+    <delete dir="${dist.home}"/>
+  </target>
+
+
+
+<!-- ==================== Compile Target ================================== -->
+
+<!--
+
+  The "compile" target transforms source files (from your "src" directory)
+  into object files in the appropriate location in the build directory.
+  This example assumes that you will be including your classes in an
+  unpacked directory hierarchy under "/WEB-INF/classes".
+
+-->
+
+  <target name="compile" depends="prepare"
+   description="Compile Java sources">
+
+    <!-- Compile Java classes as necessary -->
+    <mkdir    dir="${build.home}/WEB-INF/classes"/>
+    <javac srcdir="${src.home}"
+          destdir="${build.home}/WEB-INF/classes"
+            debug="${compile.debug}"
+      deprecation="${compile.deprecation}"
+         optimize="${compile.optimize}">
+        <classpath refid="compile.classpath"/>
+    </javac>
+
+    <!-- Copy application resources -->
+    <copy  todir="${build.home}/WEB-INF/classes">
+      <fileset dir="${src.home}" excludes="**/*.java"/>
+    </copy>
+
+  </target>
+
+
+
+<!-- ==================== Dist Target ===================================== -->
+
+
+<!--
+
+  The "dist" target creates a binary distribution of your application
+  in a directory structure ready to be archived in a tar.gz or zip file.
+  Note that this target depends on two others:
+
+  * "compile" so that the entire web application (including external
+    dependencies) will have been assembled
+
+  * "javadoc" so that the application Javadocs will have been created
+
+-->
+
+  <target name="dist" depends="compile,javadoc"
+   description="Create binary distribution">
+
+    <!-- Copy documentation subdirectories -->
+    <mkdir   dir="${dist.home}/docs"/>
+    <copy    todir="${dist.home}/docs">
+      <fileset dir="${docs.home}"/>
+    </copy>
+
+    <!-- Create application JAR file -->
+    <jar jarfile="${dist.home}/${app.name}-${app.version}.war"
+         basedir="${build.home}"/>
+
+    <!-- Copy additional files to ${dist.home} as necessary -->
+
+  </target>
+
+
+
+<!-- ==================== Install Target ================================== -->
+
+<!--
+
+  The "install" target tells the specified Tomcat 6 installation to dynamically
+  install this web application and make it available for execution.  It does
+  *not* cause the existence of this web application to be remembered across
+  Tomcat restarts; if you restart the server, you will need to re-install all
+  this web application.
+
+  If you have already installed this application, and simply want Tomcat to
+  recognize that you have updated Java classes (or the web.xml file), use the
+  "reload" target instead.
+
+  NOTE:  This target will only succeed if it is run from the same server that
+  Tomcat is running on.
+
+  NOTE:  This is the logical opposite of the "remove" target.
+
+-->
+
+  <target name="install" depends="compile"
+   description="Install application to servlet container">
+
+    <deploy url="${manager.url}"
+       username="${manager.username}"
+       password="${manager.password}"
+           path="${app.path}"
+       localWar="file://${build.home}"/>
+
+  </target>
+
+
+<!-- ==================== Javadoc Target ================================== -->
+
+<!--
+
+  The "javadoc" target creates Javadoc API documentation for the Java
+  classes included in your application.  Normally, this is only required
+  when preparing a distribution release, but is available as a separate
+  target in case the developer wants to create Javadocs independently.
+
+-->
+
+  <target name="javadoc" depends="compile"
+   description="Create Javadoc API documentation">
+
+    <mkdir          dir="${dist.home}/docs/api"/>
+    <javadoc sourcepath="${src.home}"
+                destdir="${dist.home}/docs/api"
+           packagenames="*">
+      <classpath refid="compile.classpath"/>
+    </javadoc>
+
+  </target>
+
+
+
+<!-- ====================== List Target =================================== -->
+
+<!--
+
+  The "list" target asks the specified Tomcat 6 installation to list the
+  currently running web applications, either loaded at startup time or
+  installed dynamically.  It is useful to determine whether or not the
+  application you are currently developing has been installed.
+
+-->
+
+  <target name="list"
+   description="List installed applications on servlet container">
+
+    <list    url="${manager.url}"
+        username="${manager.username}"
+        password="${manager.password}"/>
+
+  </target>
+
+
+<!-- ==================== Prepare Target ================================== -->
+
+<!--
+
+  The "prepare" target is used to create the "build" destination directory,
+  and copy the static contents of your web application to it.  If you need
+  to copy static files from external dependencies, you can customize the
+  contents of this task.
+
+  Normally, this task is executed indirectly when needed.
+
+-->
+
+  <target name="prepare">
+
+    <!-- Create build directories as needed -->
+    <mkdir  dir="${build.home}"/>
+    <mkdir  dir="${build.home}/WEB-INF"/>
+    <mkdir  dir="${build.home}/WEB-INF/classes"/>
+
+
+    <!-- Copy static content of this web application -->
+    <copy todir="${build.home}">
+      <fileset dir="${web.home}"/>
+    </copy>
+
+    <!-- Copy external dependencies as required -->
+    <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
+    <mkdir  dir="${build.home}/WEB-INF/lib"/>
+<!--
+    <copy todir="${build.home}/WEB-INF/lib" file="${foo.jar}"/>
+-->
+
+    <!-- Copy static files from external dependencies as needed -->
+    <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
+
+  </target>
+
+
+<!-- ==================== Reload Target =================================== -->
+
+<!--
+
+  The "reload" signals the specified application Tomcat 6 to shut itself down
+  and reload. This can be useful when the web application context is not
+  reloadable and you have updated classes or property files in the
+  /WEB-INF/classes directory or when you have added or updated jar files in the
+  /WEB-INF/lib directory.
+
+  NOTE: The /WEB-INF/web.xml web application configuration file is not reread
+  on a reload. If you have made changes to your web.xml file you must stop
+  then start the web application. 
+
+-->
+
+  <target name="reload" depends="compile"
+   description="Reload application on servlet container">
+
+    <reload url="${manager.url}"
+       username="${manager.username}"
+       password="${manager.password}"
+           path="${app.path}"/>
+
+  </target>
+
+
+<!-- ==================== Remove Target =================================== -->
+
+<!--
+
+  The "remove" target tells the specified Tomcat 6 installation to dynamically
+  remove this web application from service.
+
+  NOTE:  This is the logical opposite of the "install" target.
+
+-->
+
+  <target name="remove"
+   description="Remove application on servlet container">
+
+    <undeploy url="${manager.url}"
+         username="${manager.username}"
+         password="${manager.password}"
+             path="${app.path}"/>
+
+  </target>
+
+
+</project>
diff --git a/Business Logic/trunk/docs/Thoughts about API.txt b/Business Logic/trunk/docs/Thoughts about API.txt
new file mode 100644 (file)
index 0000000..37796e9
--- /dev/null
@@ -0,0 +1,12 @@
+What to use for the API?
+========================
+ * Apache Tomcat
+ * JBOSS
+ * Use Java libraries for HTTP server
+ * Implement own HTTP server
+
+How to handle permission checking?
+==================================
+ * Only in the API
+ * Only in the business logic
+ * Distribute it over both
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/api/Controller.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/api/Controller.java
new file mode 100644 (file)
index 0000000..1ce69db
--- /dev/null
@@ -0,0 +1,552 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.api;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author law
+ * 
+ */
+public class Controller extends HttpServlet {
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 2942637779582104096L;
+       
+       private void handleRequest(HttpServletRequest req, HttpServletResponse resp, String uri)
+                       throws IOException {
+               String resource = null;
+               String id = null;
+               String function = null;
+               String args = null;
+               
+               resp.getOutputStream().println(req.getMethod()+" "+req.getRequestURI()+"?"+req.getQueryString()+"\n\n");
+
+               String splituri[] = req.getRequestURI().split("\\/", 5);
+               if(splituri.length > 1)
+                       resource = splituri[1];
+               if(splituri.length > 2)
+                       id = splituri[2];
+               if(splituri.length > 3)
+                       function = splituri[3];
+               if(splituri.length > 4)
+                       args = splituri[4];
+               
+               resp.getOutputStream().println(resource);
+               resp.getOutputStream().println(id);
+               resp.getOutputStream().println(function);
+               resp.getOutputStream().println(args);
+
+               if(resource.equals("member")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               if(function == null) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("DELETE")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(args == null) {
+                                       if(function.equals("privacy")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("PUT")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("emailaddress")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("PUT")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("assurance")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("profile")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("experience")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("role")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("credential")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("log")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("notification")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("token")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                                       }
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                               }
+                       }
+               } else if(resource.equals("profile")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(args == null) {
+                               if(function == null) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("DELETE")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("permisssion")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("email")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("credential")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("delegation")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("dob")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("PUT")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("name")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("assurance")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("credential")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("notification")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("token")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("email")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("domain")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("delegation")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("name")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("application")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function.equals("member")) {
+                               if(args == null) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else {
+                                       if(req.getMethod().equals("PUT")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("DELETE")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("event")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("role")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function != null && args == null) {
+                               if(function.equals("member")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("permission")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("permission")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("authenticate")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else {
+                       resp.sendError(HttpServletResponse.SC_NOT_FOUND, "The requested resource does not exists");
+               }
+       }
+       
+       private void handleRequest(HttpServletRequest req, HttpServletResponse resp)
+                       throws IOException {
+               handleRequest(req, resp, req.getRequestURI());
+       }
+       
+       /* (non-Javadoc)
+        * @see javax.servlet.http.HttpServlet#doDelete(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+        */
+       @Override
+       protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
+                       throws ServletException, IOException {
+               handleRequest(req, resp);
+       }
+
+       /* (non-Javadoc)
+        * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+        */
+       @Override
+       protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+                       throws ServletException, IOException {
+               handleRequest(req, resp);
+       }
+
+       /* (non-Javadoc)
+        * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+        */
+       @Override
+       protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+                       throws ServletException, IOException {
+               handleRequest(req, resp);
+       }
+
+       /* (non-Javadoc)
+        * @see javax.servlet.http.HttpServlet#doPut(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+        */
+       @Override
+       protected void doPut(HttpServletRequest req, HttpServletResponse resp)
+                       throws ServletException, IOException {
+               handleRequest(req, resp);
+       }
+
+
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Application.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Application.java
new file mode 100644 (file)
index 0000000..4bba8d9
--- /dev/null
@@ -0,0 +1,28 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Application extends AssurableEntity {
+       String desc;
+
+       /**
+        * @return the desc
+        */
+       public String getDesc() {
+               return desc;
+       }
+
+       /**
+        * @param desc the desc to set
+        */
+       protected Application setDesc(String desc) {
+               this.desc = desc;
+               return this;
+       }
+       
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/AssurableEntity.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/AssurableEntity.java
new file mode 100644 (file)
index 0000000..f4434a7
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+import java.util.List;
+
+/**
+ * @author law
+ *
+ */
+public abstract class AssurableEntity extends BirdShackObject {
+       private String name;
+       public AssurableEntity() {
+               super();
+       }
+       
+       public static List<AssurableEntity> list() {
+               return null;
+       }
+       
+       /**
+        * @return the name
+        */
+       public String getName() {
+               return name;
+       }
+       /**
+        * @param name the name to set
+        */
+       protected AssurableEntity setName(String name) {
+               this.name = name;
+               return this;
+       }
+       
+       
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/AssurableEntityVerifiable.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/AssurableEntityVerifiable.java
new file mode 100644 (file)
index 0000000..03834c0
--- /dev/null
@@ -0,0 +1,27 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public abstract class AssurableEntityVerifiable extends AssurableEntity {
+       private String status;
+
+       /**
+        * @return the status
+        */
+       public String getStatus() {
+               return status;
+       }
+
+       /**
+        * @param status the status to set
+        */
+       public AssurableEntityVerifiable setStatus(String status) {
+               this.status = status;
+               return this;
+       }
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Assurance.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Assurance.java
new file mode 100644 (file)
index 0000000..3060721
--- /dev/null
@@ -0,0 +1,126 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+import java.util.List;
+
+
+/**
+ * @author law
+ *
+ */
+public class Assurance extends BirdShackObject {
+       private int assurancePoints;
+       private int experiencePoints;
+       private String date;
+       private String location;
+       private Member from;
+       private Member to;
+       
+       public static List<Assurance> list() {
+               return null;
+       }
+       
+       /**
+        * 
+        */
+       public Assurance() {
+               // TODO Auto-generated constructor stub
+       }
+       
+       protected Assurance revoke() {
+               return this;
+       }
+
+       /**
+        * @return the assurancePoints
+        */
+       public int getAssurancePoints() {
+               return assurancePoints;
+       }
+
+       /**
+        * @param assurancePoints the assurancePoints to set
+        */
+       protected Assurance setAssurancePoints(int assurancePoints) {
+               this.assurancePoints = assurancePoints;
+               return this;
+       }
+
+       /**
+        * @return the experiencePoints
+        */
+       public int getExperiencePoints() {
+               return experiencePoints;
+       }
+
+       /**
+        * @param experiencePoints the experiencePoints to set
+        */
+       protected Assurance setExperiencePoints(int experiencePoints) {
+               this.experiencePoints = experiencePoints;
+               return this;
+       }
+
+       /**
+        * @return the date
+        */
+       public String getDate() {
+               return date;
+       }
+
+       /**
+        * @param date the date to set
+        */
+       protected Assurance setDate(String date) {
+               this.date = date;
+               return this;
+       }
+
+       /**
+        * @return the location
+        */
+       public String getLocation() {
+               return location;
+       }
+
+       /**
+        * @param location the location to set
+        */
+       protected Assurance setLocation(String location) {
+               this.location = location;
+               return this;
+       }
+
+       /**
+        * @return the from
+        */
+       public Member getFrom() {
+               return from;
+       }
+
+       /**
+        * @param from the from to set
+        */
+       protected Assurance setFrom(Member from) {
+               this.from = from;
+               return this;
+       }
+
+       /**
+        * @return the to
+        */
+       public Member getTo() {
+               return to;
+       }
+
+       /**
+        * @param to the to to set
+        */
+       protected Assurance setTo(Member to) {
+               this.to = to;
+               return this;
+       }
+
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/BirdShackObject.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/BirdShackObject.java
new file mode 100644 (file)
index 0000000..5a79c43
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+import java.util.List;
+
+
+/**
+ * @author law
+ * Generic Object where all other are derived from
+ */
+public abstract class BirdShackObject {
+       private String id;
+       
+       /**
+        * @return the id
+        */
+       public String getId() {
+               return id;
+       }
+
+       /**
+        * @param id the id to set
+        */
+       public void setId(String id) {
+               this.id = id;
+       }
+
+       public List<Event> getEvents() {
+               return null;
+       }
+       
+       protected BirdShackObject addEvent(Event event) {
+               return this;
+       }
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Credential.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Credential.java
new file mode 100644 (file)
index 0000000..371d145
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Credential extends BirdShackObject {
+       private String type;
+       private String content;
+       
+       /**
+        * @return the type
+        */
+       public String getType() {
+               return type;
+       }
+
+       /**
+        * @param type the type to set
+        */
+       protected Credential setType(String type) {
+               this.type = type;
+               return this;
+       }
+
+       /**
+        * @return the content
+        */
+       public String getContent() {
+               return content;
+       }
+
+       /**
+        * @param content the content to set
+        */
+       protected Credential setContent(String content) {
+               this.content = content;
+               return this;
+       }
+
+       /**
+        * 
+        */
+       public Credential() {
+               // TODO Auto-generated constructor stub
+       }
+
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Delegation.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Delegation.java
new file mode 100644 (file)
index 0000000..01d9a2f
--- /dev/null
@@ -0,0 +1,41 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Delegation extends BirdShackObject {
+       private String comment;
+       private boolean revoked;
+       /**
+        * @return the comment
+        */
+       public String getComment() {
+               return comment;
+       }
+       /**
+        * @param comment the comment to set
+        */
+       protected Delegation setComment(String comment) {
+               this.comment = comment;
+               return this;
+       }
+       /**
+        * @return the revoked
+        */
+       public boolean isRevoked() {
+               return revoked;
+       }
+       /**
+        * @param revoked the revoked to set
+        */
+       protected Delegation setRevoked(boolean revoked) {
+               this.revoked = revoked;
+               return this;
+       }
+       
+       
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Domain.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Domain.java
new file mode 100644 (file)
index 0000000..8ac06ef
--- /dev/null
@@ -0,0 +1,12 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Domain extends AssurableEntityVerifiable {
+
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Email.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Email.java
new file mode 100644 (file)
index 0000000..6d93669
--- /dev/null
@@ -0,0 +1,12 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Email extends AssurableEntityVerifiable {
+
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Event.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Event.java
new file mode 100644 (file)
index 0000000..67dd40a
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Event extends BirdShackObject {
+       private String type;
+       private String reference;
+       private String date;
+       private String desc;
+       /**
+        * @return the type
+        */
+       public String getType() {
+               return type;
+       }
+       /**
+        * @param type the type to set
+        */
+       protected Event setType(String type) {
+               this.type = type;
+               return this;
+       }
+       /**
+        * @return the reference
+        */
+       public String getReference() {
+               return reference;
+       }
+       /**
+        * @param reference the reference to set
+        */
+       protected Event setReference(String reference) {
+               this.reference = reference;
+               return this;
+       }
+       /**
+        * @return the date
+        */
+       public String getDate() {
+               return date;
+       }
+       /**
+        * @param date the date to set
+        */
+       protected Event setDate(String date) {
+               this.date = date;
+               return this;
+       }
+       /**
+        * @return the desc
+        */
+       public String getDesc() {
+               return desc;
+       }
+       /**
+        * @param desc the desc to set
+        */
+       protected Event setDesc(String desc) {
+               this.desc = desc;
+               return this;
+       }
+       
+       
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Member.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Member.java
new file mode 100644 (file)
index 0000000..4c8a49b
--- /dev/null
@@ -0,0 +1,128 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+import java.util.List;
+
+
+/**
+ * @author law
+ * Object for the member
+ */
+public class Member extends BirdShackObject {
+       private boolean privacy;
+       private boolean terminated;
+       private Email email;
+       
+       public static List<Member> list() {
+               return null;
+       }
+       
+       public Member() {
+               
+       }
+       
+       /**
+        * @return the privacy
+        */
+       public boolean isPrivacy() {
+               return privacy;
+       }
+       /**
+        * @param privacy the privacy to set
+        */
+       protected Member setPrivacy(boolean privacy) {
+               this.privacy = privacy;
+               return this;
+       }
+       /**
+        * @return the terminated
+        */
+       public boolean isTerminated() {
+               return terminated;
+       }
+       /**
+        * @param terminated the terminated to set
+        */
+       protected Member setTerminated(boolean terminated) {
+               this.terminated = terminated;
+               return this;
+       }
+       
+       public Email getEmail() {
+               return email;
+       }
+       
+       protected Member setEmail() {
+               return this;
+       }
+       
+       public List<Delegation> getDelegations() {
+               return null;
+       }
+       
+       public List<Assurance> getAssurances() {
+               return null;
+       }
+       
+       public int getAssurancePoints() {
+               return 0;
+       }
+       
+       protected Member addAssurance(Assurance assurance) {
+               return this;
+       }
+       
+       public List<Profile> getProfiles() {
+               return null;    
+       }
+       
+       public List<Token> getReceivedTokens() {
+               return null;
+       }
+       
+       public List<Token> getIssuedTokens() {
+               return null;
+       }
+       
+       public List<Application> getApplications() {
+               return null;
+       }
+       
+       public List<Role> getRoles() {
+               return null;
+       }
+       
+       protected Member addRole(Role role) {
+               return this;
+       }
+       
+       public List<Credential> getCredentials() {
+               return null;
+       }
+       
+       protected Member addCredential(Credential credential) {
+               return null;
+       }
+       
+       public List<Notification> getNotifications() {
+               return null;
+       }
+       
+       protected Member addNotification(Notification notification) {
+               return null;
+       }
+       
+       public List<Token> getTokens() {
+               return null;
+       }
+       
+       protected Member addToken(Token token) {
+               return null;
+       }
+       
+       protected Member delete() {
+               return null;
+       }
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Name.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Name.java
new file mode 100644 (file)
index 0000000..03cf0f9
--- /dev/null
@@ -0,0 +1,28 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Name extends AssurableEntity {
+       String type;
+
+       /**
+        * @return the desc
+        */
+       public String getType() {
+               return type;
+       }
+
+       /**
+        * @param desc the desc to set
+        */
+       protected Name setType(String desc) {
+               this.type = desc;
+               return this;
+       }
+       
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Notification.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Notification.java
new file mode 100644 (file)
index 0000000..cf30176
--- /dev/null
@@ -0,0 +1,115 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Notification extends BirdShackObject {
+       private Member from;
+       private Member to;
+       private String content;
+       private String created;
+       private String confirmed;
+       private String type;
+       
+       /**
+        * 
+        */
+       public Notification() {
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @return the from
+        */
+       public Member getFrom() {
+               return from;
+       }
+
+       /**
+        * @param from the from to set
+        */
+       protected Notification setFrom(Member from) {
+               this.from = from;
+               return this;
+       }
+
+       /**
+        * @return the to
+        */
+       public Member getTo() {
+               return to;
+       }
+
+       /**
+        * @param to the to to set
+        */
+       protected Notification setTo(Member to) {
+               this.to = to;
+               return this;
+       }
+
+       /**
+        * @return the content
+        */
+       public String getContent() {
+               return content;
+       }
+
+       /**
+        * @param content the content to set
+        */
+       protected Notification setContent(String content) {
+               this.content = content;
+               return this;
+       }
+
+       /**
+        * @return the created
+        */
+       public String getCreated() {
+               return created;
+       }
+
+       /**
+        * @param created the created to set
+        */
+       protected Notification setCreated(String created) {
+               this.created = created;
+               return this;
+       }
+
+       /**
+        * @return the confirmed
+        */
+       public String getConfirmed() {
+               return confirmed;
+       }
+
+       /**
+        * @param confirmed the confirmed to set
+        */
+       protected Notification setConfirmed(String confirmed) {
+               this.confirmed = confirmed;
+               return this;
+       }
+
+       /**
+        * @return the type
+        */
+       public String getType() {
+               return type;
+       }
+
+       /**
+        * @param type the type to set
+        */
+       protected Notification setType(String type) {
+               this.type = type;
+               return this;
+       }
+
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Permission.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Permission.java
new file mode 100644 (file)
index 0000000..843f338
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+import java.util.List;
+
+
+/**
+ * @author law
+ *
+ */
+public class Permission extends BirdShackObject {
+       private String recourcePattern;
+       private List<String> actions;
+       /**
+        * @return the recourcePattern
+        */
+       public String getRecourcePattern() {
+               return recourcePattern;
+       }
+       /**
+        * @param recourcePattern the recourcePattern to set
+        */
+       protected Permission setRecourcePattern(String recourcePattern) {
+               this.recourcePattern = recourcePattern;
+               return this;
+       }
+       /**
+        * @return the actions
+        */
+       public List<String> getActions() {
+               return actions;
+       }
+       /**
+        * @param actions the actions to set
+        */
+       protected Permission setActions(List<String> actions) {
+               this.actions = actions;
+               return this;
+       }
+       
+       
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Profile.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Profile.java
new file mode 100644 (file)
index 0000000..32a0172
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+import java.util.List;
+
+
+/**
+ * @author law
+ *
+ */
+public class Profile extends BirdShackObject {
+       private String dob;
+       
+       public static List<Profile> list() {
+               return null;
+       }
+       
+       public Profile() {
+               
+       }
+       
+       public List<Email> getEmails() {
+               return null;
+       }
+       
+       protected Profile addEmail(Email email) {
+               return this;
+       }
+       
+       public List<Credential> getCredentials() {
+               return null;
+       }
+       
+       protected Profile addCredential(Credential credential) {
+               return this;
+       }
+       
+       public List<Delegation> getDelegations() {
+               return null;
+       }
+       
+       protected Profile addDelegation(Delegation delegation) {
+               return this;
+       }
+       
+       public String getDob() {
+               return dob;
+       }
+       
+       protected Profile setDob(String dob) {
+               this.dob = dob;
+               return this;
+       }
+       
+       public List<Name> getNames() {
+               return null;
+       }
+       
+       protected Profile addName(Name name) {
+               return this;
+       }
+       
+       protected Profile delete() {
+               return this;
+       }
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Role.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Role.java
new file mode 100644 (file)
index 0000000..7316a3c
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Role {
+       String name;
+
+       /**
+        * @return the name
+        */
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * @param name the name to set
+        */
+       protected Role setName(String name) {
+               this.name = name;
+               return this;
+       }
+       
+       
+}
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Token.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/model/Token.java
new file mode 100644 (file)
index 0000000..2068733
--- /dev/null
@@ -0,0 +1,100 @@
+/**
+ * 
+ */
+package org.cacert.birdshack.bl.model;
+
+/**
+ * @author law
+ *
+ */
+public class Token extends BirdShackObject {
+       private String token;
+       private String created;
+       private String expired;
+       private boolean revoked;
+       private String desc;
+       
+       /**
+        * 
+        */
+       public Token() {
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @return the token
+        */
+       public String getToken() {
+               return token;
+       }
+
+       /**
+        * @param token the token to set
+        */
+       protected Token setToken(String token) {
+               this.token = token;
+               return this;
+       }
+
+       /**
+        * @return the created
+        */
+       public String getCreated() {
+               return created;
+       }
+
+       /**
+        * @param created the created to set
+        */
+       protected Token setCreated(String created) {
+               this.created = created;
+               return this;
+       }
+
+       /**
+        * @return the expired
+        */
+       public String getExpired() {
+               return expired;
+       }
+
+       /**
+        * @param expired the expired to set
+        */
+       protected Token setExpired(String expired) {
+               this.expired = expired;
+               return this;
+       }
+
+       /**
+        * @return the revoked
+        */
+       public boolean isRevoked() {
+               return revoked;
+       }
+
+       /**
+        * @param revoked the revoked to set
+        */
+       protected Token setRevoked(boolean revoked) {
+               this.revoked = revoked;
+               return this;
+       }
+
+       /**
+        * @return the desc
+        */
+       public String getDesc() {
+               return desc;
+       }
+
+       /**
+        * @param desc the desc to set
+        */
+       protected Token setDesc(String desc) {
+               this.desc = desc;
+               return this;
+       }
+       
+       
+}
diff --git a/Business Logic/trunk/webapps/ROOT/WEB-INF/web.xml b/Business Logic/trunk/webapps/ROOT/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..e98efa0
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+   version="2.5"> 
+
+    <description>
+      The BirdShack API
+    </description>
+    <display-name>BirdShack API</display-name>
+
+    <servlet>
+        <servlet-name>Controller</servlet-name>
+        <servlet-class>org.cacert.birdshack.bl.api.Controller</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>Controller</servlet-name>
+        <url-pattern>/</url-pattern>
+    </servlet-mapping>
+</web-app>
diff --git a/TailFeather/trunk/copyright.txt b/TailFeather/trunk/copyright.txt
new file mode 100644 (file)
index 0000000..6a2d27d
--- /dev/null
@@ -0,0 +1 @@
+Copyright for this Project is assigned according to http://svn.cacert.cl/Documents/SourceCodeManifesto.html
diff --git a/TailFeather/trunk/src/bscp/Makefile b/TailFeather/trunk/src/bscp/Makefile
new file mode 100644 (file)
index 0000000..629417e
--- /dev/null
@@ -0,0 +1,21 @@
+AR=ar
+CC=gcc
+
+stdpipe : stdpipe.o bscp.a
+       $(CC) -o stdpipe stdpipe.o bscp.a
+
+bscp.a : packet.o comm.o crc.o
+       $(AR) r bscp.a packet.o comm.o crc.o
+
+simpletest : simpletest.o stdpipe
+       $(CC) -o simpletest simpletest.o
+
+recovertest : recovertest.o bscp.a
+       $(CC) -o recovertest recovertest.o bscp.a
+
+clean :
+       rm -f stdpipe
+       rm -f simpletest
+       rm -f recovertest
+       rm -f *.a
+       rm -f *.o
diff --git a/TailFeather/trunk/src/bscp/comm.c b/TailFeather/trunk/src/bscp/comm.c
new file mode 100644 (file)
index 0000000..cf886b9
--- /dev/null
@@ -0,0 +1,106 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#include "comm.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+
+#ifndef COMM_FAULTMAX
+#define COMM_FAULTMAX 3
+#endif
+
+comm *comm_create(int readchnl, int writechnl) {
+       comm *chnl = (comm *)malloc(sizeof(comm));
+       if (NULL == chnl) {
+               return NULL;
+       }
+       if (comm_init(chnl, readchnl, writechnl) != 0) {
+               free(chnl);
+               return NULL;
+       }
+       return chnl;
+}
+int comm_init(comm *chnl, int readchnl, int writechnl) {
+       int result = 0;
+       chnl->read = readchnl;
+       chnl->write = writechnl;
+       chnl->faults = 0;
+       
+       result = pthread_mutex_init(&(chnl->readlock),NULL);
+       if (result != 0) {
+               return result;
+       }
+       
+       result = pthread_mutex_init(&(chnl->writelock),NULL);
+       if (result != 0) {
+               pthread_mutex_destroy(&(chnl->readlock));
+               return result;
+       }
+       
+       return result;
+}
+void comm_sync(comm *chnl) {
+       char buffer[3];
+       int cnt = 0;
+       int res = pthread_mutex_lock(&(chnl->writelock));
+       memset(buffer,0,3);
+       if (res != 0) return;
+       while (pthread_mutex_lock(&(chnl->readlock)) != 0) {
+               comm_put(chnl, buffer, 3);
+       }
+       while (cnt < 13) {
+               comm_get(chnl,buffer,1);
+               cnt = (buffer[0]==0)?(cnt+1):0;
+               buffer[0] = 0;
+               comm_put(chnl,buffer,3);
+       }
+       while ((buffer[0] && 0xFF) != 0xFF) {
+               comm_get(chnl,buffer,1);
+               if (((buffer[0] && 0xFF) != 0xFF) && (buffer[0] != 0)) {
+                       pthread_mutex_unlock(&(chnl->readlock));
+                       pthread_mutex_unlock(&(chnl->writelock));
+                       comm_sync(chnl);
+                       return;
+               }
+       }
+       chnl->faults=0;
+       pthread_mutex_unlock(&(chnl->readlock));
+       pthread_mutex_unlock(&(chnl->writelock));
+}
+int comm_get(comm *chnl, char *buf, int buflen) {
+       int res = pthread_mutex_lock(&(chnl->readlock));
+       if (res != 0) return -1;
+       res = read(chnl->read,buf,buflen);
+       pthread_mutex_unlock(&(chnl->readlock));
+       return res;
+}
+int comm_put(comm *chnl, const char *buf, const int buflen) {
+       int res = pthread_mutex_lock(&(chnl->writelock));
+       if (res != 0) return -1;
+       res = write(chnl->write,buf,buflen);
+       pthread_mutex_unlock(&(chnl->writelock));
+       return res;
+}
+void comm_fault(comm *chnl) {
+       if (pthread_mutex_lock(&(chnl->readlock)) != 0) return;
+       chnl->faults++;
+       pthread_mutex_unlock(&(chnl->readlock));
+       if (chnl->faults > COMM_FAULTMAX) {
+               fprintf(stderr,"?");
+               //comm_sync(chnl);
+       }
+}
+void comm_cleanup(comm *chnl) {
+       if (NULL == chnl) return;
+       pthread_mutex_destroy(&(chnl->readlock));
+       pthread_mutex_destroy(&(chnl->writelock));
+}
+void comm_destroy(comm *chnl) {
+       if (NULL == chnl) return;
+       comm_cleanup(chnl);
+       free(chnl);
+}
diff --git a/TailFeather/trunk/src/bscp/comm.h b/TailFeather/trunk/src/bscp/comm.h
new file mode 100644 (file)
index 0000000..fada551
--- /dev/null
@@ -0,0 +1,28 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#ifndef comm_h
+#define comm_h
+
+#include <pthread.h>
+
+struct comm_t {
+       int read;
+       int write;
+       int faults;
+       pthread_mutex_t readlock;
+       pthread_mutex_t writelock;
+};
+typedef struct comm_t comm;
+
+comm *comm_create(int readchnl, int writechnl);
+int comm_init(comm *chnl, int readchnl, int writechnl);
+int comm_get(comm *chnl, char *buf, int buflen);
+int comm_put(comm *chnl, const char *buf, const int buflen);
+void comm_fault(comm *chnl);
+void comm_cleanup(comm *chnl);
+void comm_destroy(comm *chnl);
+
+#endif
diff --git a/TailFeather/trunk/src/bscp/crc.c b/TailFeather/trunk/src/bscp/crc.c
new file mode 100644 (file)
index 0000000..d1a2457
--- /dev/null
@@ -0,0 +1,74 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#include "crc.h"
+
+static crc crctab[256] = {
+       0x00000000,
+       0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B,
+       0x1A864DB2, 0x1E475005, 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6,
+       0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
+       0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC,
+       0x5BD4B01B, 0x569796C2, 0x52568B75, 0x6A1936C8, 0x6ED82B7F,
+       0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A,
+       0x745E66CD, 0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039,
+       0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5, 0xBE2B5B58,
+       0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033,
+       0xA4AD16EA, 0xA06C0B5D, 0xD4326D90, 0xD0F37027, 0xDDB056FE,
+       0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95,
+       0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4,
+       0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D, 0x34867077, 0x30476DC0,
+       0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5,
+       0x2AC12072, 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16,
+       0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA, 0x7897AB07,
+       0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C,
+       0x6211E6B5, 0x66D0FB02, 0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1,
+       0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
+       0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B,
+       0xBB60ADFC, 0xB6238B25, 0xB2E29692, 0x8AAD2B2F, 0x8E6C3698,
+       0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D,
+       0x94EA7B2A, 0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E,
+       0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2, 0xC6BCF05F,
+       0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34,
+       0xDC3ABDED, 0xD8FBA05A, 0x690CE0EE, 0x6DCDFD59, 0x608EDB80,
+       0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB,
+       0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A,
+       0x58C1663D, 0x558240E4, 0x51435D53, 0x251D3B9E, 0x21DC2629,
+       0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C,
+       0x3B5A6B9B, 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF,
+       0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623, 0xF12F560E,
+       0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65,
+       0xEBA91BBC, 0xEF68060B, 0xD727BBB6, 0xD3E6A601, 0xDEA580D8,
+       0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,
+       0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2,
+       0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B, 0x9B3660C6, 0x9FF77D71,
+       0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74,
+       0x857130C3, 0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640,
+       0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C, 0x7B827D21,
+       0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A,
+       0x61043093, 0x65C52D24, 0x119B4BE9, 0x155A565E, 0x18197087,
+       0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,
+       0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D,
+       0x2056CD3A, 0x2D15EBE3, 0x29D4F654, 0xC5A92679, 0xC1683BCE,
+       0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB,
+       0xDBEE767C, 0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18,
+       0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4, 0x89B8FD09,
+       0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662,
+       0x933EB0BB, 0x97FFAD0C, 0xAFB010B1, 0xAB710D06, 0xA6322BDF,
+       0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4
+};
+
+crc partial_crc(crc crcval, char *buf, int buflen) {
+       int idx = 0;
+       unsigned char byte = 0;
+       for (idx=0; idx < buflen; idx++) {
+               byte = 0x00 | buf[idx];
+               crcval = (crcval << 8) ^ crctab[(crcval >> 24) ^ byte];
+       }
+       return crcval;
+}
+crc calculate_crc(char *buf, int buflen) {
+       return partial_crc(0, buf, buflen);
+}
diff --git a/TailFeather/trunk/src/bscp/crc.h b/TailFeather/trunk/src/bscp/crc.h
new file mode 100644 (file)
index 0000000..658da8c
--- /dev/null
@@ -0,0 +1,16 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#ifndef crc_h
+#define crc_h
+
+#include <sys/types.h>
+
+typedef int32_t crc;
+
+crc partial_crc(crc crcval, char *buf, int buflen);
+crc calculate_crc(char *buf, int buflen);
+
+#endif
diff --git a/TailFeather/trunk/src/bscp/packet.c b/TailFeather/trunk/src/bscp/packet.c
new file mode 100644 (file)
index 0000000..510b749
--- /dev/null
@@ -0,0 +1,92 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#include "packet.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "crc.h"
+
+void num2char(char *buf, const unsigned long value, const int bits) {
+       int idx = 0;
+       for (idx=0; idx < (bits/8); idx++) {
+               buf[idx] = (value << (bits - (idx * 8))) & 0xFF;
+       }
+}
+void char2num(unsigned long *value, const char *buf, const int bits) {
+       int idx = 0;
+       *value = 0;
+       for (idx=0; idx < (bits/8); idx++) {
+               *value = *value << 8;
+               *value |= buf[idx];
+       }
+}
+
+packet *packet_create(void *buf, const int buflen) {
+       packet *pkt = (packet*)malloc(sizeof(packet));
+       pkt->length = 0;
+       pkt->checksum = 0;
+       memset(pkt->data, 0, PACKET_MAXLEN + PACKET_HEADER + PACKET_FOOTER + 1);
+       if (NULL == buf) {
+               packet_setdata(pkt,buf,buflen);
+       }
+       return pkt;
+}
+
+int packet_setdata(packet *pkt, void *buf, const int length) {
+       int32_t len=0;
+       memset(pkt->data,0,PACKET_MAXLEN + PACKET_HEADER + PACKET_FOOTER + 1);
+       pkt->length = (length > PACKET_MAXLEN) ? PACKET_MAXLEN : length;
+       len = htonl(pkt->length);
+       memcpy(pkt->data, &len, PACKET_HEADER);
+       memcpy(pkt->data + PACKET_HEADER,buf,pkt->length);
+       pkt->checksum = calculate_crc(pkt->data,pkt->length+PACKET_HEADER);
+       memcpy(pkt->data + PACKET_HEADER + pkt->length,&(pkt->checksum),PACKET_FOOTER);
+}
+
+void packet_send(comm *channel, packet *pkt) {
+       if ((pkt->length < 1)||(pkt->length > PACKET_MAXLEN)) return;
+       comm_put(channel, pkt->data, pkt->length + PACKET_HEADER + PACKET_FOOTER);
+}
+
+packet *packet_recv(comm *channel) {
+       packet *pkt = packet_create(NULL,0);
+       if (packet_fetch(channel, pkt) == 0) {
+               return pkt;
+       }
+       packet_destroy(pkt);
+}
+int packet_fetch(comm *channel, packet *pkt) {
+       int32_t len=0;
+       if (comm_get(channel, (void*)&len, PACKET_HEADER) != PACKET_HEADER) return 1;
+       memcpy(pkt->data, &len, PACKET_HEADER);
+       pkt->length = ntohl(len);
+       if ((pkt->length > 0) && (pkt->length <= PACKET_MAXLEN)) {
+               comm_get(channel,pkt->data + PACKET_HEADER,pkt->length + PACKET_FOOTER);
+               memcpy(&(pkt->checksum),pkt->data+ PACKET_HEADER + pkt->length, PACKET_FOOTER);
+               if (pkt->checksum != calculate_crc(pkt->data,PACKET_HEADER + pkt->length)) {
+                       comm_fault(channel);
+                       return 1;
+               }
+       } else {
+               comm_fault(channel);
+               return 1;
+       }
+       return 0;
+}
+
+void *packet_data(packet *pkt, int *len) {
+       *len = pkt->length;
+       return pkt->data + PACKET_HEADER;
+}
+
+void packet_destroy(packet *pkt) {
+       if (NULL == pkt) return;
+       pkt->length = 0;
+       pkt->checksum = 0;
+       free(pkt);
+}
diff --git a/TailFeather/trunk/src/bscp/packet.h b/TailFeather/trunk/src/bscp/packet.h
new file mode 100644 (file)
index 0000000..5641d90
--- /dev/null
@@ -0,0 +1,33 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#ifndef packet_h
+#define packet_h
+
+#include "comm.h"
+#include "crc.h"
+
+#include <sys/types.h>
+
+#define PACKET_MAXLEN 1024
+#define PACKET_HEADER 4
+#define PACKET_FOOTER 4
+
+struct packet_t {
+       char data[ PACKET_HEADER + PACKET_MAXLEN + PACKET_FOOTER + 1 ];
+       int32_t length;
+       int32_t checksum;
+};
+typedef struct packet_t packet;
+
+packet *packet_create(void *buf, const int buflen);
+void packet_send(comm *channel, packet *pkt);
+packet *packet_recv(comm *channel);
+int packet_fetch(comm *channel, packet *pkt);
+void *packet_data(packet *pkt, int *len);
+int packet_setdata(packet *pkt, void *buf, const int len);
+void packet_destroy(packet *pkt);
+
+#endif
diff --git a/TailFeather/trunk/src/bscp/recovertest.c b/TailFeather/trunk/src/bscp/recovertest.c
new file mode 100644 (file)
index 0000000..ccf4be4
--- /dev/null
@@ -0,0 +1,123 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <signal.h>
+#include "packet.h"
+
+int running;
+comm one,two;
+
+void bugout(int sig) {
+       if (!running) {
+               return;
+       }
+       running = 0;
+       comm_cleanup(&one);
+       comm_cleanup(&two);
+       signal(SIGHUP,NULL);
+       signal(SIGINT,NULL);
+       signal(SIGTERM,NULL);
+}
+
+void *bscp2bscp(void *args) {
+       packet pkt;
+       while (running) {
+               if ((packet_fetch(&one, &pkt) == 0)&&running) {
+                       packet_send(&two, &pkt);
+               }
+       }
+       fprintf(stderr,"bscp2bscp complete\n");
+       pthread_exit(NULL);
+       return NULL;
+}
+void *stdin2bscp(void *args) {
+       packet pkt;
+       char *line;
+       int len;
+       comm *port = (comm*)args;
+       while (running) {
+               line = fgetln(stdin,(size_t *)&len);
+               if ((len > 0) && running) {
+                       if ((len > 7)&&(memcmp("PDUEOF",line,6) != 0)) {
+                               packet_setdata(&pkt, line, len);
+                               packet_send(port,&pkt);
+                       }
+               }
+               if ((len==-1)||((len>7)&&(memcmp("EOF",line,6) == 0))) {
+                       bugout(0);
+                       close(one.write);
+                       close(two.write);
+               }
+       }
+       fprintf(stderr,"stdin2bscp complete\n");
+       pthread_exit(NULL);
+       return NULL;
+}
+void *bscp2stdout(void *args) {
+       packet pkt;
+       comm *port = (comm*)args;
+       char *buffer;
+       int len;
+       while (running) {
+               if ((packet_fetch(port, &pkt) == 0)&&running) {
+                       buffer = (char*)packet_data(&pkt,&len);
+                       if (len > -1) {
+                               buffer[len-1] = 0;
+                               fprintf(stderr,"*");
+                       }
+               }
+       }
+       fprintf(stderr,"bscp2stdout complete\n");
+       pthread_exit(NULL);
+       return NULL;
+}
+void *doerror(void* na) {
+       while (running) {
+               pthread_mutex_lock(&one.writelock);
+               //write(one.write,"\2",1);
+               pthread_mutex_unlock(&one.writelock);
+               sleep(10);
+       }
+}
+int main(int argc, char *argv[]) {
+       pthread_t th_bscp2bscp;
+       pthread_t th_stdin2bscp;
+       pthread_t th_bscp2stdout;
+       pthread_t th_error;
+       
+       int pone[2];
+       int ptwo[2];
+       
+       if (pipe(pone) || pipe(ptwo)) {
+               fprintf(stderr,"Could not create redirect pipe!\n");
+               return -1;
+       }
+       running = 0;
+       signal(SIGHUP,bugout);
+       siginterrupt(SIGHUP, 1);
+       signal(SIGINT,bugout);
+       siginterrupt(SIGINT, 1);
+       signal(SIGTERM,bugout);
+       siginterrupt(SIGTERM, 1);
+
+       comm_init(&one,pone[0],pone[1]);
+       comm_init(&two,ptwo[0],ptwo[1]);
+       running = 1;
+       
+       
+       pthread_create(&th_stdin2bscp,NULL,stdin2bscp,(void*)&one);
+       pthread_create(&th_bscp2bscp,NULL,bscp2bscp,NULL);
+       pthread_create(&th_bscp2stdout,NULL,bscp2stdout,(void*)&two);
+       pthread_create(&th_bscp2stdout,NULL,doerror,NULL);
+       
+       pthread_join(th_bscp2bscp, NULL);
+       pthread_join(th_stdin2bscp, NULL);
+       pthread_join(th_bscp2stdout, NULL);
+       fprintf(stderr,"main complete\n");
+       return 0;
+}
diff --git a/TailFeather/trunk/src/bscp/simpletest.c b/TailFeather/trunk/src/bscp/simpletest.c
new file mode 100644 (file)
index 0000000..fc36128
--- /dev/null
@@ -0,0 +1,29 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#include <stdio.h>
+#include <unistd.h>
+
+extern char **environ;
+
+int main(int argc, char *argv[]) {
+       int pip[2];
+       if (pipe(pip)) {
+               fprintf(stderr,"Could not create redirect pipe!\n");
+               return -1;
+       }
+       if (dup2(pip[0],0) != 0) {
+               fprintf(stderr,"Could not redirect STDIN!\n");
+               return -1;
+       }
+       if (dup2(pip[1],1) != 1) {
+               fprintf(stderr,"Could not redirect STDOUT!\n");
+               return -1;
+       }
+        
+       execve("./stdpipe",argv,environ);
+       fprintf(stderr,"Could not execute ./stdpipe !\n");
+       return -1;
+}
\ No newline at end of file
diff --git a/TailFeather/trunk/src/bscp/stdpipe.c b/TailFeather/trunk/src/bscp/stdpipe.c
new file mode 100644 (file)
index 0000000..29a539f
--- /dev/null
@@ -0,0 +1,93 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include "packet.h"
+
+int running;
+comm iface;
+
+void bugout(int sig) {
+       if (!running) {
+               return;
+       }
+       running = 0;
+       comm_cleanup(&iface);
+       close(0);
+       close(1);
+       signal(SIGHUP,NULL);
+       signal(SIGINT,NULL);
+       signal(SIGTERM,NULL);
+}
+
+void *bscp2pipe(void *argdata) {
+       char **argv = (char **)argdata;
+       packet pkt;
+       void *data = NULL;
+       int length = 0;
+       int pipe = -1;
+       while (running) {
+               if (packet_fetch(&iface, &pkt) == 0) {
+                       data = packet_data(&pkt, &length);
+                       if (data && running) {
+                               pipe = open(argv[2],O_WRONLY);
+                               if (pipe > -1) {
+                                       write(pipe,data,length);
+                                       close(pipe);
+                               }
+                       }
+               }
+       }
+       return NULL;
+}
+void *pipe2bscp(void *argdata) {
+       char **argv = (char**)argdata;
+       packet pkt;
+       unsigned char data[PACKET_MAXLEN];
+       int length;
+       int pipe = -1;
+       while (running) {
+               pipe = open(argv[1],O_RDONLY);
+               if (running && (pipe > -1)) {
+                       length = read(pipe,data,PACKET_MAXLEN);
+                       close(pipe);
+                       if ((length > -1) && running) {
+                               packet_setdata(&pkt,data,length);
+                               packet_send(&iface, &pkt);
+                       }
+               }
+       }
+       return NULL;
+}
+int main(int argc, char *argv[]) {
+       pthread_t th_bscp2pipe;
+       pthread_t th_pipe2bscp;
+       
+       if (argc != 3) {
+               fprintf(stderr,"Usage: %s <pipe-in> <pipe-out>\n",argv[0]);
+               return -1;
+       }
+       running = 0;
+       signal(SIGHUP,bugout);
+       siginterrupt(SIGHUP, 1);
+       signal(SIGINT,bugout);
+       siginterrupt(SIGINT, 1);
+       signal(SIGTERM,bugout);
+       siginterrupt(SIGTERM, 1);
+
+       running = 1;
+       comm_init(&iface, 0, 1);
+       fprintf(stderr, "Starting Threads...\n");
+       pthread_create(&th_bscp2pipe, NULL, bscp2pipe, (void*)argv);
+       pthread_create(&th_pipe2bscp, NULL, pipe2bscp, (void*)argv);
+       pthread_join(th_bscp2pipe, NULL);
+       pthread_join(th_pipe2bscp, NULL);
+
+       return 0;
+}