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 <netdb.h>
35 #include <netinet/in.h>
36 #include <sys/param.h>
37 #endif
38 #include <stdlib.h>
39 #include <stdio.h>
40 #include <string.h>
41 #if defined(__CYGWIN__) || defined(__FreeBSD__)
42 #include <sys/socket.h>
43 #endif
44 
45 #include "XrdSec/XrdSecEntity.hh"
46 
47 /******************************************************************************/
48 /* 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 */
49 /******************************************************************************/
50 
51 //------------------------------------------------------------------------------
53 //------------------------------------------------------------------------------
54 
56 {
57  int size;
58  char *buffer;
59 
60  XrdSecBuffer(char *bp=0, int sz=0) : size(sz), buffer(bp), membuf(bp) {}
61  ~XrdSecBuffer() {if (membuf) free(membuf);}
62 
63 private:
64  char *membuf; // Stable copy of the buffer address
65 };
66 
67 //------------------------------------------------------------------------------
72 //------------------------------------------------------------------------------
73 
75 
76 //------------------------------------------------------------------------------
82 //------------------------------------------------------------------------------
83 
85 
86 /******************************************************************************/
87 /* X r d S e c P r o t o c o l */
88 /******************************************************************************/
133 class XrdOucErrInfo;
134 
136 {
137 public:
138 
139 //------------------------------------------------------------------------------
142 //------------------------------------------------------------------------------
143 
145 
146 //------------------------------------------------------------------------------
159 //------------------------------------------------------------------------------
160 
161 virtual int Authenticate (XrdSecCredentials *cred,
162  XrdSecParameters **parms,
163  XrdOucErrInfo *einfo=0)=0;
164 
165 //------------------------------------------------------------------------------
178 //------------------------------------------------------------------------------
179 
181  XrdOucErrInfo *einfo=0)=0;
182 
183 //------------------------------------------------------------------------------
196 //------------------------------------------------------------------------------
197 
198 virtual int Encrypt(const char * /*inbuff*/, // Data to be encrypted
199  int /*inlen*/, // Length of data in inbuff
200  XrdSecBuffer ** /*outbuff*/ // Returns encrypted data
201  ) {return -ENOTSUP;}
202 
203 //------------------------------------------------------------------------------
213 //------------------------------------------------------------------------------
214 
215 virtual int Decrypt(const char * /*inbuff*/, // Data to be decrypted
216  int /*inlen*/, // Length of data in inbuff
217  XrdSecBuffer ** /*outbuff*/ // Buffer for decrypted data
218  ) {return -ENOTSUP;}
219 
220 //------------------------------------------------------------------------------
230 //------------------------------------------------------------------------------
231 
232 virtual int Sign(const char * /*inbuff*/, // Data to be signed
233  int /*inlen*/, // Length of data in inbuff
234  XrdSecBuffer ** /*outbuff*/ // Buffer for the signature
235  ) {return -ENOTSUP;}
236 
237 //------------------------------------------------------------------------------
248 //------------------------------------------------------------------------------
249 
250 virtual int Verify(const char * /*inbuff*/, // Data to be decrypted
251  int /*inlen*/, // Length of data in inbuff
252  const char * /*sigbuff*/, // Buffer for signature
253  int /*siglen*/) // Length if signature
254  {return -ENOTSUP;}
255 
256 //------------------------------------------------------------------------------
267 //------------------------------------------------------------------------------
268 
269 virtual int getKey(char * /*buff*/=0, int /*size*/=0) {return -ENOTSUP;}
270 
271 //------------------------------------------------------------------------------
279 //------------------------------------------------------------------------------
280 
281 virtual int setKey(char * /*buff*/, int /*size*/) {return -ENOTSUP;}
282 
283 //------------------------------------------------------------------------------
285 //------------------------------------------------------------------------------
286 
287 virtual void Delete()=0; // Normally does "delete this"
288 
289 //------------------------------------------------------------------------------
291 //------------------------------------------------------------------------------
292 
293  XrdSecProtocol(const char *pName) : Entity(pName) {}
294 protected:
295 
296 //------------------------------------------------------------------------------
298 //------------------------------------------------------------------------------
299 
300 virtual ~XrdSecProtocol() {}
301 };
302 
303 /******************************************************************************/
304 /* 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 */
305 /******************************************************************************/
306 
320 //------------------------------------------------------------------------------
343 //------------------------------------------------------------------------------
344 
350 //------------------------------------------------------------------------------
377 //------------------------------------------------------------------------------
378 
391 /******************************************************************************/
392 /* P r o t o c o l O b j e c t M a n a g e m e n t */
393 /******************************************************************************/
394 
398 
399 /******************************************************************************/
400 /* X r d S e c G e t P r o t o c o l */
401 /* */
402 /* C l i e n t S i d e U S e O n l y */
403 /******************************************************************************/
404 
405 //------------------------------------------------------------------------------
437 //------------------------------------------------------------------------------
438 
450 /******************************************************************************/
451 /* X r d S e c S e r v i c e */
452 /* */
453 /* S e r v e r S i d e U s e O n l y */
454 /******************************************************************************/
455 
470 {
471 public:
472 
473 //------------------------------------------------------------------------------
485 //------------------------------------------------------------------------------
486 
487 virtual const char *getParms(int &size, const char *hname=0) = 0;
488 
489 //------------------------------------------------------------------------------
508 //------------------------------------------------------------------------------
509 
510 virtual XrdSecProtocol *getProtocol(const char *host, // In
511  const struct sockaddr &hadr, // In
512  const XrdSecCredentials *cred, // In
513  XrdOucErrInfo *einfo)=0;// Out
514 
515 //------------------------------------------------------------------------------
517 //------------------------------------------------------------------------------
518 
520 
521 //------------------------------------------------------------------------------
523 //------------------------------------------------------------------------------
524 
525 virtual ~XrdSecService() {}
526 };
527 
528 /******************************************************************************/
529 /* X r d g e t S e c S e r v i c e */
530 /******************************************************************************/
531 
532 //------------------------------------------------------------------------------
553 //------------------------------------------------------------------------------
554 
561 #endif
char * membuf
Definition: XrdSecInterface.hh:64
virtual int setKey(char *, int)
Definition: XrdSecInterface.hh:281
int size
Size of the buffer or length of data in the buffer.
Definition: XrdSecInterface.hh:57
virtual int Sign(const char *, int, XrdSecBuffer **)
Definition: XrdSecInterface.hh:232
Definition: XrdSecInterface.hh:469
virtual int Encrypt(const char *, int, XrdSecBuffer **)
Definition: XrdSecInterface.hh:198
Definition: XrdSecInterface.hh:135
XrdSecService()
Constructor.
Definition: XrdSecInterface.hh:519
virtual XrdSecCredentials * getCredentials(XrdSecParameters *parm=0, XrdOucErrInfo *einfo=0)=0
Definition: XrdOucErrInfo.hh:71
virtual const char * getParms(int &size, const char *hname=0)=0
virtual int Verify(const char *, int, const char *, int)
Definition: XrdSecInterface.hh:250
XrdSecEntity Entity
Definition: XrdSecInterface.hh:144
virtual XrdSecProtocol * getProtocol(const char *host, const struct sockaddr &hadr, const XrdSecCredentials *cred, XrdOucErrInfo *einfo)=0
XrdSecBuffer(char *bp=0, int sz=0)
Definition: XrdSecInterface.hh:60
virtual ~XrdSecProtocol()
Destructor (prevents use of direct delete).
Definition: XrdSecInterface.hh:300
virtual int Decrypt(const char *, int, XrdSecBuffer **)
Definition: XrdSecInterface.hh:215
XrdSecProtocol(const char *pName)
Constructor.
Definition: XrdSecInterface.hh:293
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:58
virtual ~XrdSecService()
Destructor.
Definition: XrdSecInterface.hh:525
~XrdSecBuffer()
Definition: XrdSecInterface.hh:61
Definition: XrdSecEntity.hh:50
Generic structure to pass security information back and forth.
Definition: XrdSecInterface.hh:55
virtual int getKey(char *=0, int=0)
Definition: XrdSecInterface.hh:269
XrdSecBuffer XrdSecCredentials
Definition: XrdSecInterface.hh:74
virtual int Authenticate(XrdSecCredentials *cred, XrdSecParameters **parms, XrdOucErrInfo *einfo=0)=0
XrdSecBuffer XrdSecParameters
Definition: XrdSecInterface.hh:84