xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdSecInterface.hh
Go to the documentation of this file.
1 #ifndef __SEC_INTERFACE_H__
2 #define __SEC_INTERFACE_H__
3 /******************************************************************************/
4 /* */
5 /* X r d S e c I n t e r f a c e . h h */
6 /* */
7 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Andrew Hanushevsky for Stanford University under contract */
9 /* DE-AC02-76-SFO0515 with the Department of Energy */
10 /* */
11 /* This file is part of the XRootD software suite. */
12 /* */
13 /* XRootD is free software: you can redistribute it and/or modify it under */
14 /* the terms of the GNU Lesser General Public License as published by the */
15 /* Free Software Foundation, either version 3 of the License, or (at your */
16 /* option) any later version. */
17 /* */
18 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21 /* License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26 /* */
27 /* The copyright holder's institutional names and contributor's names may not */
28 /* be used to endorse or promote products derived from this software without */
29 /* specific prior written permission of the institution or contributor. */
30 /******************************************************************************/
31 
32 #include <cerrno>
33 #ifndef WIN32
34 #include <sys/param.h>
35 #endif
36 #include <cstdlib>
37 #include <cstdio>
38 #include <cstring>
39 
40 #include "XrdSec/XrdSecEntity.hh"
41 
42 /******************************************************************************/
43 /* 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 */
44 /******************************************************************************/
45 
46 //------------------------------------------------------------------------------
48 //------------------------------------------------------------------------------
49 
51 {
52  int size;
53  char *buffer;
54 
55  XrdSecBuffer(char *bp=0, int sz=0) : size(sz), buffer(bp), membuf(bp) {}
56  ~XrdSecBuffer() {if (membuf) free(membuf);}
57 
58 private:
59  char *membuf; // Stable copy of the buffer address
60 };
61 
62 //------------------------------------------------------------------------------
67 //------------------------------------------------------------------------------
68 
70 
71 //------------------------------------------------------------------------------
77 //------------------------------------------------------------------------------
78 
80 
81 /******************************************************************************/
82 /* X r d S e c P r o t o c o l */
83 /******************************************************************************/
128 class XrdOucErrInfo;
129 
131 {
132 public:
133 
134 //------------------------------------------------------------------------------
137 //------------------------------------------------------------------------------
138 
140 
141 //------------------------------------------------------------------------------
154 //------------------------------------------------------------------------------
155 
156 virtual int Authenticate (XrdSecCredentials *cred,
157  XrdSecParameters **parms,
158  XrdOucErrInfo *einfo=0)=0;
159 
160 //------------------------------------------------------------------------------
173 //------------------------------------------------------------------------------
174 
176  XrdOucErrInfo *einfo=0)=0;
177 
178 //------------------------------------------------------------------------------
191 //------------------------------------------------------------------------------
192 
193 virtual int Encrypt(const char *inbuff, // Data to be encrypted
194  int inlen, // Length of data in inbuff
195  XrdSecBuffer **outbuff // Returns encrypted data
196  )
197 {
198  (void) inbuff; (void) inlen; (void) outbuff;
199  return -ENOTSUP;
200 }
201 
202 //------------------------------------------------------------------------------
212 //------------------------------------------------------------------------------
213 
214 virtual int Decrypt(const char *inbuff, // Data to be decrypted
215  int inlen, // Length of data in inbuff
216  XrdSecBuffer **outbuff // Buffer for decrypted data
217  )
218 {
219  (void) inbuff; (void) inlen; (void) outbuff;
220  return -ENOTSUP;
221 }
222 
223 //------------------------------------------------------------------------------
233 //------------------------------------------------------------------------------
234 
235 virtual int Sign(const char *inbuff, // Data to be signed
236  int inlen, // Length of data in inbuff
237  XrdSecBuffer **outbuff // Buffer for the signature
238  )
239 {
240  (void) inbuff; (void) inlen; (void) outbuff;
241  return -ENOTSUP;
242 }
243 
244 //------------------------------------------------------------------------------
255 //------------------------------------------------------------------------------
256 
257 virtual int Verify(const char *inbuff, // Data to be decrypted
258  int inlen, // Length of data in inbuff
259  const char *sigbuff, // Buffer for signature
260  int siglen) // Length if signature
261 {
262  (void) inbuff; (void) inlen; (void) sigbuff; (void) siglen;
263  return -ENOTSUP;
264 }
265 
266 //------------------------------------------------------------------------------
277 //------------------------------------------------------------------------------
278 
279 virtual int getKey(char *buff = 0, int size = 0)
280 {
281  (void) buff; (void) size;
282  return -ENOTSUP;
283 }
284 
285 //------------------------------------------------------------------------------
293 //------------------------------------------------------------------------------
294 
295 virtual int setKey(char *buff, int size)
296 {
297  (void) buff; (void) size;
298  return -ENOTSUP;
299 }
300 
301 //------------------------------------------------------------------------------
303 //------------------------------------------------------------------------------
304 
305 virtual bool needTLS() {return false;}
306 
307 //------------------------------------------------------------------------------
309 //------------------------------------------------------------------------------
310 
311 virtual void Delete()=0; // Normally does "delete this"
312 
313 //------------------------------------------------------------------------------
315 //------------------------------------------------------------------------------
316 
317  XrdSecProtocol(const char *pName) : Entity(pName) {}
318 protected:
319 
320 //------------------------------------------------------------------------------
322 //------------------------------------------------------------------------------
323 
324 virtual ~XrdSecProtocol() {}
325 };
326 
327 /******************************************************************************/
328 /* 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 */
329 /******************************************************************************/
330 
344 //------------------------------------------------------------------------------
377 //------------------------------------------------------------------------------
378 
384 //------------------------------------------------------------------------------
413 //------------------------------------------------------------------------------
414 
429 /******************************************************************************/
430 /* P r o t o c o l O b j e c t M a n a g e m e n t */
431 /******************************************************************************/
432 
436 
437 /******************************************************************************/
438 /* X r d S e c G e t P r o t o c o l */
439 /* */
440 /* C l i e n t S i d e U S e O n l y */
441 /******************************************************************************/
442 
443 //------------------------------------------------------------------------------
475 //------------------------------------------------------------------------------
476 
477 //------------------------------------------------------------------------------
479 //------------------------------------------------------------------------------
480 
481 typedef XrdSecProtocol *(*XrdSecGetProt_t)(const char *,
482  XrdNetAddrInfo &,
484  XrdOucErrInfo *);
485 
499 /******************************************************************************/
500 /* X r d S e c G e t P r o t e c t i o n */
501 /* */
502 /* C l i e n t S i d e U s e O n l y */
503 /******************************************************************************/
504 
532 /******************************************************************************/
533 /* X r d S e c S e r v i c e */
534 /* */
535 /* S e r v e r S i d e U s e O n l y */
536 /******************************************************************************/
537 
552 {
553 public:
554 
555 //------------------------------------------------------------------------------
567 //------------------------------------------------------------------------------
568 
569 virtual const char *getParms(int &size, XrdNetAddrInfo *endPoint=0) = 0;
570 
571 //------------------------------------------------------------------------------
590 //------------------------------------------------------------------------------
591 
592 virtual XrdSecProtocol *getProtocol(const char *host, // In
593  XrdNetAddrInfo &endPoint,// In
594  const XrdSecCredentials *cred, // In
595  XrdOucErrInfo &einfo)=0;// Out
596 
597 //------------------------------------------------------------------------------
609 //------------------------------------------------------------------------------
610 
611 virtual bool PostProcess(XrdSecEntity &entity,
612  XrdOucErrInfo &einfo) {return true;}
613 
614 //------------------------------------------------------------------------------
618 //------------------------------------------------------------------------------
619 
620 virtual const char *protTLS()=0;
621 
622 //------------------------------------------------------------------------------
624 //------------------------------------------------------------------------------
625 
627 
628 //------------------------------------------------------------------------------
630 //------------------------------------------------------------------------------
631 
632 virtual ~XrdSecService() {}
633 };
634 
635 /******************************************************************************/
636 /* X r d g e t S e c S e r v i c e */
637 /******************************************************************************/
638 
639 //------------------------------------------------------------------------------
659 //------------------------------------------------------------------------------
660 
661 
662 //------------------------------------------------------------------------------
664 //------------------------------------------------------------------------------
665 
666 class XrdSysLogger;
667 typedef XrdSecService *(*XrdSecGetServ_t)(XrdSysLogger *, const char *);
668 
676 #endif
char * membuf
Definition: XrdSecInterface.hh:59
virtual int setKey(char *buff, int size)
Definition: XrdSecInterface.hh:295
int size
Size of the buffer or length of data in the buffer.
Definition: XrdSecInterface.hh:52
Definition: XrdSecInterface.hh:551
Definition: XrdSecInterface.hh:130
virtual int Sign(const char *inbuff, int inlen, XrdSecBuffer **outbuff)
Definition: XrdSecInterface.hh:235
XrdSecService()
Constructor.
Definition: XrdSecInterface.hh:626
virtual XrdSecCredentials * getCredentials(XrdSecParameters *parm=0, XrdOucErrInfo *einfo=0)=0
virtual const char * getParms(int &size, XrdNetAddrInfo *endPoint=0)=0
virtual const char * protTLS()=0
Definition: XrdOucErrInfo.hh:100
XrdSecEntity Entity
Definition: XrdSecInterface.hh:139
XrdSecBuffer(char *bp=0, int sz=0)
Definition: XrdSecInterface.hh:55
j template void())
Definition: XrdOucJson.hh:4121
virtual ~XrdSecProtocol()
Destructor (prevents use of direct delete).
Definition: XrdSecInterface.hh:324
Definition: XrdNetAddrInfo.hh:53
virtual int getKey(char *buff=0, int size=0)
Definition: XrdSecInterface.hh:279
XrdSecProtocol(const char *pName)
Constructor.
Definition: XrdSecInterface.hh:317
Definition: XrdSysLogger.hh:52
virtual bool PostProcess(XrdSecEntity &entity, XrdOucErrInfo &einfo)
Definition: XrdSecInterface.hh:611
virtual void Delete()=0
Delete the protocol object. DO NOT use C++ delete() on this object.
virtual int Encrypt(const char *inbuff, int inlen, XrdSecBuffer **outbuff)
Definition: XrdSecInterface.hh:193
char * buffer
Pointer to the buffer.
Definition: XrdSecInterface.hh:53
virtual ~XrdSecService()
Destructor.
Definition: XrdSecInterface.hh:632
~XrdSecBuffer()
Definition: XrdSecInterface.hh:56
virtual int Decrypt(const char *inbuff, int inlen, XrdSecBuffer **outbuff)
Definition: XrdSecInterface.hh:214
Definition: XrdSecEntity.hh:63
virtual int Verify(const char *inbuff, int inlen, const char *sigbuff, int siglen)
Definition: XrdSecInterface.hh:257
virtual XrdSecProtocol * getProtocol(const char *host, XrdNetAddrInfo &endPoint, const XrdSecCredentials *cred, XrdOucErrInfo &einfo)=0
Generic structure to pass security information back and forth.
Definition: XrdSecInterface.hh:50
XrdSecBuffer XrdSecCredentials
Definition: XrdSecInterface.hh:69
virtual bool needTLS()
Check if this protocol requires TLS to properly function.
Definition: XrdSecInterface.hh:305
virtual int Authenticate(XrdSecCredentials *cred, XrdSecParameters **parms, XrdOucErrInfo *einfo=0)=0
XrdSecBuffer XrdSecParameters
Definition: XrdSecInterface.hh:79