Package org.jasig.cas.ticket

Examples of org.jasig.cas.ticket.TicketGrantingTicket


            "code"));
    }

    @Test
    public void testExistingPGT() throws Exception {
        final TicketGrantingTicket ticket = new TicketGrantingTicketImpl(
            "ticketGrantingTicketId", TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy());
        getTicketRegistry().addTicket(ticket);
        MockHttpServletRequest request = new MockHttpServletRequest();
        request
            .addParameter("pgt", ticket.getId());
        request.addParameter(
            "targetService", "service");

        assertTrue(this.proxyController.handleRequestInternal(request,
            new MockHttpServletResponse()).getModel().containsKey(
View Full Code Here


    public boolean authenticate(final Credentials credentials)
        throws AuthenticationException {
        final OpenIdCredentials c = (OpenIdCredentials) credentials;

        final TicketGrantingTicket t = (TicketGrantingTicket) this.ticketRegistry
            .getTicket(c.getTicketGrantingTicketId(),
                TicketGrantingTicket.class);

        if (t.isExpired()) {
            return false;
        }

        return t.getAuthentication().getPrincipal().getId().equals(
            c.getUsername());
    }
View Full Code Here

    super.tearDown();
  }

  public void testAddTicket() throws Exception {

        TicketGrantingTicket ticket = getTicket();
    this.reg.addTicket(ticket);
  }
View Full Code Here

    this.reg.addTicket(ticket);
  }

  TicketGrantingTicket getTicket(String id) {
        final SimplePrincipal principal = new SimplePrincipal(id);
        TicketGrantingTicket ticket = new TicketGrantingTicketImpl(id, new ImmutableAuthentication(principal), new TimeoutExpirationPolicy(500));

    return ticket;
  }
View Full Code Here

    return  getTicket(DEFAULT_ID) ;
  }

  public void testGetTicket() throws Exception {

        TicketGrantingTicket oldticket = getTicket();
    long cdate = oldticket.getCreationTime();
    this.reg.addTicket(oldticket);
    Thread.sleep(1000);

    TicketGrantingTicket newticket = (TicketGrantingTicket) this.reg.getTicket(DEFAULT_ID);

    assertEquals(newticket.getCreationTime(), cdate);
    assertEquals(newticket,oldticket);
  }
View Full Code Here

    assertEquals(newticket,oldticket);
  }

  public void testGetTickets() throws Exception {

        TicketGrantingTicket ticket = getTicket();
    this.reg.addTicket(ticket);
    ticket = getTicket("abc");
    this.reg.addTicket(ticket);
    Collection tickets = this.reg.getTickets();
View Full Code Here

    }

    public void run() {

        for (int i = 0; i < 3 ; i++) {
                TicketGrantingTicket ticket = this.test.getTicket(this.toString() + this.createTime);
      this.test.getReg().addTicket(ticket);
            TicketGrantingTicket oldticket = this.test.getTicket(this.toString() + this.createTime);
      BerkeleyDbTicketRegistryTests.this.reg.addTicket(oldticket);
      TicketGrantingTicket newticket = (TicketGrantingTicket) this.test.getReg().getTicket(this.toString() + this.createTime);
      assertEquals(newticket,oldticket);
      boolean delete = (rand.nextInt() % 3) == 0;
      if (!delete) {
          this.test.getReg().deleteTicket(this.toString() + this.createTime);
      }
View Full Code Here

    public void testGetTicketsFromRegistryEqualToTicketsAdded() {
        final Collection<Ticket> tickets = new ArrayList<Ticket>();

        for (int i = 0; i < TICKETS_IN_REGISTRY; i++) {
            final TicketGrantingTicket ticketGrantingTicket = new TicketGrantingTicketImpl(
                "TEST" + i, TestUtils.getAuthentication(),
                new NeverExpiresExpirationPolicy());
            final ServiceTicket st = ticketGrantingTicket.grantServiceTicket("tests" + i, TestUtils.getService(), new NeverExpiresExpirationPolicy(), false);
            tickets.add(ticketGrantingTicket);
            tickets.add(st);
            this.ticketRegistry.addTicket(ticketGrantingTicket);
            this.ticketRegistry.addTicket(st);
        }
View Full Code Here

        assertTrue(this.ticketRegistry.getTickets().isEmpty());
    }

    public void testCleanRegistryOneNonExpired() {
        populateRegistryWithExpiredTickets();
        TicketGrantingTicket ticket = new TicketGrantingTicketImpl(
            "testNoExpire", TestUtils.getAuthentication(),
            new NeverExpiresExpirationPolicy());
        this.ticketRegistry.addTicket(ticket);

        this.registryCleaner.clean();
View Full Code Here

        assertEquals(this.ticketRegistry.getTickets().size(), 1);
    }

    private void populateRegistryWithExpiredTickets() {
        for (int i = 0; i < 10; i++) {
            TicketGrantingTicket ticket = new TicketGrantingTicketImpl("test"
                + i, TestUtils.getAuthentication(),
                new NeverExpiresExpirationPolicy());
            ticket.expire();
            this.ticketRegistry.addTicket(ticket);
        }
    }
View Full Code Here

TOP

Related Classes of org.jasig.cas.ticket.TicketGrantingTicket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.