diff --git a/config/alfresco/template-services-context.xml b/config/alfresco/template-services-context.xml
index 85bbc2d934..5492cf5b57 100644
--- a/config/alfresco/template-services-context.xml
+++ b/config/alfresco/template-services-context.xml
@@ -1,156 +1,159 @@
-
-
-
-
-
-
-
- freemarker
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- freemarker
-
-
- ftl
-
-
-
-
-
-
-
-
-
-
-
-
- avm
-
-
-
-
-
-
-
-
- session
-
-
-
-
-
-
-
-
- classification
-
-
- ${spaces.store}
-
-
-
-
-
-
-
-
- workflow
-
-
-
-
-
-
-
-
- people
-
-
- ${spaces.store}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- site
-
-
-
-
-
-
-
-
-
-
-
- hasAspect
-
-
-
-
-
- hasPermission
-
-
-
-
-
- message
-
-
-
-
-
- dateCompare
-
-
-
-
-
- incrementDate
-
-
-
-
-
- xmldate
-
-
-
-
-
- cropContent
-
-
-
-
+
+
+
+
+
+
+
+ freemarker
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ freemarker
+
+
+ ftl
+
+
+
+
+
+
+
+
+
+
+
+
+ avm
+
+
+
+
+
+
+
+
+ session
+
+
+
+
+
+
+
+
+ classification
+
+
+ ${spaces.store}
+
+
+
+
+
+
+
+
+ workflow
+
+
+
+
+
+
+
+
+ people
+
+
+ ${spaces.store}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ site
+
+
+
+
+
+
+
+
+
+
+
+ hasAspect
+
+
+
+
+
+ hasPermission
+
+
+
+
+
+ message
+
+
+
+
+
+ dateCompare
+
+
+
+
+
+ incrementDate
+
+
+
+
+
+ xmldate
+
+
+
+
+
+ cropContent
+
+
+
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/jscript/People.java b/source/java/org/alfresco/repo/jscript/People.java
index c085572f35..2fa6228b40 100644
--- a/source/java/org/alfresco/repo/jscript/People.java
+++ b/source/java/org/alfresco/repo/jscript/People.java
@@ -29,6 +29,7 @@ import java.util.StringTokenizer;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.authentication.PasswordGenerator;
import org.alfresco.repo.security.authentication.UserNameGenerator;
@@ -53,6 +54,7 @@ import org.mozilla.javascript.Scriptable;
* Scripted People service for describing and executing actions against People & Groups.
*
* @author davidc
+ * @author kevinr
*/
public final class People extends BaseScopableProcessorExtension
{
@@ -174,8 +176,7 @@ public final class People extends BaseScopableProcessorExtension
* @return the person node (type cm:person) created or null if the person
* could not be created
*/
- public ScriptNode createPerson(boolean createUserAccount,
- boolean setAccountEnabled)
+ public ScriptNode createPerson(boolean createUserAccount, boolean setAccountEnabled)
{
ParameterCheck.mandatory("createUserAccount", createUserAccount);
ParameterCheck.mandatory("setAccountEnabled", setAccountEnabled);
@@ -213,13 +214,41 @@ public final class People extends BaseScopableProcessorExtension
}
/**
- * Enable person's user account
+ * Enable user account. Can only be called by an Admin authority.
*
- * @param userName user name of person for which to enable user account
+ * @param userName user name for which to enable user account
*/
- public void enablePerson(String userName)
+ public void enableAccount(String userName)
{
- mutableAuthenticationDao.setEnabled(userName, true);
+ if (this.authorityService.isAdminAuthority(AuthenticationUtil.getFullyAuthenticatedUser()))
+ {
+ this.mutableAuthenticationDao.setEnabled(userName, true);
+ }
+ }
+
+ /**
+ * Disable user account. Can only be called by an Admin authority.
+ *
+ * @param userName user name for which to disable user account
+ */
+ public void disableAccount(String userName)
+ {
+ if (this.authorityService.isAdminAuthority(AuthenticationUtil.getFullyAuthenticatedUser()))
+ {
+ this.mutableAuthenticationDao.setEnabled(userName, false);
+ }
+ }
+
+ /**
+ * Return true if the specified user account is enabled.
+ *
+ * @param userName user name to test account
+ *
+ * @return true if account enabled, false if disabled
+ */
+ public boolean isAccountEnabled(String userName)
+ {
+ return this.mutableAuthenticationDao.getEnabled(userName);
}
/**
@@ -246,7 +275,6 @@ public final class People extends BaseScopableProcessorExtension
return person;
}
-
/**
* Get the collection of people stored in the repository.
* An optional filter query may be provided by which to filter the people collection.
diff --git a/source/java/org/alfresco/repo/template/People.java b/source/java/org/alfresco/repo/template/People.java
index 467f9a07e3..fce635a494 100644
--- a/source/java/org/alfresco/repo/template/People.java
+++ b/source/java/org/alfresco/repo/template/People.java
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Set;
import org.alfresco.model.ContentModel;
+import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.authority.AuthorityDAO;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -50,6 +51,7 @@ public class People extends BaseTemplateProcessorExtension
private ServiceRegistry services;
private AuthorityDAO authorityDAO;
private AuthorityService authorityService;
+ private MutableAuthenticationDao mutableAuthenticationDao;
private PersonService personService;
private StoreRef storeRef;
@@ -109,6 +111,16 @@ public class People extends BaseTemplateProcessorExtension
this.personService = personService;
}
+ /**
+ * Set the mutable authentication dao
+ *
+ * @param mutableAuthenticationDao Mutable Authentication DAO
+ */
+ public void setMutableAuthenticationDao(MutableAuthenticationDao mutableAuthenticationDao)
+ {
+ this.mutableAuthenticationDao = mutableAuthenticationDao;
+ }
+
/**
* Gets the Person given the username
*
@@ -212,6 +224,18 @@ public class People extends BaseTemplateProcessorExtension
ParameterCheck.mandatory("Person", person);
return this.authorityService.isAdminAuthority((String)person.getProperties().get(ContentModel.PROP_USERNAME));
}
+
+ /**
+ * Return true if the specified user account is enabled.
+ *
+ * @param person to test
+ *
+ * @return true if account enabled, false if disabled
+ */
+ public boolean isAccountEnabled(TemplateNode person)
+ {
+ return this.mutableAuthenticationDao.getEnabled((String)person.getProperties().get(ContentModel.PROP_USERNAME));
+ }
/**
* Get Contained Authorities