//============================================================================= // // General Description of Data Access Module // // Created: 10/01/99 // Author: Hyun Kim // //============================================================================= (1) dataModule.java - General class for accessing data through different protocols - METHODs: public void open( String protocol, String location, String id, String pwd ) throws Exception; . protocol: specify a certain protocol to open its session (such as "file", "jdbc", "web", "ldap"(currently suspended)) . location: path of filename or URL . id, pwd: ID and its password for access to database or LDAP public void update(); . save the changes public void update( String location ); . save the changes into the given location public void close(); . close the session without saving public Enumeration getTypes(); . get the list of all types, such as 'user' public String getValue( String type, String name, String key ); . get the value of the specified key of the given type's and name's object public Enumeration getObjects( String types ); . get the list of all given type's objects public void addObject( String type, String name ) throws Exception; . add the new object with the given type and name . if the given type's and name's object alreadt exists, all keys of the object are removed and added as a new object public void removeObject( String type, String name ) throws Exception; . remove all keys of the given name's user . do nothing if the given type's and name's object does not exist public Enumeration getObjectKeys( String type, String name ); . get the list of all keys of the given type's and name's object public void setValue( String type, String name, String key, String value ) throws Exception; . modify the value of the given key of the given type's and name's object . do nothing if the given type's and name's object does not exist . add the key and its value if the given key does not exists public void removeKey( String type, String name, String key ) throws Exception; . remove the given key and its value . do nothing if the given type's and name's user or the given key does not exist [EXAMPLES] try { dataModule iMan = new dataModule(); String value, encPasswd; iMan.open("jdbc", "jdbc:oracle:thin:@carver.npac.syr.edu:1521:europe", "hyunkim", "hyunkim"); iMan.addObject( "user", "Hyun" ); iMan.setValue( "user", "Hyun", "e-mail", "hkim@npac.syr.edu" ); iMan.setValue( "user", "Hyun", "password", "passpassme" ); value = iMan.getValue( "user", "Hyun", "e-mail" ); System.out.println( "Hyun's email: " + value ); // Password Maching Part // // use the static method, 'passwordOK' in PasswdManager.java // Assume we read the user's passwod from the consol, say 'myPasswd' // encPasswd = iMan.getValue( "user", "Hyun", "password" ); // the return value is encripted only for password if ( PasswdManager.passwordOK( myPasswd, encPasswd ) ) { // password matched } else { // password not matched } iMan.removeKey( "user", "Hyun", "e-mail" ); iMan.removeObject( "user", "Tommy" ); Enumeration e = iMan.getObjectKeys( "user", "Hyun" ); e = iMan.getObjects( "user" ); // get the list of all users iMan.update(); // save the changes } catch ( Exception e ) { } (2) ModuleFactory.java - Construct an instance of the specific class depending on the protocol (3) dataAccess.java - Interface for the protocol-specific implemetation (4) fileModule.java - Specific implementation for accessing data in the file - implements dataAccess interface (5) jdbcModule.java - Specific implementation for accessing data in the database - implements dataAccess interface - "createtables.sql" defines the table scheme (6) httpModule.java - Specific implementation for accessing data in the web server - implements dataAccess interface - not allowed to use some writing functional methods (such as setValue, removeKey, addUser and removeUser) (7) ldapModule.java - currently suspended - Specific implementation for accessing data in the LDAP server - implements dataAccess interfade