Back to index

nordugrid-arc-nox  1.1.0~rc6
PayloadTLSStream.h
Go to the documentation of this file.
00001 #ifndef __ARC_PAYLOADTLSSTREAM_H__
00002 #define __ARC_PAYLOADTLSSTREAM_H__
00003 
00004 #include <unistd.h>
00005 #include <string>
00006 
00007 #include <arc/message/Message.h>
00008 #include <arc/message/PayloadStream.h>
00009 #include <arc/Logger.h>
00010 
00011 #include <openssl/ssl.h>
00012 
00013 namespace Arc {
00014 
00016 class PayloadTLSStream: public PayloadStreamInterface {
00017  protected:
00018   int timeout_;   
00019   SSL* ssl_; 
00020   Logger& logger_;
00021 public:
00024   PayloadTLSStream(Logger& logger,SSL* ssl=NULL);
00025   PayloadTLSStream(PayloadTLSStream& stream);
00027   virtual ~PayloadTLSStream(void);
00028   
00029   void HandleError(int code = SSL_ERROR_NONE);
00030   static void HandleError(Logger& logger,int code = SSL_ERROR_NONE);
00031   static void ClearError(void);
00032 
00033   virtual bool Get(char* buf,int& size);
00034   virtual bool Get(std::string& buf);
00035   virtual std::string Get(void) { std::string buf; Get(buf); return buf; };
00036   virtual bool Put(const char* buf,Size_t size);
00037   virtual bool Put(const std::string& buf) { return Put(buf.c_str(),buf.length()); };
00038   virtual bool Put(const char* buf) { return Put(buf,buf?strlen(buf):0); };
00039   virtual operator bool(void) { return (ssl_ != NULL); };
00040   virtual bool operator!(void) { return (ssl_ == NULL); };
00041   virtual int Timeout(void) const { return timeout_; };
00042   virtual void Timeout(int to) { timeout_=to; };
00043   virtual Size_t Pos(void) const { return 0; };
00044   virtual Size_t Size(void) const { return 0; };
00045   virtual Size_t Limit(void) const { return 0; };
00046 
00050   X509* GetPeerCert(void);
00054   STACK_OF(X509)* GetPeerChain(void);
00058   X509* GetCert(void);
00059 };
00060 
00061 }
00062 #endif /* __ARC_PAYLOADTLSSTREAM_H__ */