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
* *
@@ -389,9 +409,12 @@ public class AdministrationWebService extends AbstractWebService implements
int index = 0; int index = 0;
for (NewUserDetails newUser : newUsers) for (NewUserDetails newUser : newUsers)
{
if (this.manageAuthenticationDetails == true)
{ {
// Create a new authentication // Create a new authentication
this.authenticationService.createAuthentication(newUser.getUserName(), newUser.getPassword().toCharArray()); 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);
@@ -507,6 +530,8 @@ public class AdministrationWebService extends AbstractWebService implements
* @param newPassword the new password * @param newPassword the new password
*/ */
private void changePasswordImpl(String userName, String oldPassword, String newPassword) private void changePasswordImpl(String userName, String oldPassword, String newPassword)
{
if (this.manageAuthenticationDetails == true)
{ {
// Update the authentication details // Update the authentication details
if (this.authenticationService.getCurrentUserName().equals("admin") == true) if (this.authenticationService.getCurrentUserName().equals("admin") == true)
@@ -518,6 +543,11 @@ public class AdministrationWebService extends AbstractWebService implements
this.authenticationService.updateAuthentication(userName, oldPassword.toCharArray(), newPassword.toCharArray()); this.authenticationService.updateAuthentication(userName, oldPassword.toCharArray(), newPassword.toCharArray());
} }
} }
else
{
throw new RuntimeException("Web service has been configured so that user authenticaiton details are not managed.");
}
}
/** /**
* @see org.alfresco.repo.webservice.administration.AdministrationServiceSoapPort#deleteUsers(java.lang.String[]) * @see org.alfresco.repo.webservice.administration.AdministrationServiceSoapPort#deleteUsers(java.lang.String[])
@@ -556,8 +586,11 @@ public class AdministrationWebService extends AbstractWebService implements
private void deleteUsersImpl(String[] userNames) private void deleteUsersImpl(String[] userNames)
{ {
for (String userName : userNames) for (String userName : userNames)
{
if (this.manageAuthenticationDetails == true)
{ {
this.authenticationService.deleteAuthentication(userName); this.authenticationService.deleteAuthentication(userName);
}
this.personService.deletePerson(userName); this.personService.deletePerson(userName);
} }
} }