本文整理汇总了Java中org.alfresco.repo.security.sync.UserRegistrySynchronizer类的典型用法代码示例。如果您正苦于以下问题:Java UserRegistrySynchronizer类的具体用法?Java UserRegistrySynchronizer怎么用?Java UserRegistrySynchronizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserRegistrySynchronizer类属于org.alfresco.repo.security.sync包,在下文中一共展示了UserRegistrySynchronizer类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareTestConditions
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
private TestContext prepareTestConditions(boolean autoCreatePeopleOnLogin, String userName) throws Exception
{
UserRegistrySynchronizer userRegistrySynchronizer = makeUserRegistrySynchronizerStub(autoCreatePeopleOnLogin);
((AbstractAuthenticationComponent) cifsAuthenticator.getAuthenticationComponent()).setUserRegistrySynchronizer(userRegistrySynchronizer);
ClientInfo client = mock(AlfrescoClientInfo.class);
client.setUserName(userName);
SrvSession sess = mock(SMBSrvSession.class);
sess.setUniqueId(userName);
// add getter to the original class, otherwise reflection should be used to add session to private field
AuthenticateSession as = mock(AuthenticateSession.class);
// assume successful passthru authentication
doNothing().when(as).doSessionSetup(anyString(), anyString(), anyString(), any(byte[].class), any(byte[].class), anyInt());
PassthruDetails pd = new PassthruDetails(sess, as);
cifsAuthenticator.getSessions().put(userName, pd);
return new TestContext(client, sess);
}
示例2: makeUserRegistrySynchronizerStub
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
private UserRegistrySynchronizer makeUserRegistrySynchronizerStub(final boolean autoCreatePeopleOnLogin)
{
UserRegistrySynchronizer stub = mock(UserRegistrySynchronizer.class);
when(stub.createMissingPerson(anyString())).thenAnswer(new Answer<Boolean>()
{
public Boolean answer(InvocationOnMock invocation) throws Throwable
{
Object[] args = invocation.getArguments();
String userName = (String) args[0];
if (userName != null && !userName.equals(AuthenticationUtil.getSystemUserName()))
{
PersonService personServiceStub = mock(PersonService.class);
when(personServiceStub.createMissingPeople()).thenReturn(true);
if (autoCreatePeopleOnLogin && personServiceStub.createMissingPeople())
{
AuthorityType authorityType = AuthorityType.getAuthorityType(userName);
if (authorityType == AuthorityType.USER)
{
personService.getPerson(userName);
return true;
}
}
}
return false;
}
});
return stub;
}
示例3: testExistingUserMappingWhenAutoCreateNotAllowed
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
@Test
public void testExistingUserMappingWhenAutoCreateNotAllowed()
{
UserRegistrySynchronizer userRegistrySynchronizer = makeUserRegistrySynchronizerStub(false);
((AbstractAuthenticationComponent) cifsAuthenticator.getAuthenticationComponent()).setUserRegistrySynchronizer(userRegistrySynchronizer);
String username = cifsAuthenticator.mapUserNameToPerson(userExistingLocal, false);
assertEquals("Existing local user should be mapped to authenticated AD user", username, userExistingLocal);
}
示例4: testExistingUserMappingWhenAutoCreateAllowed
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
@Test
public void testExistingUserMappingWhenAutoCreateAllowed()
{
UserRegistrySynchronizer userRegistrySynchronizer = makeUserRegistrySynchronizerStub(true);
((AbstractAuthenticationComponent) cifsAuthenticator.getAuthenticationComponent()).setUserRegistrySynchronizer(userRegistrySynchronizer);
String username = cifsAuthenticator.mapUserNameToPerson(userExistingLocal, false);
assertEquals("Existing local user should be mapped to authenticated AD user", username, userExistingLocal);
}
示例5: testMissingUserMappingWhenAutoCreateNotAllowed
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
@Test
public void testMissingUserMappingWhenAutoCreateNotAllowed()
{
UserRegistrySynchronizer userRegistrySynchronizer = makeUserRegistrySynchronizerStub(false);
((AbstractAuthenticationComponent) cifsAuthenticator.getAuthenticationComponent()).setUserRegistrySynchronizer(userRegistrySynchronizer);
try
{
cifsAuthenticator.mapUserNameToPerson(userMissingLocal, false);
fail("User that does not exist in repository should not login when autoCreatePeopleOnLogin is not allowed");
}
catch (AuthenticationException expected)
{
}
}
示例6: testMissingUserMappingWhenAutoCreateAllowed
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
@Test
public void testMissingUserMappingWhenAutoCreateAllowed()
{
UserRegistrySynchronizer userRegistrySynchronizer = makeUserRegistrySynchronizerStub(true);
((AbstractAuthenticationComponent) cifsAuthenticator.getAuthenticationComponent()).setUserRegistrySynchronizer(userRegistrySynchronizer);
String username = cifsAuthenticator.mapUserNameToPerson(userMissingLocal, false);
assertEquals("User that does not exist in repository can login when autoCreatePeopleOnLogin is allowed", username, userMissingLocal);
// personService.personExists requires RunAsUser to be set
AuthenticationUtil.setRunAsUser(AuthenticationUtil.getSystemUserName());
assertTrue(personService.personExists(userMissingLocal));
}
示例7: makeUserRegistrySynchronizerStub
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
private UserRegistrySynchronizer makeUserRegistrySynchronizerStub(final boolean autoCreatePeopleOnLogin)
{
UserRegistrySynchronizer stub = mock(UserRegistrySynchronizer.class);
when(stub.createMissingPerson(anyString())).thenAnswer(new Answer<Boolean>()
{
public Boolean answer(InvocationOnMock invocation) throws Throwable
{
Object[] args = invocation.getArguments();
String userName = (String) args[0];
if (userName != null && !userName.equals(AuthenticationUtil.getSystemUserName()))
{
PersonService personServiceStub = mock(PersonService.class);
when(personServiceStub.createMissingPeople()).thenReturn(true);
if (autoCreatePeopleOnLogin && personServiceStub.createMissingPeople())
{
AuthorityType authorityType = AuthorityType.getAuthorityType(userName);
if (authorityType == AuthorityType.USER)
{
personService.getPerson(userName);
return true;
}
}
}
return false;
}
});
return stub;
}
示例8: execute
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
/**
*
* {@inheritDoc}
*/
@Override
public void execute(final JobExecutionContext executionContext) throws JobExecutionException
{
final UserRegistrySynchronizer userRegistrySynchronizer = (UserRegistrySynchronizer) executionContext.getJobDetail().getJobDataMap()
.get("userRegistrySynchronizer");
final TenantAdminService tenantAdminService = (TenantAdminService) executionContext.getJobDetail().getJobDataMap()
.get("tenantAdminService");
final String synchronizeChangesOnly = (String) executionContext.getJobDetail().getJobDataMap().get("synchronizeChangesOnly");
final boolean forceUpdate = synchronizeChangesOnly == null || !Boolean.parseBoolean(synchronizeChangesOnly);
final String tenantDomain = (String) executionContext.getJobDetail().getJobDataMap().get("tenantDomain");
if (TenantUtil.DEFAULT_TENANT.equals(tenantDomain))
{
LOGGER.debug("Triggering synchronization for default tenant");
AuthenticationUtil.runAs(() -> {
userRegistrySynchronizer.synchronize(forceUpdate, true);
return null;
}, AuthenticationUtil.getSystemUserName());
}
else if (tenantAdminService.isEnabled() && tenantAdminService.existsTenant(tenantDomain)
&& tenantAdminService.isEnabledTenant(tenantDomain))
{
LOGGER.debug("Triggering synchronization for {} tenant", tenantDomain);
TenantUtil.runAsSystemTenant(() -> {
userRegistrySynchronizer.synchronize(forceUpdate, true);
return null;
}, tenantDomain);
}
else
{
LOGGER.debug("Failed to trigger snychronization as either multi-tenancy is disabled, tenant {} does not exist or is disabled",
tenantDomain);
}
}
示例9: setUserRegistrySynchronizer
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
public void setUserRegistrySynchronizer(UserRegistrySynchronizer userRegistrySynchronizer)
{
this.userRegistrySynchronizer = userRegistrySynchronizer;
}
示例10: setUserRegistrySynchronizer
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
/**
* @param userRegistrySynchronizer UserRegistrySynchronizer
*/
public void setUserRegistrySynchronizer(UserRegistrySynchronizer userRegistrySynchronizer)
{
this.userRegistrySynchronizer = userRegistrySynchronizer;
}
示例11: setUserRegistrySynchronizer
import org.alfresco.repo.security.sync.UserRegistrySynchronizer; //导入依赖的package包/类
/**
* Set the UserRegistrySynchronizer
*
* @param userRegistrySynchronizer UserRegistrySynchronizer
*/
public void setUserRegistrySynchronizer(UserRegistrySynchronizer userRegistrySynchronizer)
{
this.userRegistrySynchronizer = userRegistrySynchronizer;
}