* getCredential
* returns the credentials for a given user
*/
private SSOContext getCredential(SSOSite ssoSite, String fullPath)
{
InternalCredential credential = null;
InternalUserPrincipal remotePrincipal = null;
String remoteUser = null;
String remoteFullPath = null;
// Get remotePrincipals for Site and match them with the Remote Principal for the Principal attached to site
Collection principalsForSite = ssoSite.getPrincipals();
Collection remoteForSite = ssoSite.getRemotePrincipals();
// If any of them don't exist just return
if ( principalsForSite == null || remoteForSite== null )
return null; // no entry
Collection remoteForPrincipals = getRemotePrincipalsForPrincipal(principalsForSite, fullPath);
if ( remoteForPrincipals == null)
return null; // no entry
// Get remote Principal that matches the site and the principal
if ((remotePrincipal = findRemoteMatch(remoteForPrincipals, remoteForSite)) == null )
{
return null; // No entry
}
else
{
// Has an entry
if ( remotePrincipal.getCredentials() != null)
credential = (InternalCredential)remotePrincipal.getCredentials().iterator().next();
// Error checking -- should have a credential at this point
if ( credential == null)
{
System.out.println("Warning: Remote User " + remotePrincipal.getFullPath() + " doesn't have a credential");
return null;
}
}
// Create new context
String name = stripPrincipalName(remotePrincipal.getFullPath());
SSOContext context = new SSOContextImpl(credential.getPrincipalId(), name, credential.getValue());
return context;
}