public Collection<SSOSite> getSitesForSubject(Subject subject) throws SSOException { Map<Integer,SSOSite> siteIdToSite = new HashMap<Integer,SSOSite>(); for (Principal p : subject.getPrincipals()){ if (p instanceof JetspeedPrincipal){ try { Collection<SSOSite> sitesForThisPrincipal = getSitesForPrincipal((JetspeedPrincipal)p); for (SSOSite site : sitesForThisPrincipal) { if (!siteIdToSite.containsKey(site.getId())){ siteIdToSite.put(site.getId(), site); } } } catch (SSOException se){ } } } return siteIdToSite.values(); }
protected void cacheSite(SSOSite site){ if (getCachedSiteByDomainId(site.getSecurityDomainId()) != null){ removeSiteFromCache(site); } mapSiteUrlIndex.put(site.getURL(), site); mapSiteDomainIndex.put(site.getSecurityDomainId(), site); mapSiteNameIndex.put(site.getName(), site); }
protected void removeSiteFromCache(SSOSite site){ mapSiteUrlIndex.remove(site.getURL()); mapSiteDomainIndex.remove(site.getSecurityDomainId()); } }
public SSOUser getRemoteUser(SSOSite site, String remoteUsername ) { try{ return ssoUserManagerSPI.getUser(remoteUsername, site.getSecurityDomainId()); } catch (SecurityException secex){ log.debug("Could not find SSO user with name "+remoteUsername+" from remote site "+site.getName()+" (domain id: "+site.getSecurityDomainId()+")", secex); return null; } }
site.setName(s.getName()); site.setSiteURL(s.getURL()); 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());
url = new URL(site.getURL()); } catch (MalformedURLException muex){ log.error(muex.getMessage(), muex); throw new SSOException("SSO: Marlformed url: "+site.getURL()); site.getRealm(), url.getHost(), new UsernamePasswordCredentials(credential.getUserName(), SSOUtils.unscramble(credential.getPassword())) ); StringBuffer siteURL = new StringBuffer(site.getURL()); if (site.isFormAuthentication()) siteURL.append("?").append(site.getFormUserField()).append("=").append(credential.getUserName()).append("&").append(site.getFormPwdField()).append("=").append(SSOUtils.unscramble(credential.getPassword())); status = httpClient.executeMethod( get ); } catch (IOException ioe){ log.error("SSO: Error executing get method for url "+site.getURL()); throw new SSOException(ioe);
public void updateSite(SSOSite site) throws SSOException { SSOSite currentSite = ssoSiteManagerSPI.getById(site.getId()); if (currentSite == null){ throw new SSOException("Unable to update site: site doesn't exist."); } if (!currentSite.getName().equals(site.getName())){ if (domainAccessManager.getDomainByName(site.getName()) != null){ throw new SSOException("Unable to rename site to '"+site.getName()+"': a security domain with that name already exists!"); } SecurityDomain domain = domainAccessManager.getDomain(currentSite.getSecurityDomainId()); SecurityDomainImpl renamedDomain = new SecurityDomainImpl(domain); renamedDomain.setName(site.getName()); try{ domainStorageManager.updateDomain(renamedDomain); } catch (SecurityException secex){ throw new SSOException("Unable to rename security domain "+domain.getName()+" to "+site.getName()+".",secex); } } ssoSiteManagerSPI.update(site); }
protected SSOSite addSite(Long ownerDomainId, SSOSite site) throws SSOException if (domainAccessManager.getDomainByName(site.getName()) != null){ throw new SSOException(SSOException.SITE_ALREADY_EXISTS); sd.setName(site.getName()); sd.setOwnerDomainId(ownerDomainId); sd.setEnabled(true); domainStorageManager.addDomain(sd); } catch(SecurityException sx){ log.error("Could not add remote security domain with name "+site.getName()+" for owner domain "+ownerDomainId); throw new SSOException(SSOException.SITE_COULD_NOT_BE_CREATED,sx); SecurityDomain storedDomain = domainAccessManager.getDomainByName(site.getName()); if (storedDomain == null || storedDomain.getDomainId() == null){ throw new SSOException(SSOException.SITE_COULD_NOT_BE_CREATED); site.setSecurityDomainId(storedDomain.getDomainId());
public boolean login() throws SSOException { GetMethod get = new GetMethod(site.getURL().toString()); int status = login(get); get.releaseConnection(); return status >= 200 && status < 300; }
public Collection<SSOUser> getRemoteUsers(SSOSite site, JetspeedPrincipal portalPrincipal) throws SSOException { try{ return ssoUserManagerSPI.getUsers(portalPrincipal,site.getSecurityDomainId()); } catch (SecurityException secex){ throw new SSOException(secex); } }
public SSOSite add(SSOSite ssoSite) throws SSOException { try { getPersistenceBrokerTemplate().store(ssoSite); cacheSite(ssoSite); return ssoSite; } catch (Exception e) { String msg = "Unable to add SSO Site: " + ssoSite.getName(); log.error(msg, e); throw new SSOException(msg, e); } }
public Collection<SSOUser> getUsersForSite(SSOSite site) throws SSOException { try{ return ssoUserManagerSPI.getUsers("", site.getSecurityDomainId()); } catch (SecurityException e){ throw new SSOException("Could not fetch SSO users for site "+site.getName(),e); } }
public Collection<JetspeedPrincipal> getPortalPrincipals(SSOUser user) { SSOSite site = ssoSiteManagerSPI.getSite(user); if (site != null){ SecurityDomain ssoDomain = domainAccessManager.getDomain(site.getSecurityDomainId()); SecurityDomain ownerDomain = domainAccessManager.getDomain(ssoDomain.getOwnerDomainId()); return ssoUserManagerSPI.getPortalPrincipals(user,ownerDomain.getDomainId()); } else { return Collections.emptyList(); } }
public void remove(SSOSite site) throws SSOException { try { getPersistenceBrokerTemplate().delete(site); removeSiteFromCache(site); } catch (Exception e) { String msg = "Unable to remove SSO Site: " + site.getName(); log.error(msg, e); throw new SSOException(msg, e); } }
public void removeSite(SSOSite site) throws SSOException { SecurityDomain domain = domainAccessManager.getDomain(site.getSecurityDomainId()); if (domain != null){ try{ domainStorageManager.removeDomain(domain); } catch (SecurityException secex){ throw new SSOException("Unable to remove security domain (id:"+site.getSecurityDomainId()+") associated with the SSO Site "+site.getName()); } } ssoSiteManagerSPI.remove(site); }
if (!(ssoSitesMap.containsKey(s.getURL())))
public SSOUser addUser(SSOSite site, JetspeedPrincipal ownerPrincipal, String ssoUsername, String ssoUserPassword) throws SSOException { SSOUser newUser = null; try{ // step 1. create new SSO user newUser = ssoUserManagerSPI.addUser(ssoUsername, site.getSecurityDomainId(), ownerPrincipal); // step 2. store new user's credentials setPassword(newUser, ssoUserPassword); // step 3. relate owner to SSO user addAssociation(newUser, ownerPrincipal); } catch (SecurityException secex){ // revert changes, if applicable if (newUser != null){ removeUser(newUser); } throw new SSOException("Unable to add new SSO User "+ssoUsername,secex); } return newUser; }
public void update(SSOSite site) throws SSOException { try { getPersistenceBrokerTemplate().store(site); cacheSite(site); } catch (Exception e) { String msg = "Unable to remove SSO Site: " + site.getName(); log.error(msg, e); throw new SSOException(msg, e); } }