Example #1
0
 /**
  * Get the user profile from the credentials.
  *
  * @param credentials
  * @return the user profile
  */
 @Override
 protected CasProfile retrieveUserProfile(
     final CasCredentials credentials, final WebContext context) {
   final String ticket = credentials.getServiceTicket();
   try {
     final String contextualCallbackUrl = getContextualCallbackUrl(context);
     final Assertion assertion = this.ticketValidator.validate(ticket, contextualCallbackUrl);
     final AttributePrincipal principal = assertion.getPrincipal();
     logger.debug("principal : {}", principal);
     final CasProfile casProfile;
     if (this.casProxyReceptor != null) {
       casProfile = new CasProxyProfile();
     } else {
       casProfile = new CasProfile();
     }
     casProfile.setId(principal.getName());
     casProfile.addAttributes(principal.getAttributes());
     if (this.casProxyReceptor != null) {
       ((CasProxyProfile) casProfile).setPrincipal(principal);
     }
     logger.debug("casProfile : {}", casProfile);
     return casProfile;
   } catch (final TicketValidationException e) {
     logger.error("cannot validate CAS ticket : {} / {}", ticket, e);
     throw new TechnicalException(e);
   }
 }
Example #2
0
 public CasProfile validateServiceTicket(final String serviceURL, final CasCredentials ticket) {
   try {
     final Assertion assertion =
         getAuthenticator().getTicketValidator().validate(ticket.getServiceTicket(), serviceURL);
     final AttributePrincipal principal = assertion.getPrincipal();
     final CasProfile casProfile = new CasProfile();
     casProfile.setId(principal.getName());
     casProfile.addAttributes(principal.getAttributes());
     return casProfile;
   } catch (final TicketValidationException e) {
     throw new TechnicalException(e);
   }
 }