SilverStream
Application Server 3.5

com.sssw.srv.api
Interface AgiSession

All Superinterfaces:
AgiAdmSession, HttpSession

public interface AgiSession
extends HttpSession, AgiAdmSession

Interface that represents a single session between client and server. This interface is only available to code running in the SilverStream server (in a Servlet, business object, or dynamic page); it provides all the methods provided in the AgiAdmSession interface, plus additional methods. In addition, the AgiSession interface provides all the methods provided in the standard Java extension interface javax.servlet.HttpSession.


Method Summary
 AgiServer getAgiServer()
          Return an AgiServer object for access to the server APIs.
 Locale getLocale()
          Return the Java locale associated with this session.
 AgpPage getPageForSession(String serverRelativeUrl)
          Load a page for this session.
 Principal getPrincipal()
          Get the Principal associated with this session.
 void loginUser(String userName, String password)
          Log in the user with the specified password into this session.
 
Methods implemented from interface javax.servlet.http.HttpSession
getCreationTime, getId, getLastAccessedTime, getMaxInactiveInterval, getSessionContext, getValue, getValueNames, invalidate, isNew, putValue, removeValue, setMaxInactiveInterval
 
Methods implemented from interface com.sssw.rts.adminapi.AgiAdmSession
getHost, getID, getIdleTime, getProtocolVersionNumber, getState, getUserName, isUserLoggedIn
 

Method Detail

getPrincipal

public Principal getPrincipal()
Get the Principal associated with this session.
Returns:
The session's Principal, or null.
Usage:

The Principal represents the identity of the user on whose behalf this session is executing; it is either the logged-in user if the user has logged in, or a distinguished "Anonymous" user for sessions that have not been logged in.

Example:

To print the name of the user logged in to this session:

     AgiSession sess = evt.getSession();
     Principal prin = sess.getPrincipal();
     System.out.println("The logged-in user is " + prin.getName());
 
See Also:
Principal

getLocale

public Locale getLocale()
Return the Java locale associated with this session. Used for date and other formatting.
Example:
     AgiSession sess = evt.getSession();
     Locale locale = sess.getLocale();
     DateFormat format = DateFormat.getTimeInstance(DateFormat.DEFAULT, locale);
 

getAgiServer

public AgiServer getAgiServer()
Return an AgiServer object for access to the server APIs.
Usage:

Every session is associated with exactly one server.

Example:

To print a list of all the known database names on this server:

     AgiSession sess = evt.getSession();
     AgiServer serv = sess.getAgiServer();
     Enumeration dbNames = serv.getDBNames();
     while (dbNames.hasMoreElements()) {
         System.out.println((String)dbNames.nextElement());
     }
 

getPageForSession

public AgpPage getPageForSession(String serverRelativeUrl)
                          throws AgoApiException
Load a page for this session.
Parameters:
serverRelativeUrl - the URL of the page, relative to the server's root.
Usage:

The page object is maintained for the life of this session. Subsequent calls on the same server-relative url will return the same object.

Example:
     AgiSession sess = evt.getSession();
     AgpPage page = sess.getPageForSession("TestDB/SilverStream/Meta/Pages/index.html");
 

loginUser

public void loginUser(String userName,
                      String password)
               throws AgoUnrecoverableSystemException,
                      AgoSecurityException
Log in the user with the specified password into this session.
Parameters:
userName -  
password -  
Usage:

The login lasts until the user logs out (by calling invalidate() on the session) or until the session is terminated. The user name should be a fully-qualified user name. Throws an exception if the user name is unknown or the password is incorrect, or if the session is already logged in. This routine might be used, for example, by a dynamic HTML page that prompts the user for a user name and password.

Example:

The following code might be written to respond to the pageActionPerformed event on a pushbutton on an HTML page:

 private void handle_Button1_pageActionPerformed(ActionEvent evt) throws
 Exception
 {
 
    String Username = username.getText();
    String Password = password.getText();
    AgiSession sess=((AgoHttpRequestEvent)getCurrentRequest()).getSession();
    Principal aUser=sess.getPrincipal();
    sess.loginUser(Username, Password);
 }
 
 

SilverStream
Application Server 3.5