|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectibi.broker.api.cci.WebAuthenticateCredential
public class WebAuthenticateCredential
This class is used to pass authentication credentials from a WebServer to the CasterConnectionFactory.getConnection() method. It can be used in conjunction with the PasswordCredential class, which, if the existance of the remote_user is not available the user is asked to supply credentials. The sample code below is taken from the samples packaged with the product. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2004 Information Builders, Inc. All Rights Reserved. + + + + Information Builders offers sample API programs as a heuristic device. + + They are not intended, as is, for production use. Licensed users are + + welcome to alter and extend these samples and deploy them in other + + environments, or alternate configurations, as they see fit. + + Information Builders will support the documented functionality of + + its API classes and methods. However, Information Builders is not + + responsible for functionality or behavior of products built with + + its API unless the documented behavior of its discrete classes and + + methods is different than the actual results. + + + + Redistributions of IBI source code and documentation must be within + + the scope of the Information Builders Software License Agreement. + + + + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <%@ page import="ibi.broker.api.*"%> <%@ page import="ibi.broker.api.cci.*"%> <%@ page import="javax.resource.cci.*"%> <% try { String user = request.getParameter("user"); String password = request.getParameter("password"); String host = pageContext.getServletContext().getInitParameter("AGENT_NODE"); String port = pageContext.getServletContext().getInitParameter("AGENT_PORT"); CasterManagedConnectionFactory managedConnectionFactory = new CasterManagedConnectionFactory(); managedConnectionFactory.setServerName(host); managedConnectionFactory.setPortNumber(port); CasterConnectionFactory connectionFactory = (CasterConnectionFactory)managedConnectionFactory.createConnectionFactory(); ConnectionSpec credential = null; if(request.getRemoteUser() == null) credential = new PasswordCredential(user, password.toCharArray()); else { //for remote authenticate user = request.getRemoteUser(); String authorization = request.getHeader("AUTHORIZATION"); credential = new WebAuthenticateCredential(user, authorization); } CasterConnection casterConnection = ((CasterConnection)connectionFactory.getConnection(credential)); //for using cookies { String securityToken = casterConnection.getSecurityToken(); response.setHeader("Set-Cookie", "RC_COOKIE=" + securityToken); } // for using session { request.getSession().setAttribute("CASTER_CONNECTION", casterConnection); } out.println("OK"); } catch(Exception e) { try{ out.println(e.getMessage()); }catch(Exception ex){} } %>
Constructor Summary | |
---|---|
WebAuthenticateCredential()
Constructor for WebAuthenicateCredential. |
|
WebAuthenticateCredential(javax.servlet.http.HttpServletRequest request)
|
|
WebAuthenticateCredential(java.lang.String user,
java.lang.String authorization)
|
Method Summary | |
---|---|
javax.servlet.http.HttpServletRequest |
getRequest()
Returns the HTTP Servlet request object. |
java.lang.String |
getUserName()
Returns the user name contained in the Web server. |
void |
setRequest(javax.servlet.http.HttpServletRequest request)
Sets the HTTP Servlet request object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WebAuthenticateCredential()
public WebAuthenticateCredential(java.lang.String user, java.lang.String authorization)
public WebAuthenticateCredential(javax.servlet.http.HttpServletRequest request)
Method Detail |
---|
public javax.servlet.http.HttpServletRequest getRequest()
public void setRequest(javax.servlet.http.HttpServletRequest request)
request
- The request to set.public java.lang.String getUserName()
getUserName
in interface Credential
Credential.getUserName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |