|
SilverStream Application Server 3.5 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 |
public Principal getPrincipal()
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.
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());
Principal
public Locale getLocale()
AgiSession sess = evt.getSession(); Locale locale = sess.getLocale(); DateFormat format = DateFormat.getTimeInstance(DateFormat.DEFAULT, locale);
public AgiServer getAgiServer()
Every session is associated with exactly one server.
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()); }
public AgpPage getPageForSession(String serverRelativeUrl) throws AgoApiException
serverRelativeUrl
- the URL of the page, relative to the server's root.The page object is maintained for the life of this session. Subsequent calls on the same server-relative url will return the same object.
AgiSession sess = evt.getSession(); AgpPage page = sess.getPageForSession("TestDB/SilverStream/Meta/Pages/index.html");
public void loginUser(String userName, String password) throws AgoUnrecoverableSystemException, AgoSecurityException
userName
- password
- 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.
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 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |