XrdSecInterface.hh

Go to the documentation of this file.
00001 #ifndef __SEC_INTERFACE_H__
00002 #define __SEC_INTERFACE_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                    X r d S e c I n t e r f a c e . h h                     */
00006 /*                                                                            */
00007 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00009 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00010 /*                                                                            */
00011 /* This file is part of the XRootD software suite.                            */
00012 /*                                                                            */
00013 /* XRootD is free software: you can redistribute it and/or modify it under    */
00014 /* the terms of the GNU Lesser General Public License as published by the     */
00015 /* Free Software Foundation, either version 3 of the License, or (at your     */
00016 /* option) any later version.                                                 */
00017 /*                                                                            */
00018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00020 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00021 /* License for more details.                                                  */
00022 /*                                                                            */
00023 /* You should have received a copy of the GNU Lesser General Public License   */
00024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00025 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00026 /*                                                                            */
00027 /* The copyright holder's institutional names and contributor's names may not */
00028 /* be used to endorse or promote products derived from this software without  */
00029 /* specific prior written permission of the institution or contributor.       */
00030 /******************************************************************************/
00031 
00032 #include <errno.h>
00033 #ifndef WIN32
00034 #include <sys/param.h>
00035 #endif
00036 #include <stdlib.h>
00037 #include <stdio.h>
00038 #include <string.h>
00039 
00040 #include "XrdSec/XrdSecEntity.hh"
00041 
00042 /******************************************************************************/
00043 /*  X r d S e c C r e d e n t i a l s   &   X r d S e c P a r a m e t e r s   */
00044 /******************************************************************************/
00045   
00046 //------------------------------------------------------------------------------
00048 //------------------------------------------------------------------------------
00049 
00050 struct XrdSecBuffer
00051 {
00052        int   size;    
00053        char *buffer;  
00054 
00055        XrdSecBuffer(char *bp=0, int sz=0) : size(sz), buffer(bp), membuf(bp) {}
00056       ~XrdSecBuffer() {if (membuf) free(membuf);}
00057 
00058 private:
00059         char *membuf; // Stable copy of the buffer address
00060 };
00061 
00062 //------------------------------------------------------------------------------
00067 //------------------------------------------------------------------------------
00068 
00069 typedef XrdSecBuffer XrdSecCredentials;
00070 
00071 //------------------------------------------------------------------------------
00077 //------------------------------------------------------------------------------
00078 
00079 typedef XrdSecBuffer XrdSecParameters;
00080   
00081 /******************************************************************************/
00082 /*                        X r d S e c P r o t o c o l                         */
00083 /******************************************************************************/
00128 class XrdOucErrInfo;
00129 
00130 class XrdSecProtocol
00131 {
00132 public:
00133 
00134 //------------------------------------------------------------------------------
00137 //------------------------------------------------------------------------------
00138 
00139 XrdSecEntity               Entity;
00140 
00141 //------------------------------------------------------------------------------
00154 //------------------------------------------------------------------------------
00155 
00156 virtual int                Authenticate  (XrdSecCredentials  *cred,
00157                                           XrdSecParameters  **parms,
00158                                           XrdOucErrInfo      *einfo=0)=0;
00159 
00160 //------------------------------------------------------------------------------
00173 //------------------------------------------------------------------------------
00174 
00175 virtual XrdSecCredentials *getCredentials(XrdSecParameters   *parm=0,
00176                                           XrdOucErrInfo      *einfo=0)=0;
00177 
00178 //------------------------------------------------------------------------------
00191 //------------------------------------------------------------------------------
00192 
00193 virtual int     Encrypt(const char    * /*inbuff*/,  // Data to be encrypted
00194                               int       /*inlen*/,   // Length of data in inbuff
00195                         XrdSecBuffer ** /*outbuff*/  // Returns encrypted data
00196                              ) {return -ENOTSUP;}
00197 
00198 //------------------------------------------------------------------------------
00208 //------------------------------------------------------------------------------
00209 
00210 virtual int     Decrypt(const char  * /*inbuff*/,   // Data to be decrypted
00211                               int     /*inlen*/,    // Length of data in inbuff
00212                       XrdSecBuffer ** /*outbuff*/   // Buffer for decrypted data
00213                               ) {return -ENOTSUP;}
00214 
00215 //------------------------------------------------------------------------------
00225 //------------------------------------------------------------------------------
00226 
00227 virtual int     Sign(const char  * /*inbuff*/,   // Data to be signed
00228                            int     /*inlen*/,    // Length of data in inbuff
00229                    XrdSecBuffer ** /*outbuff*/   // Buffer for the signature
00230                            ) {return -ENOTSUP;}
00231 
00232 //------------------------------------------------------------------------------
00243 //------------------------------------------------------------------------------
00244 
00245 virtual int     Verify(const char  * /*inbuff*/,   // Data to be decrypted
00246                              int     /*inlen*/,    // Length of data in inbuff
00247                        const char  * /*sigbuff*/,  // Buffer for signature
00248                              int     /*siglen*/)   // Length if signature
00249                       {return -ENOTSUP;}
00250 
00251 //------------------------------------------------------------------------------
00262 //------------------------------------------------------------------------------
00263 
00264 virtual int     getKey(char * /*buff*/=0, int /*size*/=0) {return -ENOTSUP;}
00265 
00266 //------------------------------------------------------------------------------
00274 //------------------------------------------------------------------------------
00275 
00276 virtual int     setKey(char * /*buff*/, int /*size*/) {return -ENOTSUP;}
00277 
00278 //------------------------------------------------------------------------------
00280 //------------------------------------------------------------------------------
00281 
00282 virtual void    Delete()=0; // Normally does "delete this"
00283 
00284 //------------------------------------------------------------------------------
00286 //------------------------------------------------------------------------------
00287 
00288               XrdSecProtocol(const char *pName) : Entity(pName) {}
00289 protected:
00290 
00291 //------------------------------------------------------------------------------
00293 //------------------------------------------------------------------------------
00294 
00295 virtual      ~XrdSecProtocol() {}
00296 };
00297  
00298 /******************************************************************************/
00299 /*           P r o t o c o l   N a m i n g   C o n v e n t i o n s            */
00300 /******************************************************************************/
00301 
00315 //------------------------------------------------------------------------------
00338 //------------------------------------------------------------------------------
00339 
00345 //------------------------------------------------------------------------------
00374 //------------------------------------------------------------------------------
00375 
00388 /******************************************************************************/
00389 /*            P r o t o c o l   O b j e c t   M a n a g e m e n t             */
00390 /******************************************************************************/
00391 
00395   
00396 /******************************************************************************/
00397 /*                     X r d S e c G e t P r o t o c o l                      */
00398 /*                                                                            */
00399 /*                  C l i e n t   S i d e   U S e   O n l y                   */
00400 /******************************************************************************/
00401   
00402 //------------------------------------------------------------------------------
00434 //------------------------------------------------------------------------------
00435 
00436 //------------------------------------------------------------------------------
00438 //------------------------------------------------------------------------------
00439 
00440 typedef XrdSecProtocol *(*XrdSecGetProt_t)(const char *,
00441                                            XrdNetAddrInfo &,
00442                                            XrdSecParameters &,
00443                                            XrdOucErrInfo *);
00444 
00456 /******************************************************************************/
00457 /*                         X r d S e c S e r v i c e                          */
00458 /*                                                                            */
00459 /*                  S e r v e r   S i d e   U s e   O n l y                   */
00460 /******************************************************************************/
00461   
00475 class XrdSecService
00476 {
00477 public:
00478 
00479 //------------------------------------------------------------------------------
00491 //------------------------------------------------------------------------------
00492 
00493 virtual const char     *getParms(int &size, XrdNetAddrInfo *endPoint=0) = 0;
00494 
00495 //------------------------------------------------------------------------------
00517 //------------------------------------------------------------------------------
00518 
00519 virtual XrdSecProtocol *getProtocol(const char              *host,    // In
00520                                           XrdNetAddrInfo    &endPoint,// In
00521                                     const XrdSecCredentials *cred,    // In
00522                                           XrdOucErrInfo     *einfo)=0;// Out
00523 
00524 //------------------------------------------------------------------------------
00526 //------------------------------------------------------------------------------
00527 
00528                         XrdSecService() {}
00529 
00530 //------------------------------------------------------------------------------
00532 //------------------------------------------------------------------------------
00533 
00534 virtual                ~XrdSecService() {}
00535 };
00536   
00537 /******************************************************************************/
00538 /*                      X r d g e t S e c S e r v i c e                       */
00539 /******************************************************************************/
00540   
00541 //------------------------------------------------------------------------------
00561 //------------------------------------------------------------------------------
00562 
00563 
00564 //------------------------------------------------------------------------------
00566 //------------------------------------------------------------------------------
00567 
00568 class XrdSysLogger;
00569 typedef XrdSecService  *(*XrdSecGetServ_t)(XrdSysLogger *, const char *);
00570 
00577 #endif

Generated on 12 Dec 2014 for xrootd by  doxygen 1.4.7