@Override
    public boolean handleMessage(SOAPMessageContext context) {
        if (!feslAuthZ) {
            return true;
        }
        String service =
                ((QName) context.get(SOAPMessageContext.WSDL_SERVICE))
                        .getLocalPart();
        String operation =
                ((QName) context.get(SOAPMessageContext.WSDL_OPERATION))
                        .getLocalPart();
        if (logger.isDebugEnabled()) {
            logger.debug("AuthHandler executed: " + service + "/" + operation
                    + " [" + m_ts + "]");
        }

        //        // Obtain the service details
        //        ServiceDesc service = context.getService().getServiceDescription();
        //        // Obtain the operation details and message type
        //        OperationDesc operation = context.getOperation();
        // Obtain a class to handle our request
        OperationHandler operationHandler = getHandler(service, operation);

        // there must always be a handler.
        if (operationHandler == null) {
            logger.error("Missing handler for service/operation: " + service
                    + "/" + operation);
            throw CXFUtility
                    .getFault(new PEPException("Missing handler for service/operation: "
                            + service + "/" + operation));
        }

        RequestCtx reqCtx = null;

        // if we are on the request pathway, outboundProperty == false. True on
        // response pathway
        Boolean outboundProperty =
                (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        try {
            if (outboundProperty) {
                reqCtx = operationHandler.handleResponse(context);
            } else {
                reqCtx = operationHandler.handleRequest(context);
            }
        } catch (OperationHandlerException ohe) {
            logger.error("Error handling operation: " + operation, ohe);
            throw CXFUtility
                    .getFault(new PEPException("Error handling operation: "
                            + operation, ohe));
        }

        // if handler returns null, then there is no work to do (would have
        // thrown exception if things went wrong).
        if (reqCtx == null) {
            return false;
        }

        // if we have received a requestContext, we need to hand it over to the
        // context handler for resolution.
        ResponseCtx resCtx = null;

        try {
            resCtx = m_ctxHandler.evaluate(reqCtx);
        } catch (PEPException pe) {
            logger.error("Error evaluating request", pe);
            throw CXFUtility
                    .getFault(new PEPException("Error evaluating request (operation: "
                                                       + operation + ")",
                                               pe));
        }

        // TODO: set obligations
        /*
         * Need to set obligations in some sort of map, with UserID/SessionID +
         * list of obligationIDs. Enforce will have to check that these
         * obligations are met before providing access. There will need to be an
         * external obligations service that this PEP can communicate with. Will
         * be working on that... This service will throw an 'Obligations need to
         * be met' exception for outstanding obligations
         */

        // TODO: enforce will need to ensure that obligations are met.
        enforce(resCtx);
        return true;
    }
@ Override public boolean handleMessage ( SOAPMessageContext context ) { if ( ! feslAuthZ ) { return true ; } String service = ( ( QName ) context . get ( SOAPMessageContext . WSDL_SERVICE ) ) . getLocalPart ( ) ; String operation = ( ( QName ) context . get ( SOAPMessageContext . WSDL_OPERATION ) ) . getLocalPart ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "AuthHandler executed: " + service + "/" + operation + " [" + m_ts + "]" ) ; } OperationHandler operationHandler = getHandler ( service , operation ) ; if ( operationHandler == null ) { logger . error ( "Missing handler for service/operation: " + service + "/" + operation ) ; throw CXFUtility . getFault ( new PEPException ( "Missing handler for service/operation: " + service + "/" + operation ) ) ; } RequestCtx reqCtx = null ; Boolean outboundProperty = ( Boolean ) context . get ( MessageContext . MESSAGE_OUTBOUND_PROPERTY ) ; try { if ( outboundProperty ) { reqCtx = operationHandler . handleResponse ( context ) ; } else { reqCtx = operationHandler . handleRequest ( context ) ; } } catch ( OperationHandlerException ohe ) { logger . error ( "Error handling operation: " + operation , ohe ) ; throw CXFUtility . getFault ( new PEPException ( "Error handling operation: " + operation , ohe ) ) ; } if ( reqCtx == null ) { return false ; } ResponseCtx resCtx = null ; try { resCtx = m_ctxHandler . evaluate ( reqCtx ) ; } catch ( PEPException pe ) { logger . error ( "Error evaluating request" , pe ) ; throw CXFUtility . getFault ( new PEPException ( "Error evaluating request (operation: " + operation + ")" , pe ) ) ; } enforce ( resCtx ) ; return true ; }
/*
(non-Javadoc)