com.cbse.jeasy
Class JEHttpConnector

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.cbse.jeasy.JEHttpConnector
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class JEHttpConnector
extends javax.servlet.http.HttpServlet

A servlet using for connection between JEasy presentation layer and application layer. JEHttpConnector is the server side of the JEHttpClient

Version:
%I%, %G%
Author:
H.Pfohl
See Also:
Serialized Form

Constructor Summary
JEHttpConnector()
           
 
Method Summary
 void checkForSessionsOutOfTime()
          Checks for session out of time and discard them
 void closeSession(java.lang.String sessionId)
           
 byte[] compress(byte[] ba)
           
 byte[] compress(byte[] ba, javax.crypto.Cipher ec)
           
 byte[] compress(java.lang.String s)
           
 byte[] compress(java.lang.String s, javax.crypto.Cipher ec)
           
 byte[] decompress(byte[] ba)
           
 java.lang.String decompress(java.io.InputStream in)
           
 java.lang.String decompress(java.io.InputStream in, javax.crypto.Cipher dc)
           
 byte[] decrypt(byte[] ba, javax.crypto.Cipher decryptCipher)
           
 java.lang.String decrypt(java.io.InputStream in, javax.crypto.Cipher dc)
           
 void destroy()
           
 void doPost(java.io.ByteArrayInputStream stream, java.io.ByteArrayOutputStream bos)
           
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void doPost(java.io.InputStream in, java.io.OutputStream os)
           
 byte[] encrypt(byte[] ba, javax.crypto.Cipher encryptCipher)
           
static java.lang.String getXMLElement(java.lang.String source, java.lang.String element)
          Parses the String for the given XML-Element inside and
static java.lang.String getXMLElementAttribute(java.lang.String source, java.lang.String element, java.lang.String attribut)
          Parses the String for the attribut inside the the given XML-Element inside
 void init()
           
 void initSimulation(java.lang.String dclass, java.lang.String confpath)
           
 java.lang.String openSession()
          Opens a Session
 java.lang.String request(java.io.OutputStream os, java.lang.String sessionId, java.lang.String service, java.lang.String sXML, boolean getAttachment)
          Performes a request from the client
 boolean setCrypt(boolean b, java.lang.String key, com.cbse.jeasy.JEHttpConnector.Request req)
          If b is true the data send to and received from the server are crypted
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JEHttpConnector

public JEHttpConnector()
Method Detail

initSimulation

public void initSimulation(java.lang.String dclass,
                           java.lang.String confpath)

init

public void init()
          throws javax.servlet.ServletException
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

setCrypt

public boolean setCrypt(boolean b,
                        java.lang.String key,
                        com.cbse.jeasy.JEHttpConnector.Request req)
If b is true the data send to and received from the server are crypted

Parameters:
req -

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws java.io.IOException
Overrides:
doPost in class javax.servlet.http.HttpServlet
Throws:
java.io.IOException

doPost

public void doPost(java.io.ByteArrayInputStream stream,
                   java.io.ByteArrayOutputStream bos)
            throws java.io.IOException
Throws:
java.io.IOException

doPost

public void doPost(java.io.InputStream in,
                   java.io.OutputStream os)
            throws java.io.IOException
Throws:
java.io.IOException

request

public java.lang.String request(java.io.OutputStream os,
                                java.lang.String sessionId,
                                java.lang.String service,
                                java.lang.String sXML,
                                boolean getAttachment)
Performes a request from the client

Parameters:
sessionId -
service -
sXML -
Returns:

openSession

public java.lang.String openSession()
Opens a Session

Returns:

closeSession

public void closeSession(java.lang.String sessionId)

checkForSessionsOutOfTime

public void checkForSessionsOutOfTime()
Checks for session out of time and discard them


compress

public byte[] compress(byte[] ba,
                       javax.crypto.Cipher ec)
                throws java.lang.Exception
Throws:
java.lang.Exception

compress

public byte[] compress(java.lang.String s)
                throws java.lang.Exception
Throws:
java.lang.Exception

compress

public byte[] compress(java.lang.String s,
                       javax.crypto.Cipher ec)
                throws java.lang.Exception
Throws:
java.lang.Exception

decompress

public java.lang.String decompress(java.io.InputStream in)
                            throws java.lang.Exception
Throws:
java.lang.Exception

decompress

public java.lang.String decompress(java.io.InputStream in,
                                   javax.crypto.Cipher dc)
                            throws java.lang.Exception
Throws:
java.lang.Exception

decrypt

public java.lang.String decrypt(java.io.InputStream in,
                                javax.crypto.Cipher dc)
                         throws java.lang.Exception
Throws:
java.lang.Exception

compress

public byte[] compress(byte[] ba)

decompress

public byte[] decompress(byte[] ba)

decrypt

public byte[] decrypt(byte[] ba,
                      javax.crypto.Cipher decryptCipher)

encrypt

public byte[] encrypt(byte[] ba,
                      javax.crypto.Cipher encryptCipher)
               throws java.lang.Exception
Throws:
java.lang.Exception

getXMLElement

public static java.lang.String getXMLElement(java.lang.String source,
                                             java.lang.String element)
Parses the String for the given XML-Element inside and

Parameters:
source - the string where it will be searched
element - the XML element to look for
Returns:
the string inside the tag or null

getXMLElementAttribute

public static java.lang.String getXMLElementAttribute(java.lang.String source,
                                                      java.lang.String element,
                                                      java.lang.String attribut)
Parses the String for the attribut inside the the given XML-Element inside

Parameters:
source - the string where it will be searched
element - the XML element to look for
Returns:
the string inside the tag or null