-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.txt
113 lines (88 loc) · 3.84 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Project Name: knzn-lib
Last Modified: 2/9/2011
Version 0.1
-----------------------------------------------------------------------------
Database Library: src/main/java/knzn/db
Database.java
DatabaseImpl.java
ResultSetHandler.java
Transaction.java
TransactionalDatabase.java
TransactionDatabase.java
Documentation:
Constructors
DatabaseImpl(final String dataSourceName)
Constructor attempts to lookup data source with the specified name
DatabaseImpl(final DataSource dataSource)
Constructor expects a provided data source
Methods
query(final String sql, final Objec[] params, final ResultSetHandler result) : List
RETURNS: List of results for a column specified in the Sql statement
Parameters:
sql - Sql state to query the database
SELECT * FROM user WHERE username = ? AND password = ?
params - Array of parameters to add to the Sql statement
Object[] params = {"username", "password"};
result - Interface used to determine what column to select and what data type to return
final ResultSetHandler<String> color = new ResultSetHandler<String>() {
public String handle(final ResultSet resultSet) throws SQLException {
return resultSet.getString("username");}};
update(final String sql, final Object[] params) : void
Runs an update sql update statement
Parameters:
sql - Sql statement used to update the database
params - Array of parameters to add to the Sql statement. Can be Null
runTransaction(final Transaction transaction) : void
Runs a sql command with provided functionality such as Rollback and Commit
If an exception is thrown in runTransaction then a rollback is executed
(see below for more on runTransaction)
TransactionDatabase Class
Provides an interface for executing transactional commands using the DatabaseImpl Class
DatabaseImpl db = new DatabaseIml(dataSource);
db.runTransaction(new Transaction() {
public void doInTransaction(TransactionDatabase database) throws SQLException {
database.startTransaction();
String color = "Green";
database.update("DELETE FROM foo WHERE color = ?", new String[]{color}); }});
The result is the update statement is executed as a transactional database
------------------------------------------------------------------------------
Ldap Library: src/main/java/knzn/ldap
InitialDirectionContextFactory.java
LdapTemplate.java
SearchResultHandler.java
SearchResultWrapper.java
Documentation:
InitialContextFactory Class
Provides static methods for building an initial context used to communicate with an ldap server
createBaseEnv(String principle, String credentials, String host, String authentication) : Hashtable
Parameters:
principle - Security Principle
credentials - Security Credentials
host - Provider Url
authentication - Security Authentication type
createPooledEnv(String principle, String credentials, String host, String authentication, int connectTimeout, int poolSize, int poolTimeout) : Hashtable
Parameters:
principle - Security Principle
credentials - Security Credentials
host - Provider Url
authentication - Security Authentication type
connectionTimeout - How long to stay connected
poolSize - Maximum pool size
poolTimout - How long before the poot times out
LdapTemplate Class
Constructor
LdapTemplate(Hashtable env)
the Initial context must be provided
Method
search(String name, String filter, SearchResultHandler srMapper, SearchControls constraints) : List
searches an ldap server for specific attributes
RETURNS: List of search results
Parameters:
name - the name of the context to search
filter - search filter provided
Filter syntax example: "(cn=*)" * means all
srMapper - interface that defines the what attributes to get and what data type to return
SearchResultHandler<Object> result = new SearchResultHandler<Object>() {
public Object handle(SearchResultWrapper searchResult) throws NamingException {
return searchResult.getAttribute("ou"); }};
constraints - the search controls that control the search. Can be Null