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  ) {return -ENOTSUP;}
197 
198 //------------------------------------------------------------------------------
208 //------------------------------------------------------------------------------
209 
210 virtual int Decrypt(const char * /*inbuff*/, // Data to be decrypted
211  int /*inlen*/, // Length of data in inbuff
212  XrdSecBuffer ** /*outbuff*/ // Buffer for decrypted data
213  ) {return -ENOTSUP;}
214 
215 //------------------------------------------------------------------------------
225 //------------------------------------------------------------------------------
226 
227 virtual int Sign(const char * /*inbuff*/, // Data to be signed
228  int /*inlen*/, // Length of data in inbuff
229  XrdSecBuffer ** /*outbuff*/ // Buffer for the signature
230  ) {return -ENOTSUP;}
231 
232 //------------------------------------------------------------------------------
243 //------------------------------------------------------------------------------
244 
245 virtual int Verify(const char * /*inbuff*/, // Data to be decrypted
246  int /*inlen*/, // Length of data in inbuff
247  const char * /*sigbuff*/, // Buffer for signature
248  int /*siglen*/) // Length if signature
249  {return -ENOTSUP;}
250 
251 //------------------------------------------------------------------------------
262 //------------------------------------------------------------------------------
263 
264 virtual int getKey(char * /*buff*/=0, int /*size*/=0) {return -ENOTSUP;}
265 
266 //------------------------------------------------------------------------------
274 //------------------------------------------------------------------------------
275 
276 virtual int setKey(char * /*buff*/, int /*size*/) {return -ENOTSUP;}
277 
278 //------------------------------------------------------------------------------
280 //------------------------------------------------------------------------------
281 
282 virtual void Delete()=0; // Normally does "delete this"
283 
284 //------------------------------------------------------------------------------
286 //------------------------------------------------------------------------------
287 
288  XrdSecProtocol(const char *pName) : Entity(pName) {}
289 protected:
290 
291 //------------------------------------------------------------------------------
293 //------------------------------------------------------------------------------
294 
295 virtual ~XrdSecProtocol() {}
296 };
297 
298 /******************************************************************************/
299 /* 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 */
300 /******************************************************************************/
301 
315 //------------------------------------------------------------------------------
338 //------------------------------------------------------------------------------
339 
345 //------------------------------------------------------------------------------
374 //------------------------------------------------------------------------------
375 
388 /******************************************************************************/
389 /* P r o t o c o l O b j e c t M a n a g e m e n t */
390 /******************************************************************************/
391 
395 
396 /******************************************************************************/
397 /* X r d S e c G e t P r o t o c o l */
398 /* */
399 /* C l i e n t S i d e U S e O n l y */
400 /******************************************************************************/
401 
402 //------------------------------------------------------------------------------
434 //------------------------------------------------------------------------------
435 
436 //------------------------------------------------------------------------------
438 //------------------------------------------------------------------------------
439 
440 typedef XrdSecProtocol *(*XrdSecGetProt_t)(const char *,
441  XrdNetAddrInfo &,
443  XrdOucErrInfo *);
444 
456 /******************************************************************************/
457 /* X r d S e c S e r v i c e */
458 /* */
459 /* S e r v e r S i d e U s e O n l y */
460 /******************************************************************************/
461 
476 {
477 public:
478 
479 //------------------------------------------------------------------------------
491 //------------------------------------------------------------------------------
492 
493 virtual const char *getParms(int &size, XrdNetAddrInfo *endPoint=0) = 0;
494 
495 //------------------------------------------------------------------------------
517 //------------------------------------------------------------------------------
518 
519 virtual XrdSecProtocol *getProtocol(const char *host, // In
520  XrdNetAddrInfo &endPoint,// In
521  const XrdSecCredentials *cred, // In
522  XrdOucErrInfo *einfo)=0;// Out
523 
524 //------------------------------------------------------------------------------
526 //------------------------------------------------------------------------------
527 
529 
530 //------------------------------------------------------------------------------
532 //------------------------------------------------------------------------------
533 
534 virtual ~XrdSecService() {}
535 };
536 
537 /******************************************************************************/
538 /* X r d g e t S e c S e r v i c e */
539 /******************************************************************************/
540 
541 //------------------------------------------------------------------------------
561 //------------------------------------------------------------------------------
562 
563 
564 //------------------------------------------------------------------------------
566 //------------------------------------------------------------------------------
567 
568 class XrdSysLogger;
569 typedef XrdSecService *(*XrdSecGetServ_t)(XrdSysLogger *, const char *);
570 
577 #endif
char * membuf
Definition: XrdSecInterface.hh:59
virtual int setKey(char *, int)
Definition: XrdSecInterface.hh:276
int size
Size of the buffer or length of data in the buffer.
Definition: XrdSecInterface.hh:52
virtual int Sign(const char *, int, XrdSecBuffer **)
Definition: XrdSecInterface.hh:227
Definition: XrdSecInterface.hh:475
virtual int Encrypt(const char *, int, XrdSecBuffer **)
Definition: XrdSecInterface.hh:193
Definition: XrdSecInterface.hh:130
XrdSecService()
Constructor.
Definition: XrdSecInterface.hh:528
virtual XrdSecCredentials * getCredentials(XrdSecParameters *parm=0, XrdOucErrInfo *einfo=0)=0
virtual const char * getParms(int &size, XrdNetAddrInfo *endPoint=0)=0
Definition: XrdOucErrInfo.hh:97
virtual int Verify(const char *, int, const char *, int)
Definition: XrdSecInterface.hh:245
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:295
virtual int Decrypt(const char *, int, XrdSecBuffer **)
Definition: XrdSecInterface.hh:210
XrdSecProtocol(const char *pName)
Constructor.
Definition: XrdSecInterface.hh:288
Definition: XrdSysLogger.hh:50
virtual void Delete()=0
Delete the protocol object. DO NOT use C++ delete() on this object.
char * buffer
Pointer to the buffer.
Definition: XrdSecInterface.hh:53
virtual ~XrdSecService()
Destructor.
Definition: XrdSecInterface.hh:534
~XrdSecBuffer()
Definition: XrdSecInterface.hh:56
Definition: XrdSecEntity.hh:51
Generic structure to pass security information back and forth.
Definition: XrdSecInterface.hh:50
virtual int getKey(char *=0, int=0)
Definition: XrdSecInterface.hh:264
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