public TicketGrantingTicket grantTicketGrantingTicket(string id, Authentication authentication, ExpirationPolicy expirationPolicy)
            {
                TicketGrantingTicket t = this.getTicket().grantTicketGrantingTicket(id, authentication, expirationPolicy);

                this.updateTicket();
                return(t);
            }
            public bool isExpired()
            {
                if (!this.callback)
                {
                    return(this.ticket.isExpired());
                }

                TicketGrantingTicket t = this.getGrantingTicket();

                return(this.ticket.isExpired() || (t != null && t.isExpired()));
            }
            public TicketGrantingTicket getGrantingTicket()
            {
                TicketGrantingTicket old = this.ticket.getGrantingTicket();

                if (old == null || !this.callback)
                {
                    return(old);
                }

                return((TicketGrantingTicket)this.ticketRegistry.getTicket(old.getId(), typeof(Ticket)));
            }
Example #4
0
        /**
         * @throws IllegalArgumentException if the ServiceTicketId or the
         * Credentials are null.
         */
        //@Audit(
        //    action="PROXY_GRANTING_TICKET",
        //    actionResolverName="GRANT_PROXY_GRANTING_TICKET_RESOLVER",
        //    resourceResolverName="GRANT_PROXY_GRANTING_TICKET_RESOURCE_RESOLVER")
        //@Profiled(tag="GRANT_PROXY_GRANTING_TICKET",logFailuresSeparately = false)
        //@Transactional(readOnly = false)
        public string delegateTicketGrantingTicket(string serviceTicketId,
                                                   Credentials credentials)
        {
            //Assert.notNull(serviceTicketId, "serviceTicketId cannot be null");
            //Assert.notNull(credentials, "credentials cannot be null");

            try
            {
                Authentication authentication = this.authenticationManager
                                                .authenticate(credentials);

                ServiceTicket serviceTicket;
                serviceTicket = (ServiceTicket)this.serviceTicketRegistry.getTicket(serviceTicketId, typeof(ServiceTicket));

                if (serviceTicket == null || serviceTicket.isExpired())
                {
                    throw new InvalidTicketException();
                }

                RegisteredService registeredService = this.servicesManager
                                                      .findServiceBy(serviceTicket.getService());

                if (registeredService == null || !registeredService.isEnabled() ||
                    !registeredService.isAllowedToProxy())
                {
                    //log.warn("ServiceManagement: Service Attempted to Proxy, but is not allowed.  Service: [" + serviceTicket.getService().getId() + "]");
                    throw new UnauthorizedProxyingException();
                }

                TicketGrantingTicket ticketGrantingTicket = serviceTicket
                                                            .grantTicketGrantingTicket(
                    this.ticketGrantingTicketUniqueTicketIdGenerator
                    .getNewTicketId(TicketPrefix.TicketGrantingTicket_PREFIX),
                    authentication, this.ticketGrantingTicketExpirationPolicy);

                this.ticketRegistry.addTicket(ticketGrantingTicket);

                return(ticketGrantingTicket.getId());
            }
            catch (AuthenticationException e)
            {
                throw new TicketCreationException(e);
            }
        }
Example #5
0
        /**
         * Implementation of destoryTicketGrantingTicket expires the ticket provided
         * and removes it from the TicketRegistry.
         *
         * @throws IllegalArgumentException if the TicketGrantingTicket ID is null.
         */
        //@Audit(
        //    action="TICKET_GRANTING_TICKET_DESTROYED",
        //    actionResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOLVER",
        //    resourceResolverName="DESTROY_TICKET_GRANTING_TICKET_RESOURCE_RESOLVER")
        //@Profiled(tag = "DESTROY_TICKET_GRANTING_TICKET",logFailuresSeparately = false)
        //@Transactional(readOnly = false)
        public void destroyTicketGrantingTicket(string ticketGrantingTicketId)
        {
            //Assert.notNull(ticketGrantingTicketId);

            //if (log.isDebugEnabled()) {
            //    log.debug("Removing ticket [" + ticketGrantingTicketId + "] from registry.");
            //}
            TicketGrantingTicket ticket = (TicketGrantingTicket)this.ticketRegistry.getTicket(ticketGrantingTicketId, typeof(TicketGrantingTicket));

            if (ticket == null)
            {
                return;
            }

            //if (log.isDebugEnabled()) {
            //    log.debug("Ticket found.  Expiring and then deleting.");
            //}
            ticket.expire();
            this.ticketRegistry.deleteTicket(ticketGrantingTicketId);
        }