* @param s sso site
* @return sso site wrapper
*/
private JSSSOSite createSSOSite(SSOSite s)
{
JSSSOSite site = new JSSSOSite();
site.setName(s.getName());
site.setSiteURL(s.getSiteURL());
site.setAllowUserSet(s.isAllowUserSet());
site.setCertificateRequired(s.isCertificateRequired());
site.setChallengeResponseAuthentication(s.isChallengeResponseAuthentication());
site.setRealm(s.getRealm());
site.setFormAuthentication(s.isFormAuthentication());
site.setFormUserField(s.getFormUserField());
site.setFormPwdField(s.getFormPwdField());
Iterator rupIter = s.getRemotePrincipals().iterator();
while (rupIter.hasNext())
{
InternalUserPrincipal rup = (InternalUserPrincipal)rupIter.next();
InternalCredential rupCredential = null;
Collection rupCredentials = rup.getCredentials();
if (rupCredentials != null)
{
rupCredential = (InternalCredential)rupCredentials.iterator().next();
}
if (rupCredential != null)
{
String rupPath = rup.getFullPath();
String rupPrincipalType = null;
String rupPrincipalName = null;
String rupName = null;
String [] names = null;
if (rupPath.startsWith("/sso/") && (rupPath.indexOf("/user/") != -1))
{
rupPrincipalType = "user";
names = rupPath.replaceAll("^/sso/[0-9]+/user/", "").split("/");
}
else if (rupPath.startsWith("/sso/") && (rupPath.indexOf("/group/") != -1))
{
rupPrincipalType = "group";
names = rupPath.replaceAll("^/sso/[0-9]+/group/", "").split("/");
}
if ((names != null) && (names.length == 2))
{
rupPrincipalName = names[0];
rupName = names[1];
}
if ((rupPrincipalType != null) && (rupPrincipalName != null) && (rupPrincipalName.length() > 0) && (rupName != null) && (rupName.length() > 0))
{
JSSSOSiteRemoteUser siteRemoteUser = new JSSSOSiteRemoteUser();
siteRemoteUser.setPrincipalName(rupPrincipalName);
siteRemoteUser.setPrincipalType(rupPrincipalType);
siteRemoteUser.setUserCredential(rupName, rupCredential.getValue().toCharArray());
site.addRemoteUser(siteRemoteUser);
}
}
}
return site;