Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleTargettedTicketImpl
public Class TargettedTicketImpl implements TargettedTicket {

    private final Date whenCreated = new Date();

    private final ExpirationPolicy expPolicy;

    private final TicketGrantingTicket parent;

    private final URL target;


    public SSOTicket(URL target, TicketGrantingTicket parent, ExpirationPolicy expPolicy) {
       this.target = target;
       this.parent = parent;
       this.expPolicy = expPolicy;
    }

    public boolean isValid() {
         return this.expPolicy.isValid()
             && this.parent.isValid();
    }

    public URL getTarget() {
        return this.target;
    }

    public List getPrincipalChain() {
      
      List principalChain = new ArrayList();

      TicketGrantingTicket ancestor = this.parent;

      while (ancestor != null) {

         principalChain.add(ancestor.getPrincipal());

         if (parent instanceof DerivedTicket) {
              DerivedTicket ancestorIsAlsoAChild = (DerivedTicket) ancestor;
              ancestor = ancestor.getParent();
         } else {
              // perhaps an ugly way of breaking out of this while loop
              ancestor = null;
         }

     }
            
     return principalChain;
    }

    public TicketGrantingTicket getParent() {
        return this.parent;
    }

}