Java Code Examples for org.jasig.cas.validation.Assertion#getPrimaryAuthentication()
The following examples show how to use
org.jasig.cas.validation.Assertion#getPrimaryAuthentication() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CentralAuthenticationServiceImplTests.java From springboot-shiro-cas-mybatis with MIT License | 6 votes |
@Test public void verifyValidateServiceTicketWithInvalidUsernameAttribute() throws Exception { final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final Service svc = TestUtils.getService("eduPersonTestInvalid"); final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), svc); final Authentication auth = assertion.getPrimaryAuthentication(); /* * The attribute specified for this service does not resolve. * Therefore, we expect the default to be returned. */ assertEquals(auth.getPrincipal().getId(), cred.getUsername()); }
Example 2
Source File: CentralAuthenticationServiceImplTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 6 votes |
@Test public void testValidateServiceTicketWithInvalidUsernameAttribute() throws Exception { final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final Service svc = TestUtils.getService("eduPersonTestInvalid"); final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket, svc); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket, svc); final Authentication auth = assertion.getPrimaryAuthentication(); /* * The attribute specified for this service does not resolve. * Therefore, we expect the default to be returned. */ assertEquals(auth.getPrincipal().getId(), cred.getUsername()); }
Example 3
Source File: CentralAuthenticationServiceImplTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyValidateServiceTicketWithoutUsernameAttribute() throws Exception { final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), TestUtils.getService()); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), TestUtils.getService()); final Authentication auth = assertion.getPrimaryAuthentication(); assertEquals(auth.getPrincipal().getId(), cred.getUsername()); }
Example 4
Source File: CentralAuthenticationServiceImplTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyValidateServiceTicketWithDefaultUsernameAttribute() throws Exception { final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final Service svc = TestUtils.getService("testDefault"); final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), svc); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), svc); final Authentication auth = assertion.getPrimaryAuthentication(); assertEquals(auth.getPrincipal().getId(), cred.getUsername()); }
Example 5
Source File: CentralAuthenticationServiceImplTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyValidateServiceTicketNoAttributesReturned() throws Exception { final Service service = TestUtils.getService(); final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), service); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), service); final Authentication auth = assertion.getPrimaryAuthentication(); assertEquals(0, auth.getPrincipal().getAttributes().size()); }
Example 6
Source File: CentralAuthenticationServiceImplTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyValidateServiceTicketReturnAllAttributes() throws Exception { final Service service = TestUtils.getService("eduPersonTest"); final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), service); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), service); final Authentication auth = assertion.getPrimaryAuthentication(); assertEquals(3, auth.getPrincipal().getAttributes().size()); }
Example 7
Source File: CentralAuthenticationServiceImplTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyValidateServiceTicketReturnOnlyAllowedAttribute() throws Exception { final Service service = TestUtils.getService("eduPersonTestInvalid"); final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), service); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), service); final Authentication auth = assertion.getPrimaryAuthentication(); final Map<String, Object> attributes = auth.getPrincipal().getAttributes(); assertEquals(1, attributes.size()); assertEquals("adopters", attributes.get("groupMembership")); }
Example 8
Source File: CentralAuthenticationServiceImplTests.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
@Test public void verifyValidateServiceTicketAnonymous() throws Exception { final Service service = TestUtils.getService("testAnonymous"); final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), service); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), service); final Authentication auth = assertion.getPrimaryAuthentication(); assertNotEquals(cred.getUsername(), auth.getPrincipal().getId()); }
Example 9
Source File: CentralAuthenticationServiceImplTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Test public void testValidateServiceTicketWithoutUsernameAttribute() throws Exception { UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket, TestUtils.getService()); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket, TestUtils.getService()); final Authentication auth = assertion.getPrimaryAuthentication(); assertEquals(auth.getPrincipal().getId(), cred.getUsername()); }
Example 10
Source File: CentralAuthenticationServiceImplTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Test public void testValidateServiceTicketWithDefaultUsernameAttribute() throws Exception { UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); Service svc = TestUtils.getService("testDefault"); final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket, svc); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket, svc); final Authentication auth = assertion.getPrimaryAuthentication(); assertEquals(auth.getPrincipal().getId(), cred.getUsername()); }
Example 11
Source File: CentralAuthenticationServiceImplTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Test public void testValidateServiceTicketNoAttributesReturned() throws Exception { final Service service = TestUtils.getService(); final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket, service); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket, service); final Authentication auth = assertion.getPrimaryAuthentication(); assertEquals(0, auth.getPrincipal().getAttributes().size()); }
Example 12
Source File: CentralAuthenticationServiceImplTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Test public void testValidateServiceTicketReturnAllAttributes() throws Exception { final Service service = TestUtils.getService("eduPersonTest"); final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket, service); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket, service); final Authentication auth = assertion.getPrimaryAuthentication(); assertEquals(3, auth.getPrincipal().getAttributes().size()); }
Example 13
Source File: CentralAuthenticationServiceImplTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Test public void testValidateServiceTicketReturnOnlyAllowedAttribute() throws Exception { final Service service = TestUtils.getService("eduPersonTestInvalid"); final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket, service); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket, service); final Authentication auth = assertion.getPrimaryAuthentication(); Map<String, Object> attributes = auth.getPrincipal().getAttributes(); assertEquals(1, attributes.size()); assertEquals("adopters", attributes.get("groupMembership")); }
Example 14
Source File: CentralAuthenticationServiceImplTests.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Test public void testValidateServiceTicketAnonymous() throws Exception { final Service service = TestUtils.getService("testAnonymous"); final UsernamePasswordCredential cred = TestUtils.getCredentialsWithSameUsernameAndPassword(); final String ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(cred); final String serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket, service); final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket, service); final Authentication auth = assertion.getPrimaryAuthentication(); assertNotEquals(cred.getUsername(), auth.getPrincipal().getId()); }