SSOSite site = sso.getSiteByName(siteName);
if ( site != null )
{
JetspeedPrincipal principal = getJetspeedPrincipal(principalType,principalName);
if (principal != null){
Collection<SSOUser> ssoUsers = sso.getRemoteUsers(site, principal);
if (ssoUsers != null && ssoUsers.size() == 1){
sso.removeUser(ssoUsers.iterator().next());
} else {
// TODO: provide feedback, sso user not found
}
} else {
// TODO: provide feedback, user not found
}
this.clearBrowserIterator(request);
}
}
catch (SSOException e)
{
publishStatusMessage(request, "SSODetails", "status", e, "Could not remove credentials");
}
catch (SecurityException e)
{
publishStatusMessage(request, "SSODetails", "status", e, "Could not remove credentials");
}
}
else if (add != null)
{
// Roger: here is the principal type
String principalType = request.getParameter("principal.type"); //group user
String portalPrincipal = request.getParameter("portal.principal");
String remotePrincipal = request.getParameter("remote.principal");
String remoteCredential = request.getParameter("remote.credential");
// The principal type can benull if the user just typed the name instead of
// using the choosers.
if (principalType == null || principalType.length() == 0 )
principalType = "user";
if (!(StringUtils.isEmpty(remotePrincipal) || StringUtils.isEmpty(remotePrincipal) || StringUtils.isEmpty(remoteCredential)))
{
try
{
String siteName = (String)PortletMessaging.receive(request, "site", "selectedName");
SSOSite site = sso.getSiteByName(siteName);
JetspeedPrincipal localPrincipal = getJetspeedPrincipal(principalType, portalPrincipal);
if (site != null && localPrincipal != null )
{
if (sso.getRemoteUsers(site, localPrincipal).size() > 0)
{
try
{
// TODO: fixme, bug in Pluto on portlet session
PortletMessaging.publish(request, "SSODetails", "status", new StatusMessage("Could not add remote user: portal principal "+localPrincipal.getName()+" is already associated with a remote user for this site!", StatusMessage.ERROR));
}
catch (Exception e)
{
logger.error("Failed to publish message: {}", e);
}