Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Protected Member Functions | Protected Attributes
Echo::Service_Echo Class Reference

This is a test service which accepts SOAP requests and produces response as described in echo.wsdl. More...

#include <echo.h>

Inheritance diagram for Echo::Service_Echo:
Inheritance graph
[legend]
Collaboration diagram for Echo::Service_Echo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Service_Echo (Arc::Config *cfg)
 Constructor accepts configuration describing content of prefix and suffix.
virtual ~Service_Echo (void)
virtual Arc::MCC_Status process (Arc::Message &, Arc::Message &)
 Service request processing routine.
bool RegistrationCollector (Arc::XMLNode &doc)
 Service specific registartion collector, used for generate service registartions.
virtual void AddSecHandler (Config *cfg, ArcSec::SecHandler *sechandler, const std::string &label="")
 Add security components/handlers to this MCC.
virtual std::string getID ()
 Service may implement own service identitifer gathering method.

Protected Member Functions

Arc::MCC_Status make_fault (Arc::Message &outmsg, const std::string &txtmsg="")
bool ProcessSecHandlers (Message &message, const std::string &label="") const
 Executes security handlers of specified queue.

Protected Attributes

std::string prefix_
std::string suffix_
std::string policylocation_
Arc::NS ns_
Arc::Logger logger
 Logger object used to print messages generated by this class.
Arc::InformationContainer infodoc
std::map< std::string,
std::list< ArcSec::SecHandler * > > 
sechandlers_
 Set of labeled authentication and authorization handlers.

Detailed Description

This is a test service which accepts SOAP requests and produces response as described in echo.wsdl.

Response contains string passed in request with prefix_ and suffix_ added. About the policy decision, here the echo service is used as an example to demostrate how to implement and deploy it. For service developer, he is supposed to marshall the pdp request into a internal structure For service deployer, he is supposed to do the following two things: a, write the policy according to its requirement, and based on the Policy.xsd schema. b, configure the service.xml, put the pdp configuration into a <SecHandler> <PDP name="arc.pdp" policylocation="Policy_Example.xml"> The "name" attribute is the identifier for dynamic loading the ArcPDP object. The "policylocation" attribute is for the configuration of ArcPDP's policy

Definition at line 27 of file echo.h.


Constructor & Destructor Documentation

Constructor accepts configuration describing content of prefix and suffix.

Definition at line 30 of file echo.cpp.

                                        :RegisteredService(cfg),logger(Arc::Logger::rootLogger, "Echo") {
  ns_["echo"]="http://www.nordugrid.org/schemas/echo";
  prefix_=(std::string)((*cfg)["prefix"]);
  suffix_=(std::string)((*cfg)["suffix"]);

#if 0
  // Parse the policy location information, and put them into a map container for later using
  for(int i=0;; i++) {
    Arc::XMLNode cn = (*cfg).Child(i);
    if(!cn) break;
    if(MatchXMLName(cn, "SecHandler")) {
      for(int j=0;; j++) {
        Arc::XMLNode gn = cn.Child(j);
        if(!gn) break;
        if(MatchXMLName(gn, "PDP")) {
          policylocation_  = (std::string)(gn.Attribute("policylocation"));
        }
      }
    }
  }
#endif

  // Assigning service description - Glue2 document should go here.
  infodoc.Assign(Arc::XMLNode(
    "<?xml version=\"1.0\"?>"
    "<Domains><AdminDomain><Services><Service><Endpoint><HealthState>ok</HealthState><ServingState>production</ServingState></Endpoint>ECHO</Service></Services></AdminDomain></Domains>"
  ),true);
}

Here is the call graph for this function:

Echo::Service_Echo::~Service_Echo ( void  ) [virtual]

Definition at line 59 of file echo.cpp.

                                {
}

Member Function Documentation

void Arc::Service::AddSecHandler ( Config cfg,
ArcSec::SecHandler sechandler,
const std::string &  label = "" 
) [virtual, inherited]

Add security components/handlers to this MCC.

For more information please see description of MCC::AddSecHandler

Definition at line 14 of file Service.cpp.

                                                                                           {
    if(sechandler) {
        sechandlers_[label].push_back(sechandler); //need polishing to put the SecHandlerFactory->getinstance here
        XMLNode cn = (*cfg)["SecHandler"];
        Config cfg_(cn);
    }
}

Here is the caller graph for this function:

virtual std::string Arc::Service::getID ( ) [inline, virtual, inherited]

Service may implement own service identitifer gathering method.

This method return identifier of service which is used for registering it Information Services.

Reimplemented in ARex::ARexService.

Definition at line 69 of file Service.h.

{ return ""; };
Arc::MCC_Status Echo::Service_Echo::make_fault ( Arc::Message outmsg,
const std::string &  txtmsg = "" 
) [protected]

Definition at line 62 of file echo.cpp.

                                                                                 {
  Arc::PayloadSOAP* outpayload = new Arc::PayloadSOAP(ns_,true);
  Arc::SOAPFault* fault = outpayload->Fault();
  if(fault) {
    fault->Code(Arc::SOAPFault::Sender);
    if(txtmsg.empty()) {
      fault->Reason("Failed processing request");
    } else {
      logger.msg(Arc::ERROR, txtmsg);
      fault->Reason(txtmsg);
    };
  };
  outmsg.Payload(outpayload);
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Service request processing routine.

Export the formated policy-decision request

Implements Arc::MCCInterface.

Definition at line 78 of file echo.cpp.

                                                                        {
  //Store policy location into message attribute
  //inmsg.Attributes()->add("PDP:POLICYLOCATION", policylocation_);
  // Check authorization
  if(!ProcessSecHandlers(inmsg, "incoming")) {
    logger.msg(Arc::ERROR, "echo: Unauthorized");
    return Arc::MCC_Status(Arc::GENERIC_ERROR);
  };
  // Both input and output are supposed to be SOAP 
  // Extracting payload
  Arc::PayloadSOAP* inpayload = NULL;
  try {
    inpayload = dynamic_cast<Arc::PayloadSOAP*>(inmsg.Payload());
  } catch(std::exception& e) { };
  if(!inpayload) {
    return make_fault(outmsg,"Input is not SOAP");
  };
  {
      std::string str;
      inpayload->GetDoc(str, true);
      logger.msg(Arc::VERBOSE, "process: request=%s",str);
  }; 

  Arc::PayloadSOAP* outpayload = NULL;


  MessageAuth* mauth = inmsg.Auth();
  MessageAuth* cauth = inmsg.AuthContext();
  if((!mauth) && (!cauth)) {
    logger.msg(ERROR,"Missing security object in message");
    return Arc::MCC_Status();
  };
  NS ns;
  XMLNode requestxml(ns,"");
  if(mauth) {
    if(!mauth->Export(SecAttr::ARCAuth,requestxml)) {
      delete mauth;
      logger.msg(ERROR,"Failed to convert security information to ARC request");
      return Arc::MCC_Status();
    };
  };
  if(cauth) {
    if(!cauth->Export(SecAttr::ARCAuth,requestxml)) {
      delete mauth;
      logger.msg(ERROR,"Failed to convert security information to ARC request");
      return Arc::MCC_Status();
    };
  };
  // Analyzing request 

  // Checking if it's info request
  if(MatchXMLNamespace(inpayload->Child(0),"http://docs.oasis-open.org/wsrf/rp-2")) {
    Arc::SOAPEnvelope* outxml = infodoc.Process(*inpayload);
    if(!outxml) {
      return make_fault(outmsg,"WSRF request processing failed");
    };
    outpayload = new Arc::PayloadSOAP(*outxml);
    delete outxml;
  }
  else if((*inpayload)["size"]){
    Arc::XMLNode echo_op = (*inpayload)["size"];
    int size = atoi(std::string(echo_op["size"]).c_str());
    std::string msg = "Message for you, sir";
    msg.resize(size,'0');
    std::string say = echo_op["say"];
    std::string hear = prefix_+say+suffix_;
    outpayload = new Arc::PayloadSOAP(ns_);
    outpayload->NewChild("echo:echoResponse").NewChild("echo:hear")=msg;
  }
  else {
    // Then it must be 'echo' operation requested
    Arc::XMLNode echo_op = (*inpayload)["echo"];
    if(!echo_op) {
      return make_fault(outmsg,"Request is not supported - "+echo_op.Name());
    };
    std::string say = echo_op["say"];
    std::string hear = prefix_+say+suffix_;
    outpayload = new Arc::PayloadSOAP(ns_);
    outpayload->NewChild("echo:echoResponse").NewChild("echo:hear")=hear;
  };

  outmsg.Payload(outpayload);
  {
      std::string str;
      outpayload->GetDoc(str, true);
      logger.msg(Arc::VERBOSE, "process: response=%s",str);
  }; 
  return Arc::MCC_Status(Arc::STATUS_OK);
}

Here is the call graph for this function:

bool Arc::Service::ProcessSecHandlers ( Message message,
const std::string &  label = "" 
) const [protected, inherited]

Executes security handlers of specified queue.

For more information please see description of MCC::ProcessSecHandlers

Definition at line 22 of file Service.cpp.

                                                                              {
    std::map<std::string,std::list<ArcSec::SecHandler*> >::const_iterator q = sechandlers_.find(label);
    if(q == sechandlers_.end()) {
        logger.msg(DEBUG, "No security processing/check requested for '%s'", label);
        return true;
    }

    std::list<ArcSec::SecHandler*>::const_iterator h = q->second.begin();
    for(;h!=q->second.end();++h) {
        const ArcSec::SecHandler* handler = *h;
        if(handler) if(!(handler->Handle(&message))) {
            logger.msg(DEBUG, "Security processing/check for '%s' failed", label);
            return false;
        }
    }
    logger.msg(DEBUG, "Security processing/check for '%s' passed", label);
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Service specific registartion collector, used for generate service registartions.

In implemented service this method should generate GLUE2 document with part of service description which service wishes to advertise to Information Services.

Reimplemented from Arc::Service.

Definition at line 171 of file echo.cpp.

                                                        {
  // RegEntry element generation
  Arc::XMLNode empty(ns_, "RegEntry");
  empty.New(doc);
  doc.NewChild("SrcAdv").NewChild("Type") = "org.nordugrid.tests.echo";
  return true;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 36 of file echo.h.

Logger object used to print messages generated by this class.

Reimplemented from Arc::Service.

Definition at line 35 of file echo.h.

Definition at line 33 of file echo.h.

std::string Echo::Service_Echo::policylocation_ [protected]

Definition at line 32 of file echo.h.

std::string Echo::Service_Echo::prefix_ [protected]

Definition at line 30 of file echo.h.

std::map<std::string,std::list<ArcSec::SecHandler*> > Arc::Service::sechandlers_ [protected, inherited]

Set of labeled authentication and authorization handlers.

MCC calls sequence of handlers at specific point depending on associated identifier. in most aces those are "in" and "out" for incoming and outgoing messages correspondingly.

Definition at line 40 of file Service.h.

std::string Echo::Service_Echo::suffix_ [protected]

Definition at line 31 of file echo.h.


The documentation for this class was generated from the following files: