Package net.unicon.cas.overlay.events

Source Code of net.unicon.cas.overlay.events.LogPublishingCasServiceTicketValidatedEventListener

package net.unicon.cas.overlay.events;

import com.github.inspektr.common.web.ClientInfoHolder;
import net.unicon.cas.addons.authentication.support.Assertions;
import net.unicon.cas.addons.info.events.CasServiceTicketValidatedEvent;
import org.jasig.cas.authentication.principal.Principal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;


/**
* Example Cas ST validated event listener that logs contextual data associated with <code>CasServiceTicketValidatedEvent</code>
* to the slf4j appender's destination.
*
* @author Dmitriy Kopylenko
* @author Unicon, inc.
*/
@Component
public class LogPublishingCasServiceTicketValidatedEventListener implements
        ApplicationListener<CasServiceTicketValidatedEvent> {

    private static final Logger logger = LoggerFactory.getLogger(LogPublishingCasServiceTicketValidatedEventListener.class);

    @Override
    public void onApplicationEvent(CasServiceTicketValidatedEvent event) {
        final Principal principal = Assertions.getAuthenticatedPrincipalFrom(event.getAssertion());
        logger.info("==================== RELEASED SERVICE ATTRIBUTES =============================");
        logger.info("Request is received from the following IP address: [{}]", ClientInfoHolder.getClientInfo().getClientIpAddress());
        logger.info("Service [{}] will receive the following attributes [{}] for the authenticated principal [{}]", event.getService().getId(), principal.getAttributes(), principal.getId());
        logger.info("==================== RELEASED SERVICE ATTRIBUTES (END) =============================");
    }
}
TOP

Related Classes of net.unicon.cas.overlay.events.LogPublishingCasServiceTicketValidatedEventListener

TOP
Copyright © 2018 www.massapi.com. 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.