Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Private Member Functions | Private Attributes
Arc::Plexer Class Reference

The Plexer class, used for routing messages to services. More...

#include <Plexer.h>

Inheritance diagram for Arc::Plexer:
Inheritance graph
[legend]
Collaboration diagram for Arc::Plexer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Plexer (Config *cfg)
 The constructor.
virtual ~Plexer ()
 The destructor.
virtual void Next (MCCInterface *next, const std::string &label)
 Add reference to next MCC in chain.
virtual MCC_Status process (Message &request, Message &response)
 Route request messages to appropriate services.
virtual void AddSecHandler (Config *cfg, ArcSec::SecHandler *sechandler, const std::string &label="")
 Add security components/handlers to this MCC.
virtual void Unlink ()
 Removing all links.

Static Public Attributes

static Logger logger
 A logger for MCCs.

Protected Member Functions

MCCInterfaceNext (const std::string &label="")
bool ProcessSecHandlers (Message &message, const std::string &label="") const
 Executes security handlers of specified queue.

Protected Attributes

std::map< std::string,
MCCInterface * > 
next_
 Set of labeled "next" components.
std::map< std::string,
std::list< ArcSec::SecHandler * > > 
sechandlers_
 Set of labeled authentication and authorization handlers.

Static Private Member Functions

static std::string getPath (std::string url)
 Extracts the path part of an URL.

Private Attributes

std::list< PlexerEntrymccs
 The map of next MCCs.

Detailed Description

The Plexer class, used for routing messages to services.

This is the Plexer class. Its purpose is to route incoming messages to appropriate Services and MCC chains.

Definition at line 36 of file Plexer.h.


Constructor & Destructor Documentation

The constructor.

This is the constructor. Since all member variables are instances of "well-behaving" STL classes, nothing needs to be done.

Definition at line 18 of file Plexer.cpp.

                            : MCC(cfg) {
  }
Arc::Plexer::~Plexer ( ) [virtual]

The destructor.

This is the destructor. Since all member variables are instances of "well-behaving" STL classes, nothing needs to be done.

Definition at line 21 of file Plexer.cpp.

                 {
  }

Member Function Documentation

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

Add security components/handlers to this MCC.

Security handlers are stacked into a few queues with each queue identified by its label. The queue labelled 'incoming' is executed for every 'request' message after the message is processed by the MCC on the service side and before processing on the client side. The queue labelled 'outgoing' is run for response message before it is processed by MCC algorithms on the service side and after processing on the client side. Those labels are just a matter of agreement and some MCCs may implement different queues executed at various message processing steps.

Definition at line 35 of file MCC.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:

std::string Arc::Plexer::getPath ( std::string  url) [static, private]

Extracts the path part of an URL.

Definition at line 69 of file Plexer.cpp.

                                        {
    // TODO: Need even more reliable URL detection
    std::string::size_type ds, ps;
    ds=url.find("://");
    if (ds==std::string::npos)
      ps=url.find("/");
    else
      ps=url.find("/", ds+3);
    if (ps==std::string::npos)
      return "";
    else
      return url.substr(ps);
  }

Here is the caller graph for this function:

MCCInterface * Arc::MCC::Next ( const std::string &  label = "") [protected, inherited]

Definition at line 22 of file MCC.cpp.

                                                {
    std::map<std::string, MCCInterface *>::iterator n = next_.find(label);
    if (n == next_.end())
      return NULL;
    return n->second;
  }

Here is the caller graph for this function:

void Arc::Plexer::Next ( MCCInterface next,
const std::string &  label 
) [virtual]

Add reference to next MCC in chain.

This method is called by Loader for every potentially labeled link to next component which implements MCCInterface. If next is set NULL corresponding link is removed.

Reimplemented from Arc::MCC.

Definition at line 24 of file Plexer.cpp.

                                                             {
    std::list<PlexerEntry>::iterator iter;
    if (next!=0) {
      RegularExpression regex(label);
      if (regex.isOk()) {
        mccs.push_front(PlexerEntry(regex,next));
      } else {
        logger.msg(WARNING, "Bad label: \"%s\"", label);
      }
    } else {
      for (iter=mccs.begin(); iter!=mccs.end();) {
        if (iter->label.hasPattern(label)) {
          iter = mccs.erase(iter);
        } else {
          ++iter;
        }
      }
    }
  }

Here is the call graph for this function:

MCC_Status Arc::Plexer::process ( Message request,
Message response 
) [virtual]

Route request messages to appropriate services.

Routes the request message to the appropriate service. Routing is based on the path part of value of the ENDPOINT attribute. Routed message is assigned following attributes: PLEXER:PATTERN - matched pattern, PLEXER:EXTENSION - last unmatched part of ENDPOINT path.

Reimplemented from Arc::MCC.

Definition at line 44 of file Plexer.cpp.

                                                               {
    std::string ep = request.Attributes()->get("ENDPOINT");
    std::string path = getPath(ep);
    logger.msg(VERBOSE, "Operation on path \"%s\"",path);
    std::list<PlexerEntry>::iterator iter;
    for (iter=mccs.begin(); iter!=mccs.end(); ++iter) {
      std::list<std::string> unmatched, matched;
      if (iter->label.match(path, unmatched, matched)) {
        request.Attributes()->set("PLEXER:PATTERN",iter->label.getPattern());
        request.Attributes()->set("PLEXER:EXTENSION", "");
        if(unmatched.size() > 0) {
          request.Attributes()->set("PLEXER:EXTENSION",*(--unmatched.end()));
        };
        return iter->mcc->process(request, response);
      }
    }
    logger.msg(WARNING, "No next MCC or Service at path \"%s\"",path);
    return MCC_Status(UNKNOWN_SERVICE_ERROR,
                        (std::string)("MCC Plexer"),
                        path);  
  }

Here is the call graph for this function:

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

Executes security handlers of specified queue.

Returns true if the message is authorized for further processing or if there are no security handlers which implement authorization functionality. This is a convenience method and has to be called by the implemention of the MCC.

Definition at line 45 of file MCC.cpp.

                                           {
    // Each MCC/Service can define security handler queues in the configuration
    // file, the queues have labels specified in handlers configuration 'event'
    // attribute.
    // Security handlers in one queue are called sequentially.
    // Each one should be configured carefully, because there can be some
    // relationship between them (e.g. authentication should be put in front
    // of authorization).
    // The SecHandler::Handle() only returns true/false with true meaning that
    // handler processed message successfuly. If SecHandler implements
    // authorization functionality, it returns false if message is disallowed
    // and true otherwise.
    // If any SecHandler in the handler chain produces some information which
    // will be used by some following handler, the information should be
    // stored in the attributes of message (e.g. the Identity extracted from
    // authentication will be used by authorization to make access control
    // decision).
    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;
    }
    for (std::list<ArcSec::SecHandler *>::const_iterator h = q->second.begin();
         h != q->second.end(); ++h) {
      const ArcSec::SecHandler *handler = *h;
      if (!handler)
        continue; // Shouldn't happen. Just a sanity check.
      if (!(handler->Handle(&message))) {
        logger.msg(INFO, "Security processing/check failed");
        return false;
      }
    }
    logger.msg(DEBUG, "Security processing/check passed");
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void Arc::MCC::Unlink ( ) [virtual, inherited]

Removing all links.

Useful for destroying chains.

Definition at line 29 of file MCC.cpp.

                   {
    for (std::map<std::string, MCCInterface *>::iterator n = next_.begin();
         n != next_.end(); n = next_.begin())
      next_.erase(n);
  }

Here is the caller graph for this function:


Member Data Documentation

A logger for MCCs.

A logger intended to be the parent of loggers in the different MCCs.

Reimplemented from Arc::MCC.

Definition at line 71 of file Plexer.h.

std::list<PlexerEntry> Arc::Plexer::mccs [private]

The map of next MCCs.

This is a map that maps labels (regex expressions) to next elements with MCC interface. It is used for routing messages.

Definition at line 82 of file Plexer.h.

std::map<std::string, MCCInterface *> Arc::MCC::next_ [protected, inherited]

Set of labeled "next" components.

Each implemented MCC must call process() method of corresponding MCCInterface from this set in own process() method.

Definition at line 50 of file MCC.h.

std::map<std::string, std::list<ArcSec::SecHandler *> > Arc::MCC::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 57 of file MCC.h.


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