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 ) 00197 { 00198 (void) inbuff; (void) inlen; (void) outbuff; 00199 return -ENOTSUP; 00200 } 00201 00202 //------------------------------------------------------------------------------ 00212 //------------------------------------------------------------------------------ 00213 00214 virtual int Decrypt(const char *inbuff, // Data to be decrypted 00215 int inlen, // Length of data in inbuff 00216 XrdSecBuffer **outbuff // Buffer for decrypted data 00217 ) 00218 { 00219 (void) inbuff; (void) inlen; (void) outbuff; 00220 return -ENOTSUP; 00221 } 00222 00223 //------------------------------------------------------------------------------ 00233 //------------------------------------------------------------------------------ 00234 00235 virtual int Sign(const char *inbuff, // Data to be signed 00236 int inlen, // Length of data in inbuff 00237 XrdSecBuffer **outbuff // Buffer for the signature 00238 ) 00239 { 00240 (void) inbuff; (void) inlen; (void) outbuff; 00241 return -ENOTSUP; 00242 } 00243 00244 //------------------------------------------------------------------------------ 00255 //------------------------------------------------------------------------------ 00256 00257 virtual int Verify(const char *inbuff, // Data to be decrypted 00258 int inlen, // Length of data in inbuff 00259 const char *sigbuff, // Buffer for signature 00260 int siglen) // Length if signature 00261 { 00262 (void) inbuff; (void) inlen; (void) sigbuff; (void) siglen; 00263 return -ENOTSUP; 00264 } 00265 00266 //------------------------------------------------------------------------------ 00277 //------------------------------------------------------------------------------ 00278 00279 virtual int getKey(char *buff = 0, int size = 0) 00280 { 00281 (void) buff; (void) size; 00282 return -ENOTSUP; 00283 } 00284 00285 //------------------------------------------------------------------------------ 00293 //------------------------------------------------------------------------------ 00294 00295 virtual int setKey(char *buff, int size) 00296 { 00297 (void) buff; (void) size; 00298 return -ENOTSUP; 00299 } 00300 00301 //------------------------------------------------------------------------------ 00303 //------------------------------------------------------------------------------ 00304 00305 virtual bool needTLS() {return false;} 00306 00307 //------------------------------------------------------------------------------ 00309 //------------------------------------------------------------------------------ 00310 00311 virtual void Delete()=0; // Normally does "delete this" 00312 00313 //------------------------------------------------------------------------------ 00315 //------------------------------------------------------------------------------ 00316 00317 XrdSecProtocol(const char *pName) : Entity(pName) {} 00318 protected: 00319 00320 //------------------------------------------------------------------------------ 00322 //------------------------------------------------------------------------------ 00323 00324 virtual ~XrdSecProtocol() {} 00325 }; 00326 00327 /******************************************************************************/ 00328 /* 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 */ 00329 /******************************************************************************/ 00330 00344 //------------------------------------------------------------------------------ 00377 //------------------------------------------------------------------------------ 00378 00384 //------------------------------------------------------------------------------ 00413 //------------------------------------------------------------------------------ 00414 00429 /******************************************************************************/ 00430 /* P r o t o c o l O b j e c t M a n a g e m e n t */ 00431 /******************************************************************************/ 00432 00436 00437 /******************************************************************************/ 00438 /* X r d S e c G e t P r o t o c o l */ 00439 /* */ 00440 /* C l i e n t S i d e U S e O n l y */ 00441 /******************************************************************************/ 00442 00443 //------------------------------------------------------------------------------ 00475 //------------------------------------------------------------------------------ 00476 00477 //------------------------------------------------------------------------------ 00479 //------------------------------------------------------------------------------ 00480 00481 typedef XrdSecProtocol *(*XrdSecGetProt_t)(const char *, 00482 XrdNetAddrInfo &, 00483 XrdSecParameters &, 00484 XrdOucErrInfo *); 00485 00499 /******************************************************************************/ 00500 /* X r d S e c G e t P r o t e c t i o n */ 00501 /* */ 00502 /* C l i e n t S i d e U s e O n l y */ 00503 /******************************************************************************/ 00504 00532 /******************************************************************************/ 00533 /* X r d S e c S e r v i c e */ 00534 /* */ 00535 /* S e r v e r S i d e U s e O n l y */ 00536 /******************************************************************************/ 00537 00551 class XrdSecService 00552 { 00553 public: 00554 00555 //------------------------------------------------------------------------------ 00567 //------------------------------------------------------------------------------ 00568 00569 virtual const char *getParms(int &size, XrdNetAddrInfo *endPoint=0) = 0; 00570 00571 //------------------------------------------------------------------------------ 00590 //------------------------------------------------------------------------------ 00591 00592 virtual XrdSecProtocol *getProtocol(const char *host, // In 00593 XrdNetAddrInfo &endPoint,// In 00594 const XrdSecCredentials *cred, // In 00595 XrdOucErrInfo &einfo)=0;// Out 00596 00597 //------------------------------------------------------------------------------ 00609 //------------------------------------------------------------------------------ 00610 00611 virtual bool PostProcess(XrdSecEntity &entity, 00612 XrdOucErrInfo &einfo) {return true;} 00613 00614 //------------------------------------------------------------------------------ 00618 //------------------------------------------------------------------------------ 00619 00620 virtual const char *protTLS()=0; 00621 00622 //------------------------------------------------------------------------------ 00624 //------------------------------------------------------------------------------ 00625 00626 XrdSecService() {} 00627 00628 //------------------------------------------------------------------------------ 00630 //------------------------------------------------------------------------------ 00631 00632 virtual ~XrdSecService() {} 00633 }; 00634 00635 /******************************************************************************/ 00636 /* X r d g e t S e c S e r v i c e */ 00637 /******************************************************************************/ 00638 00639 //------------------------------------------------------------------------------ 00659 //------------------------------------------------------------------------------ 00660 00661 00662 //------------------------------------------------------------------------------ 00664 //------------------------------------------------------------------------------ 00665 00666 class XrdSysLogger; 00667 typedef XrdSecService *(*XrdSecGetServ_t)(XrdSysLogger *, const char *); 00668 00676 #endif