mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -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;
|
||||||
@@ -96,6 +98,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;
|
||||||
|
|
||||||
@@ -128,6 +133,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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4388,6 +4388,10 @@
|
|||||||
<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>
|
||||||
@@ -4439,6 +4443,10 @@
|
|||||||
<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>
|
||||||
|
Reference in New Issue
Block a user