MT - put back tenant username functionality MIA after dialog conversion (NewUserWizard -> CreateUserWizard)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7752 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-01-04 11:59:02 +00:00
parent b7965af43d
commit 1b466e3f12
2 changed files with 64 additions and 1 deletions

View File

@@ -40,6 +40,8 @@ import javax.faces.validator.ValidatorException;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthenticationService; import org.alfresco.service.cmr.security.AuthenticationService;
@@ -95,6 +97,9 @@ public class CreateUserWizard extends BaseWizardBean
/** PersonService bean reference */ /** PersonService bean reference */
private PersonService personService; private PersonService personService;
/** TenantService bean reference */
private TenantService tenantService;
/** PermissionService bean reference */ /** PermissionService bean reference */
private PermissionService permissionService; private PermissionService permissionService;
@@ -127,6 +132,14 @@ public class CreateUserWizard extends BaseWizardBean
{ {
this.personService = personService; this.personService = personService;
} }
/**
* @param tenantService The tenantService to set.
*/
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
/** /**
* @param permissionService The PermissionService to set. * @param permissionService The PermissionService to set.
@@ -185,6 +198,18 @@ public class CreateUserWizard extends BaseWizardBean
*/ */
public String getSummary() public String getSummary()
{ {
if (tenantService.isEnabled())
{
try
{
checkTenantUserName();
}
catch (Exception e)
{
// TODO - ignore for now, but ideally should handle earlier
}
}
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance()); ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
String homeSpaceLabel = this.homeSpaceName; String homeSpaceLabel = this.homeSpaceName;
@@ -682,6 +707,11 @@ public class CreateUserWizard extends BaseWizardBean
{ {
if (this.password.equals(this.confirm)) if (this.password.equals(this.confirm))
{ {
if (tenantService.isEnabled())
{
checkTenantUserName();
}
// create properties for Person type from submitted Form data // create properties for Person type from submitted Form data
Map<QName, Serializable> props = new HashMap<QName, Serializable>(7, 1.0f); Map<QName, Serializable> props = new HashMap<QName, Serializable>(7, 1.0f);
props.put(ContentModel.PROP_USERNAME, this.userName); props.put(ContentModel.PROP_USERNAME, this.userName);
@@ -814,4 +844,29 @@ public class CreateUserWizard extends BaseWizardBean
} }
return new Pair<Long, String>(size, units); return new Pair<Long, String>(size, units);
} }
protected void checkTenantUserName()
{
String currentDomain = tenantService.getCurrentUserDomain();
if (currentDomain != null)
{
if (! tenantService.isTenantUser(this.userName))
{
// force domain onto the end of the username
this.userName = tenantService.getDomainUser(this.userName, currentDomain);
logger.warn("Added domain to username: " + this.userName);
}
else
{
try
{
tenantService.checkDomainUser(this.userName);
}
catch (RuntimeException re)
{
throw new AuthenticationException("User must belong to same domain as admin: " + currentDomain);
}
}
}
}
} }

View File

@@ -4387,6 +4387,10 @@
<managed-property> <managed-property>
<property-name>personService</property-name> <property-name>personService</property-name>
<value>#{PersonService}</value> <value>#{PersonService}</value>
</managed-property>
<managed-property>
<property-name>tenantService</property-name>
<value>#{tenantService}</value>
</managed-property> </managed-property>
<managed-property> <managed-property>
<property-name>ownableService</property-name> <property-name>ownableService</property-name>
@@ -4438,7 +4442,11 @@
<managed-property> <managed-property>
<property-name>personService</property-name> <property-name>personService</property-name>
<value>#{PersonService}</value> <value>#{PersonService}</value>
</managed-property> </managed-property>
<managed-property>
<property-name>tenantService</property-name>
<value>#{tenantService}</value>
</managed-property>
<managed-property> <managed-property>
<property-name>ownableService</property-name> <property-name>ownableService</property-name>
<value>#{OwnableService}</value> <value>#{OwnableService}</value>