Tuesday, August 17, 2010

Session Tracking in Java

Maintaining client sessions is the ability for servers to associate multiple stateless http requests within a single session context. Often, implementing session seems to be magic, but an actual mechanism exists by which this is implemented.

The main requirement for maintaing client sessions is the server's ability to associate one request with a previous request. In order to do this, a session id must be generated and passed back from the server to client. The client will then pass this session id in subsequent requests to associate these with the previous request. The main difference between the various methods of maintaing a session is the form of the session id, such as the way the session id is generated or how it is stored on the client and/or on the server.

Java web servers provide a default implementation using Http Session. However, there are several other ways. The server

1) Using HttpSession

Generation: web server
Client Location: cookies or url
Server Location: web server

Java web servers by default can maintain http sessions by generating at request a session id, or the JSESSION_ID. Once the session has been established, the Java web developer can save any type of information in the new session when processing the request. The web server is responsible for storing this session and any saved information without any additional coding. Once the request has been processed, a JSESSION ID is passed back to the browser as a cookie. The browser saves the cookie. On subsequent requests to the same web server, the cookie is passed back to the server, and the web server picks up the session cookie and retrieves the JSESSION ID. Once the session id has been identified, the session associated with the id is set on the request.

2) Encrypt and Decrypt

Generation: servlet
Client Location: cookies
Server Location: N/A

When the client makes a request with a particular user-specific id, the server can generate the session id from this user id. The user id

3) Memcached

Generation: servlet
Client Location: cookies
Server Location: N/A

Tuesday, July 27, 2010

LDAP Modify - Changing your password

File contents: mod_attribute.ldif

dn: uid=mtan,ou=People,dc=mlbam,dc=com
changetype: modify
replace: userPassword
userPassword: {clear text password}

ldapmodify -x -h ldap01.mlbam.com -p 389 -D "uid=mtan,ou=People,dc=mlbam,dc=com" -f /Users/tan/mod_attribute.ldif -W
Enter LDAP Password:

Enter your current password.

Possible outcomes:

additional info: invalid password syntax: no numeric character
This indicates your password must contain a numeric character

additional info: invalid password syntax: dictionary word match
This indicates your new password contains a dictionary word, which is not allowed.

additional info: invalid password syntax: no special character
This indicates your new password must contain a special character.

SASL/EXTERNAL authentication started
ldap_sasl_interactive_bind_s: Unknown authentication method (-6)
additional info: SASL(-4): no mechanism available:
You should use the -x option for simple authentication.