use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.
the class InweboAuthenticationDeviceMetadataPopulatorTests method verifyPopulator.
@Test
public void verifyPopulator() {
val credentials = new InweboCredential();
credentials.setDeviceName("MyDeviceName");
val builder = CoreAuthenticationTestUtils.getAuthenticationBuilder();
assertTrue(this.populator.supports(credentials));
assertNotNull(populator.toString());
this.populator.populateAttributes(builder, new DefaultAuthenticationTransactionFactory().newTransaction(credentials));
val auth = builder.build();
assertEquals(credentials.getDeviceName(), auth.getAttributes().get(InweboAuthenticationDeviceMetadataPopulator.ATTRIBUTE_NAME_INWEBO_AUTHENTICATION_DEVICE).get(0));
}
use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.
the class BaseActionTests method setUp.
@BeforeEach
public void setUp() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, CoreAuthenticationTestUtils.getAuthenticationSystemSupport(), AuthenticationSystemSupport.BEAN_NAME);
requestContext = new MockRequestContext();
request = new MockHttpServletRequest();
val response = new MockHttpServletResponse();
requestContext.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
setRequestContext(requestContext);
setExternalContext(requestContext.getExternalContext());
((DefaultMessageContext) requestContext.getMessageContext()).setMessageSource(new AbstractMessageSource() {
@Override
protected MessageFormat resolveCode(final String code, final Locale locale) {
return new MessageFormat(StringUtils.EMPTY);
}
});
service = mock(InweboService.class);
val authenticationEventExecutionPlan = new DefaultAuthenticationEventExecutionPlan();
authenticationEventExecutionPlan.registerAuthenticationHandler(new InweboAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), new InweboMultifactorAuthenticationProperties(), service));
authenticationEventExecutionPlan.registerAuthenticationMetadataPopulator(new InweboAuthenticationDeviceMetadataPopulator());
val authenticationManager = new DefaultAuthenticationManager(authenticationEventExecutionPlan, true, applicationContext);
val authenticationTransactionManager = new DefaultAuthenticationTransactionManager(applicationContext, authenticationManager);
val authenticationSystemSupport = new DefaultAuthenticationSystemSupport(authenticationTransactionManager, new DefaultPrincipalElectionStrategy(), new DefaultAuthenticationResultBuilderFactory(), new DefaultAuthenticationTransactionFactory());
val context = CasWebflowEventResolutionConfigurationContext.builder().authenticationSystemSupport(authenticationSystemSupport).build();
resolver = new InweboMultifactorAuthenticationWebflowEventResolver(context);
setAuthenticationInContext(LOGIN);
}
use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.
the class CasJdbcAuthenticationConfigurationTests method verifyOperation.
@Test
public void verifyOperation() {
val credential = CoreAuthenticationTestUtils.getCredentialsWithDifferentUsernameAndPassword("casuser", "Mellon");
val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(CoreAuthenticationTestUtils.getService(), credential);
val result = authenticationManager.authenticate(transaction);
assertNotNull(result);
}
use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.
the class ClientAuthenticationMetaDataPopulatorTests method verifyAttribute.
@Test
public void verifyAttribute() {
val populator = new ClientAuthenticationMetaDataPopulator();
val credentials = new ClientCredential(new UsernamePasswordCredentials("casuser", "pa$$"), "FacebookClient");
val builder = CoreAuthenticationTestUtils.getAuthenticationBuilder();
populator.populateAttributes(builder, new DefaultAuthenticationTransactionFactory().newTransaction(credentials));
val auth = builder.build();
assertNotNull(auth.getAttributes().get(ClientCredential.AUTHENTICATION_ATTRIBUTE_CLIENT_NAME));
}
use of org.apereo.cas.authentication.DefaultAuthenticationTransactionFactory in project cas by apereo.
the class RegisteredServiceAuthenticationHandlerResolverTests method checkAuthenticationHandlerResolutionDefault.
@Test
public void checkAuthenticationHandlerResolutionDefault() {
val resolver = new RegisteredServiceAuthenticationHandlerResolver(this.defaultServicesManager, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
val transaction = new DefaultAuthenticationTransactionFactory().newTransaction(RegisteredServiceTestUtils.getService("serviceid1"), RegisteredServiceTestUtils.getCredentialsWithSameUsernameAndPassword("casuser"));
val handlers = resolver.resolve(this.authenticationHandlers, transaction);
assertEquals(2, handlers.size());
}
Aggregations