ibi.broker.api.cci
Class WebAuthenticateCredential

java.lang.Object
  extended by ibi.broker.api.cci.WebAuthenticateCredential
All Implemented Interfaces:
Credential, java.io.Serializable, javax.resource.cci.ConnectionSpec

public class WebAuthenticateCredential
extends java.lang.Object
implements Credential, java.io.Serializable

 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){}
                }

%>

Version:
5.3
Author:
unxmxl
See Also:
Serialized Form

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

WebAuthenticateCredential

public WebAuthenticateCredential()
Constructor for WebAuthenicateCredential.


WebAuthenticateCredential

public WebAuthenticateCredential(java.lang.String user,
                                 java.lang.String authorization)

WebAuthenticateCredential

public WebAuthenticateCredential(javax.servlet.http.HttpServletRequest request)
Method Detail

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Returns the HTTP Servlet request object.

Returns:
Returns the request.

setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Sets the HTTP Servlet request object.

Parameters:
request - The request to set.

getUserName

public java.lang.String getUserName()
Returns the user name contained in the Web server. This is often the REMOTE_USER session variable.

Specified by:
getUserName in interface Credential
Returns:
The user name contained in the Web server, as a String.
See Also:
Credential.getUserName()


Copyright © 2006 Information Builders, Incorporated.