/*
* Copyright 2000 Draagon Software, Inc. All Rights Reserved.
*
* This software is the proprietary information of Draagon Software, Inc.
* Use is subject to license terms.
*
*/
package com.draagon.wii.headers;
import com.draagon.wii.*;
import com.draagon.wii.util.NameValuePair;
import java.util.List;
/**
* The SimpleSSO request header object is currently very simplistic in that it
* passes the same credentials used to authenticate against the portal to the
* external system.
* <p>
* A newer version of this object is needed so that it may allow the user to
* enter their own set of credentials for the external system.
*
* @author Doug Mealing
* @version 1.2, 12/17/00
* @see com.draagon.wii.WIIRequestHeaders
* @since JDK1.2
*/
public class SimpleSSO implements WIIRequestHeaders
{
/**
* Empty constructor
*/
public SimpleSSO()
{
}
/**
* Retrieves the users credentials from the WIIRequest and returns them in the
* header list.
*
* @param req The WIIRequest object is used to retrieve the user's credentials
* @param headers The headers containing the SSO data to be sent to the
* external system.
*/
public void processRequestHeaders( WIIRequest req, List<NameValuePair> headers )
throws WIIException
{
// Retrieve the WIIUser object
WIIUser pu = req.getUser();
if ( pu == null ) return;
String [] creds = pu.getCredentials( req.getSite() );
// Retrieve the username and password
String user = creds[ 0 ];
// String pass = creds[ 1 ];
// Retrieve the list of roles, and the default role
String def_role = creds[ 2 ];
String roles = creds[ 3 ];
// Add the headers to the returned vector
if ( user != null )
headers.add( new NameValuePair( "X-WII-User", user ));
//if ( pass != null )
// headers.addElement( new NameValuePair( "X-WII-Pass", pass ));
if ( def_role != null )
headers.add( new NameValuePair( "X-WII-Default-Role", def_role ));
if ( roles != null )
headers.add( new NameValuePair( "X-WII-Roles", roles ));
}
}