Search in sources :

Example 21 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class PrincipalBearingCredentialsAuthenticationHandlerTests method verifySupports.

@Test
public void verifySupports() {
    val credentials = new PrincipalBearingCredential(PrincipalFactoryUtils.newPrincipalFactory().createPrincipal("scott"));
    assertTrue(this.handler.supports(credentials));
    assertFalse(this.handler.supports(new UsernamePasswordCredential()));
}
Also used : lombok.val(lombok.val) PrincipalBearingCredential(org.apereo.cas.adaptors.trusted.authentication.principal.PrincipalBearingCredential) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test)

Example 22 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class AcceptUserGraphicsForAuthenticationAction method doExecute.

@Override
public Event doExecute(final RequestContext requestContext) {
    val username = requestContext.getRequestParameters().get("username");
    WebUtils.putCredential(requestContext, new UsernamePasswordCredential(username, null));
    WebUtils.putGraphicalUserAuthenticationUsername(requestContext, username);
    return success();
}
Also used : lombok.val(lombok.val) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential)

Example 23 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class JsonResourcePasswordManagementServiceTests method verifyPasswordValidationService.

@Test
public void verifyPasswordValidationService() {
    val c = new UsernamePasswordCredential("casuser", "password");
    val bean = new PasswordChangeRequest();
    bean.setUsername(c.getUsername());
    bean.setConfirmedPassword("Test1@1234");
    bean.setPassword("Test1@1234");
    val isValid = passwordValidationService.isValid(c, bean);
    assertTrue(isValid);
}
Also used : lombok.val(lombok.val) PasswordChangeRequest(org.apereo.cas.pm.PasswordChangeRequest) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 24 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class JsonResourcePasswordManagementServiceTests method verifyUserPasswordChangeFail.

@Test
public void verifyUserPasswordChangeFail() {
    val c = new UsernamePasswordCredential("casuser", "password");
    val bean = new PasswordChangeRequest();
    bean.setConfirmedPassword("newPassword");
    var res = passwordChangeService.change(c, bean);
    assertFalse(res);
    bean.setConfirmedPassword("newPassword");
    bean.setPassword("unknown");
    res = passwordChangeService.change(c, bean);
    assertFalse(res);
    bean.setPassword(bean.getConfirmedPassword());
    c.setUsername(UUID.randomUUID().toString());
    res = passwordChangeService.change(c, bean);
    assertFalse(res);
}
Also used : lombok.val(lombok.val) PasswordChangeRequest(org.apereo.cas.pm.PasswordChangeRequest) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 25 with UsernamePasswordCredential

use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.

the class JsonResourcePasswordManagementServiceTests method verifyUserPasswordChange.

@Test
public void verifyUserPasswordChange() {
    val c = new UsernamePasswordCredential("casuser", "password");
    val bean = new PasswordChangeRequest();
    bean.setConfirmedPassword("newPassword");
    bean.setPassword("newPassword");
    val res = passwordChangeService.change(c, bean);
    assertTrue(res);
}
Also used : lombok.val(lombok.val) PasswordChangeRequest(org.apereo.cas.pm.PasswordChangeRequest) UsernamePasswordCredential(org.apereo.cas.authentication.credential.UsernamePasswordCredential) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

lombok.val (lombok.val)111 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)111 Test (org.junit.jupiter.api.Test)74 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)30 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)14 SimpleTestUsernamePasswordAuthenticationHandler (org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler)12 HashMap (java.util.HashMap)8 Map (java.util.Map)8 BasicCredentialMetaData (org.apereo.cas.authentication.metadata.BasicCredentialMetaData)8 LinkedHashMap (java.util.LinkedHashMap)7 MockTicketGrantingTicket (org.apereo.cas.mock.MockTicketGrantingTicket)7 Executable (org.junit.jupiter.api.function.Executable)7 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)6 ServletExternalContext (org.springframework.webflow.context.servlet.ServletExternalContext)6 MockRequestContext (org.springframework.webflow.test.MockRequestContext)6 ArrayList (java.util.ArrayList)5 ClassPathResource (org.springframework.core.io.ClassPathResource)5 MockServletContext (org.springframework.mock.web.MockServletContext)5 FailedLoginException (javax.security.auth.login.FailedLoginException)4 SurrogateUsernamePasswordCredential (org.apereo.cas.authentication.SurrogateUsernamePasswordCredential)4