Search in sources :

Example 1 with DefaultUserAuthenticationResourceEntityResponseFactory

use of org.apereo.cas.rest.factory.DefaultUserAuthenticationResourceEntityResponseFactory in project cas by apereo.

the class UserAuthenticationResourceTests method initialize.

@BeforeEach
public void initialize() {
    val httpRequestCredentialFactory = new UsernamePasswordRestHttpRequestCredentialFactory() {

        @Override
        public List<Credential> fromAuthentication(final HttpServletRequest request, final MultiValueMap<String, String> requestBody, final Authentication authentication, final MultifactorAuthenticationProvider provider) {
            if (provider.getId().contains("unknown")) {
                return List.of();
            }
            return List.of(new UsernamePasswordCredential("mfa-user", "mfa-user"));
        }
    };
    val api = new DefaultRestAuthenticationService(authenticationSupport, httpRequestCredentialFactory, new WebApplicationServiceFactory(), multifactorTriggerSelectionStrategy, servicesManager, requestedContextValidator);
    this.userAuthenticationResource = new UserAuthenticationResource(api, new DefaultUserAuthenticationResourceEntityResponseFactory(), new GenericApplicationContext());
    this.mockMvc = MockMvcBuilders.standaloneSetup(this.userAuthenticationResource).defaultRequest(get("/").contextPath("/cas").contentType(MediaType.APPLICATION_FORM_URLENCODED)).build();
}
Also used : lombok.val(lombok.val) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Credential(org.apereo.cas.authentication.Credential) UserAuthenticationResource(org.apereo.cas.support.rest.resources.UserAuthenticationResource) UsernamePasswordRestHttpRequestCredentialFactory(org.apereo.cas.rest.factory.UsernamePasswordRestHttpRequestCredentialFactory) MultifactorAuthenticationProvider(org.apereo.cas.authentication.MultifactorAuthenticationProvider) TestMultifactorAuthenticationProvider(org.apereo.cas.authentication.mfa.TestMultifactorAuthenticationProvider) DefaultRestAuthenticationService(org.apereo.cas.rest.authentication.DefaultRestAuthenticationService) HttpServletRequest(javax.servlet.http.HttpServletRequest) DefaultUserAuthenticationResourceEntityResponseFactory(org.apereo.cas.rest.factory.DefaultUserAuthenticationResourceEntityResponseFactory) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) Authentication(org.apereo.cas.authentication.Authentication) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) MultiValueMap(org.springframework.util.MultiValueMap) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)1 lombok.val (lombok.val)1 Authentication (org.apereo.cas.authentication.Authentication)1 Credential (org.apereo.cas.authentication.Credential)1 MultifactorAuthenticationProvider (org.apereo.cas.authentication.MultifactorAuthenticationProvider)1 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)1 TestMultifactorAuthenticationProvider (org.apereo.cas.authentication.mfa.TestMultifactorAuthenticationProvider)1 WebApplicationServiceFactory (org.apereo.cas.authentication.principal.WebApplicationServiceFactory)1 DefaultRestAuthenticationService (org.apereo.cas.rest.authentication.DefaultRestAuthenticationService)1 DefaultUserAuthenticationResourceEntityResponseFactory (org.apereo.cas.rest.factory.DefaultUserAuthenticationResourceEntityResponseFactory)1 UsernamePasswordRestHttpRequestCredentialFactory (org.apereo.cas.rest.factory.UsernamePasswordRestHttpRequestCredentialFactory)1 UserAuthenticationResource (org.apereo.cas.support.rest.resources.UserAuthenticationResource)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)1 MultiValueMap (org.springframework.util.MultiValueMap)1