diff --git a/config/alfresco/extension/license/howToInstallLicense.txt b/config/alfresco/extension/license/howToInstallLicense.txt deleted file mode 100644 index 4ee8d03d44..0000000000 --- a/config/alfresco/extension/license/howToInstallLicense.txt +++ /dev/null @@ -1,9 +0,0 @@ -A license is installed by placing the license file (.lic) within this directory. - -Only one license file may exist within this directory. - -Upon restarting the Alfresco server, the license file is read and installed. -If installed successfully, the license file is renamed by adding ".installed" -to the end of the filename. - - diff --git a/source/java/org/alfresco/license/AlfrescoKeyStore.java b/source/java/org/alfresco/license/AlfrescoKeyStore.java deleted file mode 100644 index 7ae382a056..0000000000 --- a/source/java/org/alfresco/license/AlfrescoKeyStore.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2005 Alfresco, Inc. - * - * Licensed under the Alfresco Network License. You may obtain a - * copy of the License at - * - * http://www.alfrescosoftware.com/legal/ - * - * Please view the license relevant to your network subscription. - * - * BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING, - * READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"), - * YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE - * ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO - * THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE - * AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE - * TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE" - * BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY - * HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE - * SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE - * TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU - * CHECK THE "I UNDERSTAND AND ACCEPT" BOX. - */ -package org.alfresco.license; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - -import de.schlichtherle.license.KeyStoreParam; - - -/** - * Alfresco Public KeyStore Parameters - * - * @author davidc - */ -public class AlfrescoKeyStore implements KeyStoreParam -{ - // location of alfresco public keystore - private final static String KEYSTORE = "/org/alfresco/license/alfresco.keystore"; - - - /* (non-Javadoc) - * @see de.schlichtherle.license.KeyStoreParam#getStream() - */ - public InputStream getStream() throws IOException - { - final InputStream in = getClass().getResourceAsStream(KEYSTORE); - if (in == null) - { - throw new FileNotFoundException(KEYSTORE); - } - return in; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.KeyStoreParam#getStorePwd() - */ - public String getStorePwd() - { - return "ocs3rf1a"; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.KeyStoreParam#getAlias() - */ - public String getAlias() - { - return "alfresco"; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.KeyStoreParam#getKeyPwd() - */ - public String getKeyPwd() - { - // Note: not required for public key - return null; - } - -} diff --git a/source/java/org/alfresco/license/AlfrescoLicenseParam.java b/source/java/org/alfresco/license/AlfrescoLicenseParam.java deleted file mode 100644 index f1910c534e..0000000000 --- a/source/java/org/alfresco/license/AlfrescoLicenseParam.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2005 Alfresco, Inc. - * - * Licensed under the Alfresco Network License. You may obtain a - * copy of the License at - * - * http://www.alfrescosoftware.com/legal/ - * - * Please view the license relevant to your network subscription. - * - * BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING, - * READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"), - * YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE - * ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO - * THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE - * AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE - * TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE" - * BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY - * HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE - * SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE - * TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU - * CHECK THE "I UNDERSTAND AND ACCEPT" BOX. - */ -package org.alfresco.license; - -import java.util.prefs.Preferences; - -import javax.security.auth.x500.X500Principal; - -import org.alfresco.service.descriptor.DescriptorService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import de.schlichtherle.license.CipherParam; -import de.schlichtherle.license.KeyStoreParam; -import de.schlichtherle.license.LicenseContent; -import de.schlichtherle.license.ftp.LicenseParam; - - -/** - * Alfresco License Parameters - * - * @author davidc - */ -public class AlfrescoLicenseParam implements LicenseParam -{ - private static final Log logger = LogFactory.getLog(DescriptorService.class); - - private KeyStoreParam alfrescoStore = new AlfrescoKeyStore(); - private KeyStoreParam trialStore = new TrialKeyStore(); - private CipherParam cipherParam = new CipherParamImpl(); - private boolean createTrialLicense = true; - private int days = 30; - - - /** - * Construct - * - * @param createTrialLicense allow the creation of trial license - */ - public AlfrescoLicenseParam(boolean createTrialLicense) - { - this.createTrialLicense = createTrialLicense; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.ftp.LicenseParam#getFTPKeyStoreParam() - */ - public KeyStoreParam getFTPKeyStoreParam() - { - return trialStore; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.ftp.LicenseParam#getFTPDays() - */ - public int getFTPDays() - { - return days; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.ftp.LicenseParam#isFTPEligible() - */ - public boolean isFTPEligible() - { - return createTrialLicense; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.ftp.LicenseParam#createFTPLicenseContent() - */ - public LicenseContent createFTPLicenseContent() - { - if (logger.isInfoEnabled()) - logger.info("Alfresco license: Creating time limited trial license"); - - LicenseContent result = new LicenseContent(); - X500Principal holder = new X500Principal("O=Trial User"); - result.setHolder(holder); - X500Principal issuer = new X500Principal("CN=Unknown, OU=Unknown, O=Alfresco, L=Maidenhead, ST=Berkshire, C=UK"); - result.setIssuer(issuer); - result.setConsumerType("System"); - result.setConsumerAmount(1); - return result; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.ftp.LicenseParam#removeFTPEligibility() - */ - public void removeFTPEligibility() - { - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.ftp.LicenseParam#ftpGranted(de.schlichtherle.license.LicenseContent) - */ - public void ftpGranted(LicenseContent content) - { - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.LicenseParam#getSubject() - */ - public String getSubject() - { - return "Enterprise Network"; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.LicenseParam#getPreferences() - */ - public Preferences getPreferences() - { - // note: Alfresco license manager does not store licenses in Preferences - return null; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.LicenseParam#getKeyStoreParam() - */ - public KeyStoreParam getKeyStoreParam() - { - return alfrescoStore; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.LicenseParam#getCipherParam() - */ - public CipherParam getCipherParam() - { - return cipherParam; - } - -} diff --git a/source/java/org/alfresco/license/CipherParamImpl.java b/source/java/org/alfresco/license/CipherParamImpl.java deleted file mode 100644 index 179eb618df..0000000000 --- a/source/java/org/alfresco/license/CipherParamImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2005 Alfresco, Inc. - * - * Licensed under the Alfresco Network License. You may obtain a - * copy of the License at - * - * http://www.alfrescosoftware.com/legal/ - * - * Please view the license relevant to your network subscription. - * - * BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING, - * READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"), - * YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE - * ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO - * THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE - * AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE - * TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE" - * BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY - * HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE - * SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE - * TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU - * CHECK THE "I UNDERSTAND AND ACCEPT" BOX. - */ -package org.alfresco.license; - - -import de.schlichtherle.license.CipherParam; - - -/** - * Password used for license encryption - * - * @author davidc - */ -public class CipherParamImpl implements CipherParam -{ - - /* (non-Javadoc) - * @see de.schlichtherle.license.CipherParam#getKeyPwd() - */ - public String getKeyPwd() - { - return "j3ss13"; - }; - -} diff --git a/source/java/org/alfresco/license/LicenseComponent.java b/source/java/org/alfresco/license/LicenseComponent.java deleted file mode 100644 index 63fd017ff1..0000000000 --- a/source/java/org/alfresco/license/LicenseComponent.java +++ /dev/null @@ -1,493 +0,0 @@ -/* - * Copyright (C) 2005 Alfresco, Inc. - * - * Licensed under the Alfresco Network License. You may obtain a - * copy of the License at - * - * http://www.alfrescosoftware.com/legal/ - * - * Please view the license relevant to your network subscription. - * - * BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING, - * READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"), - * YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE - * ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO - * THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE - * AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE - * TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE" - * BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY - * HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE - * SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE - * TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU - * CHECK THE "I UNDERSTAND AND ACCEPT" BOX. - */ -package org.alfresco.license; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Properties; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.admin.patch.PatchDaoService; -import org.alfresco.repo.content.MimetypeMap; -import org.alfresco.repo.domain.AppliedPatch; -import org.alfresco.repo.importer.ImporterBootstrap; -import org.alfresco.repo.transaction.TransactionComponent; -import org.alfresco.repo.transaction.TransactionUtil; -import org.alfresco.repo.transaction.TransactionUtil.TransactionWork; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.repository.ContentReader; -import org.alfresco.service.cmr.repository.ContentService; -import org.alfresco.service.cmr.repository.ContentWriter; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.descriptor.DescriptorService; -import org.alfresco.service.license.LicenseDescriptor; -import org.alfresco.service.license.LicenseException; -import org.alfresco.service.license.LicenseService; -import org.alfresco.service.namespace.NamespaceService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.quartz.Job; -import org.quartz.JobDetail; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.SchedulerFactory; -import org.quartz.Trigger; -import org.quartz.helpers.TriggerUtils; -import org.quartz.impl.StdSchedulerFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; - -import de.schlichtherle.license.LicenseContent; -import de.schlichtherle.license.ftp.LicenseManager; -import de.schlichtherle.license.ftp.LicenseParam; - - -/** - * Alfresco Enterprise Network implementation of License Service - * - * @author davidc - */ -public class LicenseComponent implements LicenseService -{ - protected AlfrescoLicenseManager licenseManager; - private LicenseDescriptor licenseDescriptor = null; - - // dependencies - private TransactionComponent transactionComponent; - private ImporterBootstrap systemBootstrap; - private SearchService searchService; - private NamespaceService namespaceService; - protected NodeService nodeService; - protected ContentService contentService; - private Scheduler verifyScheduler = null; - private boolean failed = false; - - // logger - private static final Log logger = LogFactory.getLog(DescriptorService.class); - private static final Log loggerInternal = LogFactory.getLog(LicenseComponent.class); - - - /** - * Construct - * - * @param context application context - */ - public LicenseComponent(ApplicationContext context) - { - transactionComponent = (TransactionComponent)context.getBean("transactionComponent"); - systemBootstrap = (ImporterBootstrap)context.getBean("systemBootstrap"); - nodeService = (NodeService)context.getBean("nodeService"); - searchService = (SearchService)context.getBean("searchService"); - contentService = (ContentService)context.getBean("contentService"); - namespaceService = (NamespaceService)context.getBean(ServiceRegistry.NAMESPACE_SERVICE.getLocalName()); - - // construct license manager - boolean trialEligibility = getTrialEligibility(context); - licenseManager = new AlfrescoLicenseManager(new AlfrescoLicenseParam(trialEligibility)); - } - - /* (non-Javadoc) - * @see org.alfresco.service.license.LicenseService#verifyLicense() - */ - public void verifyLicense() - { - // check to see if there's a license to install - File licenseFile = getLicenseFile(); - if (licenseFile != null) - { - if (logger.isInfoEnabled()) - logger.info("Alfresco license: Installing license file " + licenseFile.getName()); - - try - { - LicenseContent licenseContent = licenseManager.install(licenseFile); - renameLicenseFile(licenseFile); - licenseDescriptor = new LicenseContentDescriptor(licenseContent); - } - catch(Exception e) - { - throw new LicenseException("Failed to install license file " + licenseFile.getName(), e); - } - } - - // verify existing license - if (licenseDescriptor == null) - { - verify(); - - // construct scheduler for period license verify - SchedulerFactory schedulerFactory = new StdSchedulerFactory(); - try - { - verifyScheduler = schedulerFactory.getScheduler(); - JobDetail jobDetail = new JobDetail("vlj", Scheduler.DEFAULT_GROUP, VerifyLicenseJob.class); - jobDetail.getJobDataMap().put("licenseComponent", this); - Trigger trigger = TriggerUtils.makeHourlyTrigger(); - trigger.setStartTime(new Date(System.currentTimeMillis() + (60L * 1000L))); // one minute from now - trigger.setName("vlt"); - trigger.setGroup(Scheduler.DEFAULT_GROUP); - verifyScheduler.scheduleJob(jobDetail, trigger); - verifyScheduler.start(); - } - catch(SchedulerException e) - { - throw new LicenseException("Failed to initialise License Component"); - } - } - } - - /** - * Verify License - */ - protected void verify() - { - // note: if a license hasn't been already been installed then install - // a free trial period - TransactionWork verifyLicense = new TransactionUtil.TransactionWork() - { - public LicenseDescriptor doWork() - { - LicenseDescriptor descriptor = null; - try - { - LicenseContent licenseContent = licenseManager.verify(); - descriptor = new LicenseContentDescriptor(licenseContent); - } - catch(Exception e) - { - // handle license failure case - licenseFailed(e); - } - return descriptor; - } - }; - licenseDescriptor = TransactionUtil.executeInUserTransaction(transactionComponent, verifyLicense); - } - - /** - * Handle case where license is found to be invalid - */ - protected void licenseFailed(Exception e) - throws LicenseException - { - if (!failed) - { - // Mark transactions as read-only - transactionComponent.setAllowWrite(false); - - if (logger.isWarnEnabled()) - { - logger.warn("Alfresco license: Failed to verify license - Invalid License!"); - logger.warn("Alfresco license: Restricted Alfresco Repository to read-only capability"); - } - if (loggerInternal.isDebugEnabled()) - { - loggerInternal.debug("Alfresco license: Failed due to " + e.toString()); - } - failed = true; - } - } - - /* (non-Javadoc) - * @see org.alfresco.service.license.LicenseService#getLicense() - */ - public LicenseDescriptor getLicense() - { - return licenseDescriptor; - } - - /** - * Determine if a license file is to be installed - * - * @return the license file (or null, if one is not to be installed) - */ - private File getLicenseFile() - { - File licenseFile = null; - - PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); - try - { - Resource[] resources = resolver.getResources("classpath*:/alfresco/extension/license/*.lic"); - if (resources.length > 1) - { - String resMsg = ""; - for (Resource resource : resources) - { - resMsg += "[" + resource.getURL().toExternalForm() + "] "; - } - throw new LicenseException("Found more than one license file to install. The licenses found are: " + resMsg); - } - if (resources.length > 0) - { - licenseFile = resources[0].getFile(); - } - } - catch (IOException e) - { - // Note: Ignore: license not found - } - - return licenseFile; - } - - /** - * Rename installed license file - * - * @param licenseFile license file to rename - */ - private void renameLicenseFile(File licenseFile) - { - File dest = new File(licenseFile.getAbsolutePath() + ".installed"); - boolean success = false; - try - { - success = licenseFile.renameTo(dest); - } - catch(Exception e) - { - } - - if (!success) - { - if (logger.isWarnEnabled()) - logger.warn("Alfresco license: Failed to rename installed license file " + licenseFile.getName() + " to " + dest.getName()); - } - } - - /** - * Determine if eligible for trial license creation - * - * @param context application context - * @return true => trial license may be created - */ - private boolean getTrialEligibility(ApplicationContext context) - { - // from clean (open) - // from clean (enterprise) - // ==> systemBootstrap == true - - // upgrade from 1.2.1 open to 1.2.1 enterprise - // ==> patch = true, schema >= 12, versionEdition = open - - // upgrade from 1.2.1 open to 1.3.0 enterprise - // ==> patch = true, schema >= 12, versionEdition = open - - // upgrade from 1.2.1 enterprise to 1.3.0 enterprise - // ==> patch = true, schema >= 12, versionEdition = license - - // upgrade from 1.2 open to 1.2.1+ enterprise - // ==> patch = false, schema < 12, versionEdition = null - - // upgrade from 1.2 enterprise to 1.2.1+ enterprise - // ==> patch = false, schema < 12, versionEdition = null - - - // first determine if the system store has been bootstrapped in this startup sequence - // if so, a trial license may be created - boolean trialEligibility = systemBootstrap.hasPerformedBootstrap(); - - if (loggerInternal.isDebugEnabled()) - loggerInternal.debug("Alfresco license: System store bootstrapped: " + trialEligibility); - - // if not, then this could be a pre-installed repository that has yet to be patched with a license - if (!trialEligibility) - { - NodeRef descriptorRef = getDescriptor(); - if (descriptorRef != null) - { - PatchDaoService patchDao = (PatchDaoService)context.getBean("patchDaoComponent"); - AppliedPatch patch = patchDao.getAppliedPatch("patch.descriptorUpdate"); - - // versionEdition = open - // patch = true, schema >= 12 - - // versionEdition = null - // patch = false, schema < 12 - - // versionEdition = license - // not eligible - - int schema = (Integer)nodeService.getProperty(descriptorRef, ContentModel.PROP_SYS_VERSION_SCHEMA); - Serializable value = nodeService.getProperty(descriptorRef, ContentModel.PROP_SYS_VERSION_EDITION); - - if (loggerInternal.isDebugEnabled()) - { - loggerInternal.debug("Alfresco license: patch applied: " + (patch != null)); - loggerInternal.debug("Alfresco license: schema: " + schema); - loggerInternal.debug("Alfresco license: edition: " + value); - } - - if (value == null) - { - trialEligibility = (patch == null) && schema < 12; - } - else if (value instanceof Collection) - { - Collection editions = (Collection)value; - Object editionsValue = (editions.size() > 0) ? editions.iterator().next() : null; - String edition = (editionsValue instanceof String) ? (String)editionsValue : ""; - trialEligibility = (patch != null) && schema >=12 && edition.equals("Community Network"); - } - } - } - - if (loggerInternal.isDebugEnabled()) - loggerInternal.debug("Alfresco license: trial eligibility: " + trialEligibility); - - return trialEligibility; - } - - /** - * Get System Store Descriptor - * - * @return node reference of system store descriptor - */ - protected NodeRef getDescriptor() - { - StoreRef storeRef = systemBootstrap.getStoreRef(); - List nodeRefs = null; - - if (nodeService.exists(storeRef)) - { - Properties systemProperties = systemBootstrap.getConfiguration(); - String path = systemProperties.getProperty("system.descriptor.current.childname"); - String searchPath = "/" + path; - NodeRef rootNodeRef = nodeService.getRootNode(storeRef); - nodeRefs = searchService.selectNodes(rootNodeRef, searchPath, null, namespaceService, false); - } - - return (nodeRefs == null || nodeRefs.size() == 0) ? null : nodeRefs.get(0); - } - - - /** - * Job for period license verification - * - * @author davidc - */ - public static class VerifyLicenseJob implements Job - { - public void execute(JobExecutionContext context) throws JobExecutionException - { - LicenseComponent license = (LicenseComponent)context.getJobDetail().getJobDataMap().get("licenseComponent"); - license.verify(); - } - } - - - /** - * Alfresco implementation of License Manager - * - * Note: Stores verified license files in Alfresco Repository - * - * @author davidc - */ - public class AlfrescoLicenseManager extends LicenseManager - { - /** - * Construct - * - * @param context application context - * @param param license parameters - */ - public AlfrescoLicenseManager(LicenseParam param) - { - super(param); - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.LicenseManager#getLicenseKey() - */ - protected byte[] getLicenseKey() - { - byte[] key = null; - - try - { - NodeRef descriptorRef = getDescriptor(); - if (descriptorRef == null) - { - throw new LicenseException("Failed to find system descriptor"); - } - ContentReader reader = contentService.getReader(descriptorRef, ContentModel.PROP_SYS_VERSION_EDITION); - if (reader != null && reader.exists()) - { - ByteArrayOutputStream os = new ByteArrayOutputStream(); - reader.getContent(os); - key = os.toByteArray(); - } - } - catch(Exception e) - { - throw new LicenseException("Failed to load license", e); - } - return key; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.LicenseManager#setLicenseKey(byte[]) - */ - protected synchronized void setLicenseKey(final byte[] key) - { - try - { - NodeRef descriptorRef = getDescriptor(); - if (descriptorRef == null) - { - throw new LicenseException("Failed to find system descriptor"); - } - if (key == null) - { - nodeService.setProperty(descriptorRef, ContentModel.PROP_SYS_VERSION_EDITION, null); - } - else - { - ContentWriter writer = contentService.getWriter(descriptorRef, ContentModel.PROP_SYS_VERSION_EDITION, true); - InputStream is = new ByteArrayInputStream(key); - writer.setMimetype(MimetypeMap.MIMETYPE_BINARY); - writer.putContent(is); - } - } - catch(Exception e) - { - throw new LicenseException("Failed to save license", e); - } - } - - } -} diff --git a/source/java/org/alfresco/license/LicenseContentDescriptor.java b/source/java/org/alfresco/license/LicenseContentDescriptor.java deleted file mode 100644 index 776d3da1e5..0000000000 --- a/source/java/org/alfresco/license/LicenseContentDescriptor.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2005 Alfresco, Inc. - * - * Licensed under the Alfresco Network License. You may obtain a - * copy of the License at - * - * http://www.alfrescosoftware.com/legal/ - * - * Please view the license relevant to your network subscription. - * - * BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING, - * READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"), - * YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE - * ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO - * THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE - * AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE - * TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE" - * BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY - * HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE - * SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE - * TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU - * CHECK THE "I UNDERSTAND AND ACCEPT" BOX. - */ -package org.alfresco.license; - -import java.security.Principal; -import java.util.Date; - -import org.alfresco.service.license.LicenseDescriptor; -import org.joda.time.DateMidnight; -import org.joda.time.Interval; -import org.joda.time.Period; -import org.joda.time.PeriodType; - -import de.schlichtherle.license.LicenseContent; - - -/** - * License Descriptor - * - * @author davidc - */ -public class LicenseContentDescriptor implements LicenseDescriptor -{ - private LicenseContent licenseContent = null; - - /** - * Construct - * - * @param licenseContent - */ - public LicenseContentDescriptor(LicenseContent licenseContent) - { - this.licenseContent = licenseContent; - } - - /* (non-Javadoc) - * @see org.alfresco.service.license.LicenseDescriptor#getIssued() - */ - public Date getIssued() - { - return licenseContent.getIssued(); - } - - /* (non-Javadoc) - * @see org.alfresco.service.license.LicenseDescriptor#getValidUntil() - */ - public Date getValidUntil() - { - return licenseContent.getNotAfter(); - } - - /* (non-Javadoc) - * @see org.alfresco.service.license.LicenseDescriptor#getSubject() - */ - public String getSubject() - { - return licenseContent.getSubject(); - } - - /* (non-Javadoc) - * @see org.alfresco.service.license.LicenseDescriptor#getHolder() - */ - public Principal getHolder() - { - return licenseContent.getHolder(); - } - - /* (non-Javadoc) - * @see org.alfresco.service.license.LicenseDescriptor#getIssuer() - */ - public Principal getIssuer() - { - return licenseContent.getIssuer(); - } - - /* (non-Javadoc) - * @see org.alfresco.service.license.LicenseDescriptor#getDays() - */ - public Integer getDays() - { - Integer days = null; - Date validUntil = getValidUntil(); - if (validUntil != null) - { - Date issued = getIssued(); - days = new Integer(calcDays(issued, validUntil)); - } - return days; - } - - /* (non-Javadoc) - * @see org.alfresco.service.license.LicenseDescriptor#getRemainingDays() - */ - public Integer getRemainingDays() - { - Integer days = null; - Date validUntil = getValidUntil(); - if (validUntil != null) - { - Date now = new Date(); - days = new Integer(calcDays(now, validUntil)); - } - return days; - } - - /** - * Calculate number of days between start and end date - * - * @param start start date - * @param end end date - * @return number days between - */ - private int calcDays(Date start, Date end) - { - DateMidnight startMidnight = new DateMidnight(start); - DateMidnight endMidnight = new DateMidnight(end); - - int days; - if (endMidnight.isBefore(startMidnight)) - { - Interval interval = new Interval(endMidnight, startMidnight); - Period period = interval.toPeriod(PeriodType.days()); - days = 0 - period.getDays(); - } - else - { - Interval interval = new Interval(startMidnight, endMidnight); - Period period = interval.toPeriod(PeriodType.days()); - days = period.getDays(); - } - return days; - } - -} diff --git a/source/java/org/alfresco/license/TrialKeyStore.java b/source/java/org/alfresco/license/TrialKeyStore.java deleted file mode 100644 index 1065aa39c7..0000000000 --- a/source/java/org/alfresco/license/TrialKeyStore.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2005 Alfresco, Inc. - * - * Licensed under the Alfresco Network License. You may obtain a - * copy of the License at - * - * http://www.alfrescosoftware.com/legal/ - * - * Please view the license relevant to your network subscription. - * - * BY CLICKING THE "I UNDERSTAND AND ACCEPT" BOX, OR INSTALLING, - * READING OR USING ALFRESCO'S Network SOFTWARE (THE "SOFTWARE"), - * YOU ARE AGREEING ON BEHALF OF THE ENTITY LICENSING THE SOFTWARE - * ("COMPANY") THAT COMPANY WILL BE BOUND BY AND IS BECOMING A PARTY TO - * THIS ALFRESCO NETWORK AGREEMENT ("AGREEMENT") AND THAT YOU HAVE THE - * AUTHORITY TO BIND COMPANY. IF COMPANY DOES NOT AGREE TO ALL OF THE - * TERMS OF THIS AGREEMENT, DO NOT SELECT THE "I UNDERSTAND AND AGREE" - * BOX AND DO NOT INSTALL THE SOFTWARE OR VIEW THE SOURCE CODE. COMPANY - * HAS NOT BECOME A LICENSEE OF, AND IS NOT AUTHORIZED TO USE THE - * SOFTWARE UNLESS AND UNTIL IT HAS AGREED TO BE BOUND BY THESE LICENSE - * TERMS. THE "EFFECTIVE DATE" FOR THIS AGREEMENT SHALL BE THE DAY YOU - * CHECK THE "I UNDERSTAND AND ACCEPT" BOX. - */ -package org.alfresco.license; - - -/** - * Alfresco Trial KeyStore Parameters - * - * @author davidc - */ -public class TrialKeyStore extends AlfrescoKeyStore -{ - /* (non-Javadoc) - * @see de.schlichtherle.license.KeyStoreParam#getAlias() - */ - public String getAlias() - { - return "alfrescoTrial"; - } - - /* (non-Javadoc) - * @see de.schlichtherle.license.KeyStoreParam#getKeyPwd() - */ - public String getKeyPwd() - { - return "la1rtocs3rf1a"; - } - -} diff --git a/source/java/org/alfresco/license/alfresco.keystore b/source/java/org/alfresco/license/alfresco.keystore deleted file mode 100644 index 18ba225ae3..0000000000 Binary files a/source/java/org/alfresco/license/alfresco.keystore and /dev/null differ