public String removeDomain(String domainId) throws Exception { try { startTransaction(false); // Remove the domain getOrganization().domain.removeDomain(idAsInt(domainId)); if (domainDriverInstances.get(domainId) != null) { domainDriverInstances.remove(domainId); } this.commit(); LoginPasswordAuthentication.initDomains(); return domainId; } catch (AdminException e) { try { this.rollback(); } catch (Exception e1) { SilverTrace.error("admin", "DomainDriverManager.createDomain", "root.EX_ERR_ROLLBACK", e1); } throw new AdminException( "DomainDriverManager.createDomain", SilverpeasException.ERROR, "admin.EX_ERR_ADD_DOMAIN", "domain id: '" + domainId + "'", e); } finally { releaseOrganizationSchema(); } }
/** * @param sKey anthentication key * @param removeKey remove after * @return * @throws Exception */ public Map<String, String> authenticate(String sKey, boolean removeKey) throws Exception { Map<String, String> loginDomainId = new HashMap<String, String>(); try { startTransaction(false); // Get the domain information KeyStoreRow ksr = getOrganization().keyStore.getRecordByKey(idAsInt(sKey)); if (ksr == null) { throw new AdminException( "DomainDriverManager.authenticate", SilverpeasException.ERROR, "admin.EX_ERR_KEY_NOT_FOUND", "key: '" + sKey + "'"); } loginDomainId.put("login", ksr.login); loginDomainId.put("domainId", idAsString(ksr.domainId)); // Remove key from keytore in database if (removeKey) { getOrganization().keyStore.removeKeyStoreRecord(idAsInt(sKey)); } // Commit transaction commit(); return loginDomainId; } catch (AdminPersistenceException e) { try { this.rollback(); } catch (Exception e1) { SilverTrace.error("admin", "DomainDriverManager.authenticate", "root.EX_ERR_ROLLBACK", e1); } throw new AdminException( "DomainDriverManager.authenticate", SilverpeasException.ERROR, "admin.EX_ERR_AUTHENTICATE", "key: '" + sKey + "'", e); } finally { releaseOrganizationSchema(); } }
public String updateDomain(Domain theDomain) throws Exception { try { startTransaction(false); DomainRow dr = new DomainRow(); dr.id = idAsInt(theDomain.getId()); dr.name = theDomain.getName(); dr.description = theDomain.getDescription(); dr.className = theDomain.getDriverClassName(); dr.propFileName = theDomain.getPropFileName(); dr.authenticationServer = theDomain.getAuthenticationServer(); dr.theTimeStamp = theDomain.getTheTimeStamp(); dr.silverpeasServerURL = theDomain.getSilverpeasServerURL(); // Create domain getOrganization().domain.updateDomain(dr); if (domainDriverInstances.get(theDomain.getId()) != null) { domainDriverInstances.remove(theDomain.getId()); } this.commit(); LoginPasswordAuthentication.initDomains(); return theDomain.getId(); } catch (AdminException e) { try { this.rollback(); } catch (Exception e1) { SilverTrace.error("admin", "DomainDriverManager.updateDomain", "root.EX_ERR_ROLLBACK", e1); } throw new AdminException( "DomainDriverManager.updateDomain", SilverpeasException.ERROR, "admin.EX_ERR_ADD_DOMAIN", "domain name: '" + theDomain.getName() + "'", e); } finally { releaseOrganizationSchema(); } }