use of org.apereo.cas.ticket.TicketGrantingTicketImpl in project cas by apereo.
the class AbstractTicketRegistryTests method verifyDeleteExistingTicket.
@Test
public void verifyDeleteExistingTicket() {
try {
this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TicketGrantingTicket.PREFIX, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
assertSame(1, this.ticketRegistry.deleteTicket(TicketGrantingTicket.PREFIX));
} catch (final Exception e) {
fail(CAUGHT_AN_EXCEPTION_BUT_WAS_NOT_EXPECTED + e.getMessage());
}
}
use of org.apereo.cas.ticket.TicketGrantingTicketImpl in project cas by apereo.
the class DistributedTicketRegistryTests method verifyProxiedInstancesEqual.
@Test
public void verifyProxiedInstancesEqual() {
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
this.ticketRegistry.addTicket(t);
final TicketGrantingTicket returned = (TicketGrantingTicket) this.ticketRegistry.getTicket(TGT_ID);
assertEquals(t, returned);
assertEquals(returned, t);
assertEquals(t.getCreationTime(), returned.getCreationTime());
assertEquals(t.getAuthentication(), returned.getAuthentication());
assertEquals(t.getCountOfUses(), returned.getCountOfUses());
assertEquals(t.getGrantingTicket(), returned.getGrantingTicket());
assertEquals(t.getId(), returned.getId());
assertEquals(t.getChainedAuthentications(), returned.getChainedAuthentications());
assertEquals(t.isExpired(), returned.isExpired());
assertEquals(t.isRoot(), returned.isRoot());
final ServiceTicket s = t.grantServiceTicket("stest", RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
this.ticketRegistry.addTicket(s);
final ServiceTicket sreturned = (ServiceTicket) this.ticketRegistry.getTicket("stest");
assertEquals(s, sreturned);
assertEquals(sreturned, s);
assertEquals(s.getCreationTime(), sreturned.getCreationTime());
assertEquals(s.getCountOfUses(), sreturned.getCountOfUses());
assertEquals(s.getGrantingTicket(), sreturned.getGrantingTicket());
assertEquals(s.getId(), sreturned.getId());
assertEquals(s.isExpired(), sreturned.isExpired());
assertEquals(s.getService(), sreturned.getService());
assertEquals(s.isFromNewLogin(), sreturned.isFromNewLogin());
}
use of org.apereo.cas.ticket.TicketGrantingTicketImpl in project cas by apereo.
the class DistributedTicketRegistryTests method verifyUpdateOfRegistry.
@Test
public void verifyUpdateOfRegistry() throws AbstractTicketException {
final TicketGrantingTicket t = new TicketGrantingTicketImpl(TGT_ID, CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy());
this.ticketRegistry.addTicket(t);
final TicketGrantingTicket returned = (TicketGrantingTicket) this.ticketRegistry.getTicket(TGT_ID);
final ServiceTicket s = returned.grantServiceTicket("test2", RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
this.ticketRegistry.addTicket(s);
final ServiceTicket s2 = (ServiceTicket) this.ticketRegistry.getTicket("test2");
assertNotNull(s2.grantProxyGrantingTicket("ff", CoreAuthenticationTestUtils.getAuthentication(), new NeverExpiresExpirationPolicy()));
assertTrue(s2.isValidFor(RegisteredServiceTestUtils.getService()));
assertTrue(this.wasTicketUpdated);
returned.markTicketExpired();
assertTrue(t.isExpired());
}
use of org.apereo.cas.ticket.TicketGrantingTicketImpl in project cas by apereo.
the class DistributedTicketRegistryTests method verifyDeleteTicketWithPGT.
@Test
public void verifyDeleteTicketWithPGT() {
final Authentication a = CoreAuthenticationTestUtils.getAuthentication();
this.ticketRegistry.addTicket(new TicketGrantingTicketImpl(TGT_NAME, a, new NeverExpiresExpirationPolicy()));
final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class);
final Service service = CoreAuthenticationTestUtils.getService("TGT_DELETE_TEST");
final ServiceTicket st1 = tgt.grantServiceTicket("ST1", service, new NeverExpiresExpirationPolicy(), true, true);
this.ticketRegistry.addTicket(st1);
assertNotNull(this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class));
assertNotNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
final ProxyGrantingTicket pgt = st1.grantProxyGrantingTicket("PGT-1", a, new NeverExpiresExpirationPolicy());
assertEquals(a, pgt.getAuthentication());
this.ticketRegistry.addTicket(pgt);
assertSame(3, this.ticketRegistry.deleteTicket(tgt.getId()));
assertNull(this.ticketRegistry.getTicket(TGT_NAME, TicketGrantingTicket.class));
assertNull(this.ticketRegistry.getTicket("ST1", ServiceTicket.class));
assertNull(this.ticketRegistry.getTicket("PGT-1", ProxyGrantingTicket.class));
}
use of org.apereo.cas.ticket.TicketGrantingTicketImpl in project cas by apereo.
the class RememberMeDelegatingExpirationPolicyTests method verifyTicketExpirationWithoutRememberMe.
@Test
public void verifyTicketExpirationWithoutRememberMe() {
final Authentication authentication = CoreAuthenticationTestUtils.getAuthentication();
final TicketGrantingTicketImpl t = new TicketGrantingTicketImpl("111", authentication, this.p);
assertFalse(t.isExpired());
t.grantServiceTicket("55", RegisteredServiceTestUtils.getService(), this.p, false, true);
assertFalse(t.isExpired());
}
Aggregations