public SSOSite addSite(SSOSite site) throws SSOException { return this.addSite(getDefaultDomainId(), site); }
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; }
@SuppressWarnings("unchecked") public Collection<SSOSite> getSitesForPrincipal(JetspeedPrincipal localPrincipal) throws SSOException { Collection<SSOSite> sitesFound = null; if (localPrincipal != null){ Collection<SSOUser> ssoUsers = getRemoteUsers(localPrincipal); if (ssoUsers != null && ssoUsers.size() > 0){ sitesFound = ssoSiteManagerSPI.getSites(ssoUsers); } } return sitesFound != null ? sitesFound : Collections.EMPTY_SET; }
public SSOClient getClient(SSOSite site, SSOUser remoteUser) throws SSOException { PasswordCredential pwdCred = getCredentials(remoteUser); return new SSOClientImpl(site,pwdCred); }
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(); }
public Collection<SSOUser> getRemoteUsers(SSOSite site, Subject subject) throws SSOException { Map<Long,SSOUser> resultUsers = new HashMap<Long,SSOUser>(); for (Principal p : subject.getPrincipals()){ if (p instanceof JetspeedPrincipal){ try{ Collection<SSOUser> usersForThisPrincipal = getRemoteUsers(site,(JetspeedPrincipal)p); for (SSOUser user : usersForThisPrincipal) { if (!resultUsers.containsKey(user.getId())){ resultUsers.put(user.getId(), user); } } } catch (SSOException se){ throw new SSOException(se); } } } return resultUsers.values(); }