当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationService.authenticate方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.security.AuthenticationService.authenticate方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationService.authenticate方法的具体用法?Java AuthenticationService.authenticate怎么用?Java AuthenticationService.authenticate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.security.AuthenticationService的用法示例。


在下文中一共展示了AuthenticationService.authenticate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loginOnDemandSynchTenantAlpha

import org.alfresco.service.cmr.security.AuthenticationService; //导入方法依赖的package包/类
@Test
public void loginOnDemandSynchTenantAlpha()
{
    AuthenticationUtil.setFullyAuthenticatedUser("admin");
    this.createAndEnableTenant("tenantalpha");

    final WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
    final PersonService personService = context.getBean("PersonService", PersonService.class);
    TenantUtil.runAsTenant(() -> {
        Assert.assertFalse("User [email protected] should not have been synchronized yet",
                personService.personExists("[email protected]"));
        return null;
    }, "tenantalpha");
    AuthenticationUtil.clearCurrentSecurityContext();

    final AuthenticationService authenticationService = context.getBean("AuthenticationService", AuthenticationService.class);
    authenticationService.authenticate("[email protected]", "afaust".toCharArray());
    this.checkUserExistsAndState("[email protected]", "Axel", "Faust", false);
}
 
开发者ID:Acosix,项目名称:alfresco-mt-support,代码行数:20,代码来源:AuthenticationAndSynchronisationTests.java

示例2: loginNoSyncTenantBeta

import org.alfresco.service.cmr.security.AuthenticationService; //导入方法依赖的package包/类
@Test
public void loginNoSyncTenantBeta()
{
    AuthenticationUtil.setFullyAuthenticatedUser("admin");
    this.createAndEnableTenant("tenantbeta");

    final WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
    final PersonService personService = context.getBean("PersonService", PersonService.class);
    TenantUtil.runAsTenant(() -> {
        Assert.assertFalse("User [email protected] should not have been created yet", personService.personExists("[email protected]"));
        return null;
    }, "tenantbeta");
    AuthenticationUtil.clearCurrentSecurityContext();

    final AuthenticationService authenticationService = context.getBean("AuthenticationService", AuthenticationService.class);

    authenticationService.authenticate("[email protected]", "afaust".toCharArray());
    this.checkUserExistsAndState("[email protected]", "afaust", "", false);

    Assert.assertFalse("User [email protected] should not have been eagerly synchronized",
            personService.personExists("[email protected]"));
}
 
开发者ID:Acosix,项目名称:alfresco-mt-support,代码行数:23,代码来源:AuthenticationAndSynchronisationTests.java

示例3: authenticate

import org.alfresco.service.cmr.security.AuthenticationService; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void authenticate(String userName, char[] password) throws AuthenticationException
{
    preAuthenticationCheck(userName);
    List<AuthenticationService> usableAuthenticationServices = getUsableAuthenticationServices();
    int counter = usableAuthenticationServices.size();
    for (AuthenticationService authService : usableAuthenticationServices)
    {
        try
        {
            counter--;
            authService.authenticate(userName, password);
            if (logger.isDebugEnabled())
            {
                logger.debug("authenticate "+userName+" with "+getId(authService)+" SUCCEEDED");
            }
            return;
        }
        catch (AuthenticationException e)
        {
            if (logger.isDebugEnabled())
            {
                logger.debug("authenticate "+userName+" with "+getId(authService)+(counter == 0 ? " FAILED (end of chain)" : " failed (try next in chain)"));
            }
            // Ignore and chain
        }
    }
    throw new AuthenticationException("Failed to authenticate");

}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:AbstractChainingAuthenticationService.java

示例4: main

import org.alfresco.service.cmr.security.AuthenticationService; //导入方法依赖的package包/类
public static void main(String[] args)
{
	
    // initialise app content 
    ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
    // get registry of services
    final ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);

    // authenticate
    AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
    authenticationService.authenticate(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());

    
    // use TransactionWork to wrap service calls in a user transaction
    TransactionService transactionService = serviceRegistry.getTransactionService();
    RetryingTransactionCallback<Object> exampleWork = new RetryingTransactionCallback<Object>()
    {
        public Object execute() throws Exception
        {
            doExample(serviceRegistry);
            return null;
        }
    };
    currentDoc = 0;
    while (currentDoc < totalNumDocs)
    {
        transactionService.getRetryingTransactionHelper().doInTransaction(exampleWork);
    }
    System.exit(0);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:FFCLoadsOfFiles.java

示例5: login

import org.alfresco.service.cmr.security.AuthenticationService; //导入方法依赖的package包/类
/**
 * Login to Repository
 */
private void login()
{
    // TODO: Replace with call to ServiceRegistry
    AuthenticationService auth = (AuthenticationService) serviceRegistry.getAuthenticationService();
    auth.authenticate(toolContext.getUsername(), toolContext.getPassword().toCharArray());
    logInfo("Connected as " + toolContext.getUsername());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:Tool.java

示例6: authenticateUser

import org.alfresco.service.cmr.security.AuthenticationService; //导入方法依赖的package包/类
/**
 * Authenticate the user with the specified password
 * 
 * @param userName                  the user name
 * @param password                  the password
 * @param rootNodeRef               the root node reference
 * @param authenticationService     the authentication service
 */
public static void authenticateUser(
        String userName, 
        String password,
        NodeRef rootNodeRef,
        AuthenticationService authenticationService)
{
    authenticationService.authenticate(userName, password.toCharArray());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:TestWithUserUtils.java

示例7: loginStartupSynchDefaultTenant

import org.alfresco.service.cmr.security.AuthenticationService; //导入方法依赖的package包/类
@Test
public void loginStartupSynchDefaultTenant()
{
    // verifies users are eagerly synchronised on startup
    // synchronisation for missing people and and auto-creation of people is off for default tenant
    AuthenticationUtil.setFullyAuthenticatedUser("admin");
    this.checkUserExistsAndState("afaust", "Axel", "Faust", true);
    this.checkUserExistsAndState("mmustermann", "Max", "Mustermann", false);

    this.checkGroupsExistsAndMembers("Management", "Management", Arrays.asList("afaust"), Collections.emptyList(),
            Arrays.asList("afaust"), Collections.emptyList());
    this.checkGroupsExistsAndMembers("Client Development", "Client Development", Arrays.asList("mmustermann"), Collections.emptyList(),
            Arrays.asList("mmustermann"), Collections.emptyList());
    this.checkGroupsExistsAndMembers("Development", "Development", Collections.emptyList(), Arrays.asList("Client Development"),
            Arrays.asList("mmustermann"), Arrays.asList("Client Development"));
    this.checkGroupsExistsAndMembers("All Users", "All Users", Collections.emptyList(), Arrays.asList("Management", "Development"),
            Arrays.asList("afaust", "mmustermann"), Arrays.asList("Management", "Development", "Client Development"));
    AuthenticationUtil.clearCurrentSecurityContext();

    final WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
    final AuthenticationService authenticationService = context.getBean("AuthenticationService", AuthenticationService.class);

    authenticationService.authenticate("afaust", "afaust".toCharArray());
    authenticationService.authenticate("mmustermann", "mmustermann".toCharArray());

    this.thrown.expect(AuthenticationException.class);
    this.thrown.expectMessage("Failed to authenticate");
    authenticationService.authenticate("pmaier", "pmaier".toCharArray());
}
 
开发者ID:Acosix,项目名称:alfresco-mt-support,代码行数:30,代码来源:AuthenticationAndSynchronisationTests.java


注:本文中的org.alfresco.service.cmr.security.AuthenticationService.authenticate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。