Merged V2.1-A to HEAD

7710:  Added spring configuration to administration web service to prevent management of user authentication details  



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12716 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2009-01-13 17:56:00 +00:00
parent c66f7503f9
commit 4ef9a86c62
2 changed files with 43 additions and 7 deletions

View File

@@ -224,6 +224,9 @@
<property name="querySessionCache"> <property name="querySessionCache">
<ref bean="webServicesQuerySessionCache"/> <ref bean="webServicesQuerySessionCache"/>
</property> </property>
<property name="manageAuthenticationDetails">
<value>true</value>
</property>
</bean> </bean>
</beans> </beans>

View File

@@ -65,6 +65,15 @@ public class AdministrationWebService extends AbstractWebService implements
/** The person service */ /** The person service */
private PersonService personService = null; private PersonService personService = null;
/**
* Indicates whether the user administration methods should manage the authentication
* details, or just the person details.
*
* Set this to true if an 3rd party authentication implementation has been pluged into
* the repository that manages authentication details.
*/
private boolean manageAuthenticationDetails = true;
/** The authentication service */ /** The authentication service */
private AuthenticationService authenticationService = null; private AuthenticationService authenticationService = null;
@@ -85,6 +94,17 @@ public class AdministrationWebService extends AbstractWebService implements
AdministrationWebService.ignoredProperties.add(ContentModel.PROP_NODE_UUID); AdministrationWebService.ignoredProperties.add(ContentModel.PROP_NODE_UUID);
} }
/**
* Set the flag that indicates whether this service should manage user authentication details as
* well as person details.
*
* @param manageAuthenticationDetails true if authentication details are managed, false otherwise
*/
public void setManageAuthenticationDetails(boolean manageAuthenticationDetails)
{
this.manageAuthenticationDetails = manageAuthenticationDetails;
}
/** /**
* Set the transaction service * Set the transaction service
* *
@@ -390,8 +410,11 @@ public class AdministrationWebService extends AbstractWebService implements
int index = 0; int index = 0;
for (NewUserDetails newUser : newUsers) for (NewUserDetails newUser : newUsers)
{ {
// Create a new authentication if (this.manageAuthenticationDetails == true)
this.authenticationService.createAuthentication(newUser.getUserName(), newUser.getPassword().toCharArray()); {
// Create a new authentication
this.authenticationService.createAuthentication(newUser.getUserName(), newUser.getPassword().toCharArray());
}
// Create a new person // Create a new person
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7);
@@ -508,14 +531,21 @@ public class AdministrationWebService extends AbstractWebService implements
*/ */
private void changePasswordImpl(String userName, String oldPassword, String newPassword) private void changePasswordImpl(String userName, String oldPassword, String newPassword)
{ {
// Update the authentication details if (this.manageAuthenticationDetails == true)
if (this.authenticationService.getCurrentUserName().equals("admin") == true)
{ {
this.authenticationService.setAuthentication(userName, newPassword.toCharArray()); // Update the authentication details
if (this.authenticationService.getCurrentUserName().equals("admin") == true)
{
this.authenticationService.setAuthentication(userName, newPassword.toCharArray());
}
else
{
this.authenticationService.updateAuthentication(userName, oldPassword.toCharArray(), newPassword.toCharArray());
}
} }
else else
{ {
this.authenticationService.updateAuthentication(userName, oldPassword.toCharArray(), newPassword.toCharArray()); throw new RuntimeException("Web service has been configured so that user authenticaiton details are not managed.");
} }
} }
@@ -557,7 +587,10 @@ public class AdministrationWebService extends AbstractWebService implements
{ {
for (String userName : userNames) for (String userName : userNames)
{ {
this.authenticationService.deleteAuthentication(userName); if (this.manageAuthenticationDetails == true)
{
this.authenticationService.deleteAuthentication(userName);
}
this.personService.deletePerson(userName); this.personService.deletePerson(userName);
} }
} }