int numberOfSites = sites.length;
// Do all the logins for the site
for (int i=0; i<numberOfSites; i++)
{
SSOSite site = sites[i];
if (site != null)
{
Iterator itRemotePrincipals = site.getRemotePrincipals().iterator();
while (itRemotePrincipals.hasNext() )
{
InternalUserPrincipal remotePrincipal = (InternalUserPrincipal)itRemotePrincipals.next();
if (remotePrincipal != null)
{
InternalCredential credential = null;
if ( remotePrincipal.getCredentials() != null)
credential = (InternalCredential)remotePrincipal.getCredentials().iterator().next();
if (credential != null)
{
if (log.isInfoEnabled())
log.info("SSOComponent -- Remote Principal ["+stripPrincipalName(remotePrincipal.getFullPath())+"] has credential ["+this.unscramble(credential.getValue())+ "]");
client.getState().setCredentials(
site.getRealm(),
urlObj.getHost(),
new UsernamePasswordCredentials(stripPrincipalName(remotePrincipal.getFullPath()), this.unscramble(credential.getValue()))
);
// Build URL if it's Form authentication
StringBuffer siteURL = new StringBuffer(site.getSiteURL());
// Check if it's form based or ChallengeResponse
if (site.isFormAuthentication())
{
siteURL.append("?").append(site.getFormUserField()).append("=").append(stripPrincipalName(remotePrincipal.getFullPath())).append("&").append(site.getFormPwdField()).append("=").append(this.unscramble(credential.getValue()));
}
get = new GetMethod(siteURL.toString());
// Tell the GET method to automatically handle authentication. The
// method will use any appropriate credentials to handle basic
// authentication requests. Setting this value to false will cause
// any request for authentication to return with a status of 401.
// It will then be up to the client to handle the authentication.
get.setDoAuthentication( true );
try {
// execute the GET
int status = client.executeMethod( get );
if (log.isInfoEnabled() )
log.info("Accessing site [" + site.getSiteURL() + "]. HTTP Status [" +status+ "]" );
/*
* If the destination URL and the SSO url match
* use the authentication process but return immediately
* the result page.
*/
if( destUrl.compareTo(site.getSiteURL()) == 0 && numberOfSites == 1)
{
if (log.isInfoEnabled() )
log.info("SSO Component --SSO Site and destination URL match. Go and get the content." );
//try