Thanks Andrew!!
So dang close.. is there something I'm missing... I added this to my 
CustomSendTicketGrantingTicketAction.Java but when I attempt it I get no 
errors in the log and a 500 error...



Chris Whittle
SWAT Team Developer
J.B. Hunt Transport Service, Inc.
Office Phone:(479) 419-3122
Ext:73122
Fax Phone:(479) 820-1769
[email protected]
What's your next move?TM
Intermodal | Dedicated | Truckload | LTL | Delivery | Refrigerated | 
Flatbed | Expedited 



Andrew Feller <[email protected]> 
07/20/2009 07:53 AM
Please respond to
[email protected]


To
[email protected]
cc

Subject
Re: [cas-user] Placing code after authenticate






Chris,

Try something like this:

package edu.lsu.sso.cas.web.flow;

import org.inspektr.common.ioc.annotation.NotNull;
import org.jasig.cas.ticket.TicketGrantingTicket;
import org.jasig.cas.ticket.registry.TicketRegistry;
import org.jasig.cas.web.support.WebUtils;
import org.springframework.webflow.action.AbstractAction;
import org.springframework.webflow.execution.Event;
import org.springframework.webflow.execution.RequestContext;

/**
 * Sample Spring Web Flow action that will extract the user principal 
information and
 * store it within the flow scope for Chris Whittle of J.B. Hunt.
 *
 * @author Andrew Feller <[email protected]>
 */
public class PrincipalExtractorAction extends AbstractAction {

    /** TicketRegistry for storing and retrieving tickets as needed. */
   @NotNull
   private TicketRegistry ticketRegistry;

    @Override
   protected Event doExecute(RequestContext context) throws Exception {

        String tgtId = WebUtils.getTicketGrantingTicketId(context);

        // Throw an exception if the TGT wasn't put into the flow or 
request scope 
       if (tgtId == null) {
            logger.warn("Mising TGT in flow scope and cannot continue");
            throw new RuntimeException("Missing TGT in flow scope and 
cannot continue");
        }

        final TicketGrantingTicket tgt = (TicketGrantingTicket) this.
ticketRegistry.getTicket(tgtId, TicketGrantingTicket.class);

        // Throw an exception if the TGT doesn't exist within the ticket 
registry
       if (tgt == null) {
            logger.warn("Invalid TGT in flow scope and cannot continue");
            throw new RuntimeException("Invalid TGT in flow scope and 
cannot continue");
        }

        // Put the user principal into the flow scope or wherever you 
desire
       context.getFlowScope().put("principal", 
tgt.getAuthentication().getPrincipal().getId());

        return success();
    }

    /**
    * Method to set the TicketRegistry.
    * 
    * @param ticketRegistry the TicketRegistry to set.
    */
   public void setTicketRegistry(TicketRegistry ticketRegistry) {
        this.ticketRegistry = ticketRegistry;
    }
}


On 7/19/09 4:59 PM, "[email protected]" <[email protected]> 
wrote:

Is there anyway to get the principal?

-- 
Andrew Feller, Business System Programmer
LSU University Information Services
200 Frey Computing Services Center
Baton Rouge, LA 70803
Office: 225.578.3737
Fax: 225.578.6400

-- 
You are currently subscribed to [email protected] as: 
[email protected]
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/cas-user

-- 
You are currently subscribed to [email protected] as: 
[email protected]
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/cas-user

<<image/gif>>

<<image/gif>>

Reply via email to