The Java EE 6 Tutorial, Volume I

Using Programmatic Login

Programmatic login enables the client code to supply user credentials. If you are using an EJB client, you can use the class with their convenient login and logout methods.

Programmatic login is specific to a server. Information on programmatic login for the Enterprise Server is included in the Sun GlassFish Enterprise Server v3 Application Development Guide or the documentation for the server you are using.