Back to index

nordugrid-arc-nox  1.1.0~rc6
PayloadGSIStream.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifndef __ARC_PAYLOADGSISTREAM_H__
00004 #define __ARC_PAYLOADGSISTREAM_H__
00005 
00006 #include <unistd.h>
00007 #include <string>
00008 
00009 #include <arc/message/PayloadStream.h>
00010 #include <arc/Logger.h>
00011 
00012 #include <gssapi.h>
00013 
00014 namespace Arc {
00015 
00016   class PayloadGSIStream
00017     : public PayloadStreamInterface {
00018   public:
00019     PayloadGSIStream(PayloadStreamInterface *stream,
00020                      gss_ctx_id_t& ctx,
00021                      Logger& logger,
00022                      bool client);
00023     virtual ~PayloadGSIStream();
00024 
00025     virtual bool Get(char *buf, int& size);
00026 
00027     virtual bool Get(std::string& buf);
00028 
00029     virtual std::string Get() {
00030       std::string buf;
00031       Get(buf);
00032       return buf;
00033     }
00034 
00035     virtual bool Put(const char *buf, Size_t size) {}
00036 
00037     virtual bool Put(const std::string& buf) {
00038       return Put(buf.c_str(), buf.length());
00039     }
00040 
00041     virtual bool Put(const char *buf) {
00042       return Put(buf, buf ? strlen(buf) : 0);
00043     }
00044 
00045     virtual operator bool() {
00046       return (ctx != GSS_C_NO_CONTEXT);
00047     }
00048 
00049     virtual bool operator!() {
00050       return (ctx == GSS_C_NO_CONTEXT);
00051     }
00052 
00053     virtual int Timeout() const {
00054       return timeout;
00055     }
00056 
00057     virtual void Timeout(int to) {
00058       timeout = to;
00059     }
00060 
00061     virtual Size_t Pos() const {
00062       return 0;
00063     }
00064     virtual Size_t Size(void) const { 
00065       return 0; 
00066     }
00067     virtual Size_t Limit(void) const {
00068       return 0;
00069    };
00070 
00071   protected:
00072     int timeout;
00073     PayloadStreamInterface *stream;
00074     char *buffer;
00075     int bufferpos;
00076     int bufferlen;
00077     gss_ctx_id_t& ctx;
00078     Logger& logger;
00079     bool client;
00080   };
00081 
00082 } // namespace Arc
00083 
00084 #endif /* __ARC_PAYLOADGSISTREAM_H__ */