xrootd
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 <errno.h>
33 #ifndef WIN32
34 #include <sys/param.h>
35 #endif
36 #include <stdlib.h>
37 #include <stdio.h>
38 #include <string.h>
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 void Delete()=0; // Normally does "delete this"
306 
307 //------------------------------------------------------------------------------
309 //------------------------------------------------------------------------------
310 
311  XrdSecProtocol(const char *pName) : Entity(pName) {}
312 protected:
313 
314 //------------------------------------------------------------------------------
316 //------------------------------------------------------------------------------
317 
318 virtual ~XrdSecProtocol() {}
319 };
320 
321 /******************************************************************************/
322 /* 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 */
323 /******************************************************************************/
324 
338 //------------------------------------------------------------------------------
361 //------------------------------------------------------------------------------
362 
368 //------------------------------------------------------------------------------
397 //------------------------------------------------------------------------------
398 
413 /******************************************************************************/
414 /* P r o t o c o l O b j e c t M a n a g e m e n t */
415 /******************************************************************************/
416 
420 
421 /******************************************************************************/
422 /* X r d S e c G e t P r o t o c o l */
423 /* */
424 /* C l i e n t S i d e U S e O n l y */
425 /******************************************************************************/
426 
427 //------------------------------------------------------------------------------
459 //------------------------------------------------------------------------------
460 
461 //------------------------------------------------------------------------------
463 //------------------------------------------------------------------------------
464 
465 typedef XrdSecProtocol *(*XrdSecGetProt_t)(const char *,
466  XrdNetAddrInfo &,
468  XrdOucErrInfo *);
469 
483 /******************************************************************************/
484 /* X r d S e c G e t P r o t e c t i o n */
485 /* */
486 /* C l i e n t S i d e U s e O n l y */
487 /******************************************************************************/
488 
516 /******************************************************************************/
517 /* X r d S e c S e r v i c e */
518 /* */
519 /* S e r v e r S i d e U s e O n l y */
520 /******************************************************************************/
521 
536 {
537 public:
538 
539 //------------------------------------------------------------------------------
551 //------------------------------------------------------------------------------
552 
553 virtual const char *getParms(int &size, XrdNetAddrInfo *endPoint=0) = 0;
554 
555 //------------------------------------------------------------------------------
577 //------------------------------------------------------------------------------
578 
579 virtual XrdSecProtocol *getProtocol(const char *host, // In
580  XrdNetAddrInfo &endPoint,// In
581  const XrdSecCredentials *cred, // In
582  XrdOucErrInfo *einfo)=0;// Out
583 
584 //------------------------------------------------------------------------------
586 //------------------------------------------------------------------------------
587 
589 
590 //------------------------------------------------------------------------------
592 //------------------------------------------------------------------------------
593 
594 virtual ~XrdSecService() {}
595 };
596 
597 /******************************************************************************/
598 /* X r d g e t S e c S e r v i c e */
599 /******************************************************************************/
600 
601 //------------------------------------------------------------------------------
621 //------------------------------------------------------------------------------
622 
623 
624 //------------------------------------------------------------------------------
626 //------------------------------------------------------------------------------
627 
628 class XrdSysLogger;
629 typedef XrdSecService *(*XrdSecGetServ_t)(XrdSysLogger *, const char *);
630 
638 #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:535
Definition: XrdSecInterface.hh:130
virtual int Sign(const char *inbuff, int inlen, XrdSecBuffer **outbuff)
Definition: XrdSecInterface.hh:235
XrdSecService()
Constructor.
Definition: XrdSecInterface.hh:588
virtual XrdSecCredentials * getCredentials(XrdSecParameters *parm=0, XrdOucErrInfo *einfo=0)=0
virtual const char * getParms(int &size, XrdNetAddrInfo *endPoint=0)=0
Definition: XrdOucErrInfo.hh:97
XrdSecEntity Entity
Definition: XrdSecInterface.hh:139
XrdSecBuffer(char *bp=0, int sz=0)
Definition: XrdSecInterface.hh:55
virtual ~XrdSecProtocol()
Destructor (prevents use of direct delete).
Definition: XrdSecInterface.hh:318
virtual int getKey(char *buff=0, int size=0)
Definition: XrdSecInterface.hh:279
XrdSecProtocol(const char *pName)
Constructor.
Definition: XrdSecInterface.hh:311
Definition: XrdSysLogger.hh:52
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:594
~XrdSecBuffer()
Definition: XrdSecInterface.hh:56
virtual int Decrypt(const char *inbuff, int inlen, XrdSecBuffer **outbuff)
Definition: XrdSecInterface.hh:214
Definition: XrdSecEntity.hh:51
virtual int Verify(const char *inbuff, int inlen, const char *sigbuff, int siglen)
Definition: XrdSecInterface.hh:257
Generic structure to pass security information back and forth.
Definition: XrdSecInterface.hh:50
XrdSecBuffer XrdSecCredentials
Definition: XrdSecInterface.hh:69
virtual int Authenticate(XrdSecCredentials *cred, XrdSecParameters **parms, XrdOucErrInfo *einfo=0)=0
XrdSecBuffer XrdSecParameters
Definition: XrdSecInterface.hh:79
virtual XrdSecProtocol * getProtocol(const char *host, XrdNetAddrInfo &endPoint, const XrdSecCredentials *cred, XrdOucErrInfo *einfo)=0