Author: chaase3 Date: Thu Oct 2 11:39:09 2008 New Revision: 701206 URL: http://svn.apache.org/viewvc?rev=701206&view=rev Log: DERBY-3200: Developer's Guide: Add examples showing use of SQL authorization with user authentication Made additional fixes to topics suggested by reviewer, mainly for clarity and adherence to programming conventions. Patch: DERBY-3200-8.diff Modified: db/derby/docs/trunk/src/devguide/rdevcsecure26537.dita db/derby/docs/trunk/src/devguide/rdevcsecureclientexample.dita db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthclientex.dita db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthembeddedex.dita db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthexs.dita Modified: db/derby/docs/trunk/src/devguide/rdevcsecure26537.dita URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/rdevcsecure26537.dita?rev=701206&r1=701205&r2=701206&view=diff ============================================================================== --- db/derby/docs/trunk/src/devguide/rdevcsecure26537.dita (original) +++ db/derby/docs/trunk/src/devguide/rdevcsecure26537.dita Thu Oct 2 11:39:09 2008 @@ -20,7 +20,7 @@ --> User authentication and authorization embedded example -The following program, AuthExampleEmbedded.java, +This example, AuthExampleEmbedded.java, shows how to turn on, use, and turn off user authentication using 's built-in user authentication and user authorization using the embedded @@ -28,9 +28,12 @@
-

See for -information on using SQL authorization, which allows you to use ANSI SQL -Standard GRANT and REVOKE statements. See +

This example is a single long program. A similar example that uses the client +driver, in +, +uses one program to set properties and a second program to perform database +operations. Either example would work equally well in the other format.

+

See for an example similar to this one that uses SQL authorization.

The program does the following:

@@ -59,8 +62,8 @@

When you run AuthExampleEmbedded, make sure that %DERBY_HOME%\lib\derby.jar (or $DERBY_HOME/lib/derby.jar) is in your classpath. For example, -you might use the following command:

-

java -cp ${CLASSPATH}:${DERBY_HOME}/lib/derby.jar AuthExampleEmbedded

+you might use the following command on a UNIX system:

+

java -cp .:${DERBY_HOME}/lib/derby.jar AuthExampleEmbedded

Source code for <codeph>AuthExampleEmbedded.java</codeph> import java.sql.*; @@ -331,8 +334,11 @@ s.close(); } - /** Exception reporting methods - * with special handling of SQLExceptions + /** + * Report exceptions, with special handling of SQLExceptions, + * and exit. + * + * @param e an exception (Throwable) */ static void errorPrintAndExit(Throwable e) { if (e instanceof SQLException) @@ -344,7 +350,11 @@ System.exit(1); } - // Iterate through a stack of SQLExceptions + /** + * Iterate through a stack of SQLExceptions. + * + * @param sqle a SQLException + */ static void SQLExceptionPrint(SQLException sqle) { while (sqle != null) { System.out.println("\n---SQLException Caught---\n"); Modified: db/derby/docs/trunk/src/devguide/rdevcsecureclientexample.dita URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/rdevcsecureclientexample.dita?rev=701206&r1=701205&r2=701206&view=diff ============================================================================== --- db/derby/docs/trunk/src/devguide/rdevcsecureclientexample.dita (original) +++ db/derby/docs/trunk/src/devguide/rdevcsecureclientexample.dita Thu Oct 2 11:39:09 2008 @@ -20,21 +20,24 @@ --> User authentication and authorization client example -The following pair of programs, +This example consists of a pair of programs, AuthExampleClient1.java and -AuthExampleClient2.java, shows how to turn on, use, and turn -off user authentication using +AuthExampleClient2.java, which show how to turn on, use, and +turn off user authentication using 's built-in user authentication and user authorization using the client driver.
-

See for -information on using SQL authorization, which allows you to use ANSI SQL -Standard GRANT and REVOKE statements. See +

This example uses one program to set properties and a second program to +perform database operations. A similar example that uses the embedded +driver, in +, is a single long +program. Either example would work equally well in the other format.

+

See -for examples similar to these that use SQL authorization.

+for an example similar to this one that uses SQL authorization.

The first program, AuthExampleClient1.java, does the following:

    @@ -64,15 +67,15 @@

    javac AuthExampleClient2.java

    Before you run the programs, start the Network -Server as described in "Activity 4: Create and run a JDBC program using the -client driver and Network Server" in +Server as described in step 2 of "Activity 4: Create and run a JDBC program +using the client driver and Network Server" in . When you run the programs, make sure that %DERBY_HOME%\lib\derbyclient.jar (or -$DERBY_HOME/lib/derbyclient.jar) is in your classpath. Run the -programs using commands like the following:

    -

    java -cp ${CLASSPATH}:${DERBY_HOME}/lib/derbyclient.jar AuthExampleClient1

    -

    java -cp ${CLASSPATH}:${DERBY_HOME}/lib/derbyclient.jar AuthExampleClient2

    +$DERBY_HOME/lib/derbyclient.jar) is in your classpath. For +example, you might use the following commands on a Windows system:

    +

    java -cp .;%DERBY_HOME%\lib\derbyclient.jar AuthExampleClient1

    +

    java -cp .;%DERBY_HOME%\lib\derbyclient.jar AuthExampleClient2

Source code for <codeph>AuthExampleClient1.java</codeph> import java.sql.*; @@ -221,8 +224,11 @@ s.close(); } - /** Exception reporting methods - * with special handling of SQLExceptions + /** + * Report exceptions, with special handling of SQLExceptions, + * and exit. + * + * @param e an exception (Throwable) */ static void errorPrintAndExit(Throwable e) { if (e instanceof SQLException) @@ -234,7 +240,11 @@ System.exit(1); } - // Iterates through a stack of SQLExceptions + /** + * Iterate through a stack of SQLExceptions. + * + * @param sqle a SQLException + */ static void SQLExceptionPrint(SQLException sqle) { while (sqle != null) { System.out.println("\n---SQLException Caught---\n"); @@ -387,8 +397,11 @@ } } - /** Exception reporting methods - * with special handling of SQLExceptions + /** + * Report exceptions, with special handling of SQLExceptions, + * and exit. + * + * @param e an exception (Throwable) */ static void errorPrintAndExit(Throwable e) { if (e instanceof SQLException) @@ -400,7 +413,11 @@ System.exit(1); } - // Iterates through a stack of SQLExceptions + /** + * Iterate through a stack of SQLExceptions. + * + * @param sqle a SQLException + */ static void SQLExceptionPrint(SQLException sqle) { while (sqle != null) { System.out.println("\n---SQLException Caught---\n"); Modified: db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthclientex.dita URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthclientex.dita?rev=701206&r1=701205&r2=701206&view=diff ============================================================================== --- db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthclientex.dita (original) +++ db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthclientex.dita Thu Oct 2 11:39:09 2008 @@ -20,15 +20,21 @@ --> User authentication and SQL authorization client example -The following pair of programs, +This example consists of a pair of programs, AuthExampleClientSQLAuth1.java and -AuthExampleClientSQLAuth2.java, show how to use SQL +AuthExampleClientSQLAuth2.java, which show how to use SQL authorization, in addition to 's built-in user authentication and user authorization, with the client driver.
+

This example uses one program to set properties and a second program to +perform database operations. A similar example that uses the embedded +driver, in +, +is a single long program. Either example would work equally well in the other +format.

See for more information on using SQL authorization, which allows you to use ANSI SQL Standard GRANT and REVOKE statements. Compare this example to the one in @@ -78,15 +84,15 @@

javac AuthExampleClientSQLAuth2.java

Before you run the programs, start the Network -Server as described in "Activity 4: Create and run a JDBC program using the -client driver and Network Server" in +Server as described in step 2 of "Activity 4: Create and run a JDBC program +using the client driver and Network Server" in . When you run the programs, make sure that %DERBY_HOME%\lib\derbyclient.jar (or -$DERBY_HOME/lib/derbyclient.jar) is in your classpath. Run the -programs using commands like the following:

-

java -cp ${CLASSPATH}:${DERBY_HOME}/lib/derbyclient.jar AuthExampleClientSQLAuth1

-

java -cp ${CLASSPATH}:${DERBY_HOME}/lib/derbyclient.jar AuthExampleClientSQLAuth2

+$DERBY_HOME/lib/derbyclient.jar) is in your classpath. For +example, you might use the following commands on a UNIX system:

+

java -cp .:${DERBY_HOME}/lib/derbyclient.jar AuthExampleClientSQLAuth1

+

java -cp .:${DERBY_HOME}/lib/derbyclient.jar AuthExampleClientSQLAuth2

Source code for <codeph>AuthExampleClientSQLAuth1.java</codeph> import java.sql.*; @@ -256,8 +262,11 @@ s.close(); } - /** Exception reporting methods - * with special handling of SQLExceptions + /** + * Report exceptions, with special handling of SQLExceptions, + * and exit. + * + * @param e an exception (Throwable) */ static void errorPrintAndExit(Throwable e) { if (e instanceof SQLException) @@ -269,7 +278,11 @@ System.exit(1); } - // Iterate through a stack of SQLExceptions + /** + * Iterate through a stack of SQLExceptions. + * + * @param sqle a SQLException + */ static void SQLExceptionPrint(SQLException sqle) { while (sqle != null) { System.out.println("\n---SQLException Caught---\n"); @@ -524,8 +537,11 @@ } } - /** Exception reporting methods - * with special handling of SQLExceptions + /** + * Report exceptions, with special handling of SQLExceptions, + * and exit. + * + * @param e an exception (Throwable) */ static void errorPrintAndExit(Throwable e) { if (e instanceof SQLException) @@ -537,7 +553,11 @@ System.exit(1); } - // Iterate through a stack of SQLExceptions + /** + * Iterate through a stack of SQLExceptions. + * + * @param sqle a SQLException + */ static void SQLExceptionPrint(SQLException sqle) { while (sqle != null) { System.out.println("\n---SQLException Caught---\n"); Modified: db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthembeddedex.dita URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthembeddedex.dita?rev=701206&r1=701205&r2=701206&view=diff ============================================================================== --- db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthembeddedex.dita (original) +++ db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthembeddedex.dita Thu Oct 2 11:39:09 2008 @@ -20,15 +20,19 @@ --> User authentication and SQL authorization embedded example -The following program, -AuthExampleEmbeddedSQLAuth.java, shows how to use SQL -authorization, in addition to +This example, AuthExampleEmbeddedSQLAuth.java, +shows how to use SQL authorization, in addition to 's built-in user authentication and user authorization, with the embedded driver.
+

This example is a single long program. A similar example that uses the client +driver, in +, +uses one program to set properties and a second program to perform database +operations. Either example would work equally well in the other format.

See for more information on using SQL authorization, which allows you to use ANSI SQL Standard GRANT and REVOKE statements. Compare this example to the one in @@ -74,8 +78,8 @@

When you run AuthExampleEmbeddedSQLAuth, make sure that %DERBY_HOME%\lib\derby.jar (or $DERBY_HOME/lib/derby.jar) is in your classpath. For example, -you might use the following command:

-

java -cp ${CLASSPATH}:${DERBY_HOME}/lib/derby.jar AuthExampleEmbeddedSQLAuth

+you might use the following command on a Windows system:

+

java -cp .;%DERBY_HOME%\lib\derby.jar AuthExampleEmbeddedSQLAuth

Source code for <codeph>AuthExampleEmbeddedSQLAuth.java</codeph> import java.sql.*; @@ -470,8 +474,11 @@ s.close(); } - /** Exception reporting methods - * with special handling of SQLExceptions + /** + * Report exceptions, with special handling of SQLExceptions, + * and exit. + * + * @param e an exception (Throwable) */ static void errorPrintAndExit(Throwable e) { if (e instanceof SQLException) @@ -483,7 +490,11 @@ System.exit(1); } - // Iterate through a stack of SQLExceptions + /** + * Iterate through a stack of SQLExceptions. + * + * @param sqle a SQLException + */ static void SQLExceptionPrint(SQLException sqle) { while (sqle != null) { System.out.println("\n---SQLException Caught---\n"); Modified: db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthexs.dita URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthexs.dita?rev=701206&r1=701205&r2=701206&view=diff ============================================================================== --- db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthexs.dita (original) +++ db/derby/docs/trunk/src/devguide/rdevcsecuresqlauthexs.dita Thu Oct 2 11:39:09 2008 @@ -21,7 +21,7 @@ User authentication examples using SQL authorization -The following examples show how to use SQL authorization in +These examples show how to use SQL authorization in conjunction with 's built-in user authentication and user authorization.