xrootd
Loading...
Searching...
No Matches
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
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
58private:
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/******************************************************************************/
128class XrdOucErrInfo;
129
131{
132public:
133
134//------------------------------------------------------------------------------
137//------------------------------------------------------------------------------
138
140
141//------------------------------------------------------------------------------
154//------------------------------------------------------------------------------
155
157 XrdSecParameters **parms,
158 XrdOucErrInfo *einfo=0)=0;
159
160//------------------------------------------------------------------------------
173//------------------------------------------------------------------------------
174
176 XrdOucErrInfo *einfo=0)=0;
177
178//------------------------------------------------------------------------------
191//------------------------------------------------------------------------------
192
193virtual 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
214virtual 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
235virtual 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
257virtual 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
279virtual int getKey(char *buff = 0, int size = 0)
280{
281 (void) buff; (void) size;
282 return -ENOTSUP;
283}
284
285//------------------------------------------------------------------------------
293//------------------------------------------------------------------------------
294
295virtual int setKey(char *buff, int size)
296{
297 (void) buff; (void) size;
298 return -ENOTSUP;
299}
300
301//------------------------------------------------------------------------------
303//------------------------------------------------------------------------------
304
305virtual bool needTLS() {return false;}
306
307//------------------------------------------------------------------------------
309//------------------------------------------------------------------------------
310
311virtual void Delete()=0; // Normally does "delete this"
312
313//------------------------------------------------------------------------------
315//------------------------------------------------------------------------------
316
317 XrdSecProtocol(const char *pName) : Entity(pName) {}
318protected:
319
320//------------------------------------------------------------------------------
322//------------------------------------------------------------------------------
323
324virtual ~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
386//------------------------------------------------------------------------------
415//------------------------------------------------------------------------------
416
431/******************************************************************************/
432/* P r o t o c o l O b j e c t M a n a g e m e n t */
433/******************************************************************************/
434
438
439/******************************************************************************/
440/* X r d S e c G e t P r o t o c o l */
441/* */
442/* C l i e n t S i d e U S e O n l y */
443/******************************************************************************/
444
445//------------------------------------------------------------------------------
477//------------------------------------------------------------------------------
478
479//------------------------------------------------------------------------------
481//------------------------------------------------------------------------------
482
483typedef XrdSecProtocol *(*XrdSecGetProt_t)(const char *hostname,
484 XrdNetAddrInfo &endPoint,
485 XrdSecParameters &sectoken,
486 XrdOucErrInfo *einfo);
487
501/******************************************************************************/
502/* X r d S e c G e t P r o t e c t i o n */
503/* */
504/* C l i e n t S i d e U s e O n l y */
505/******************************************************************************/
506
534/******************************************************************************/
535/* X r d S e c S e r v i c e */
536/* */
537/* S e r v e r S i d e U s e O n l y */
538/******************************************************************************/
539
554{
555public:
556
557//------------------------------------------------------------------------------
569//------------------------------------------------------------------------------
570
571virtual const char *getParms(int &size, XrdNetAddrInfo *endPoint=0) = 0;
572
573//------------------------------------------------------------------------------
592//------------------------------------------------------------------------------
593
594virtual XrdSecProtocol *getProtocol(const char *host, // In
595 XrdNetAddrInfo &endPoint,// In
596 const XrdSecCredentials *cred, // In
597 XrdOucErrInfo &einfo)=0;// Out
598
599//------------------------------------------------------------------------------
611//------------------------------------------------------------------------------
612
613virtual bool PostProcess(XrdSecEntity &entity,
614 XrdOucErrInfo &einfo) {return true;}
615
616//------------------------------------------------------------------------------
620//------------------------------------------------------------------------------
621
622virtual const char *protTLS()=0;
623
624//------------------------------------------------------------------------------
626//------------------------------------------------------------------------------
627
629
630//------------------------------------------------------------------------------
632//------------------------------------------------------------------------------
633
634virtual ~XrdSecService() {}
635};
636
637/******************************************************************************/
638/* X r d g e t S e c S e r v i c e */
639/******************************************************************************/
640
641//------------------------------------------------------------------------------
661//------------------------------------------------------------------------------
662
663
664//------------------------------------------------------------------------------
666//------------------------------------------------------------------------------
667
668class XrdSysLogger;
669typedef XrdSecService *(*XrdSecGetServ_t)(XrdSysLogger *, const char *);
670
678#endif
XrdSecBuffer XrdSecParameters
Definition XrdSecInterface.hh:79
XrdSecBuffer XrdSecCredentials
Definition XrdSecInterface.hh:69
Definition XrdNetAddrInfo.hh:54
Definition XrdOucErrInfo.hh:101
Definition XrdSecEntity.hh:65
Definition XrdSecInterface.hh:131
virtual XrdSecCredentials * getCredentials(XrdSecParameters *parm=0, XrdOucErrInfo *einfo=0)=0
XrdSecEntity Entity
Definition XrdSecInterface.hh:139
virtual int Verify(const char *inbuff, int inlen, const char *sigbuff, int siglen)
Definition XrdSecInterface.hh:257
virtual int setKey(char *buff, int size)
Definition XrdSecInterface.hh:295
virtual ~XrdSecProtocol()
Destructor (prevents use of direct delete).
Definition XrdSecInterface.hh:324
virtual int getKey(char *buff=0, int size=0)
Definition XrdSecInterface.hh:279
virtual int Sign(const char *inbuff, int inlen, XrdSecBuffer **outbuff)
Definition XrdSecInterface.hh:235
XrdSecProtocol(const char *pName)
Constructor.
Definition XrdSecInterface.hh:317
virtual void Delete()=0
Delete the protocol object. DO NOT use C++ delete() on this object.
virtual int Authenticate(XrdSecCredentials *cred, XrdSecParameters **parms, XrdOucErrInfo *einfo=0)=0
virtual int Decrypt(const char *inbuff, int inlen, XrdSecBuffer **outbuff)
Definition XrdSecInterface.hh:214
virtual bool needTLS()
Check if this protocol requires TLS to properly function.
Definition XrdSecInterface.hh:305
virtual int Encrypt(const char *inbuff, int inlen, XrdSecBuffer **outbuff)
Definition XrdSecInterface.hh:193
Definition XrdSecInterface.hh:554
virtual const char * protTLS()=0
virtual XrdSecProtocol * getProtocol(const char *host, XrdNetAddrInfo &endPoint, const XrdSecCredentials *cred, XrdOucErrInfo &einfo)=0
virtual bool PostProcess(XrdSecEntity &entity, XrdOucErrInfo &einfo)
Definition XrdSecInterface.hh:613
virtual ~XrdSecService()
Destructor.
Definition XrdSecInterface.hh:634
XrdSecService()
Constructor.
Definition XrdSecInterface.hh:628
virtual const char * getParms(int &size, XrdNetAddrInfo *endPoint=0)=0
Definition XrdSysLogger.hh:53
Generic structure to pass security information back and forth.
Definition XrdSecInterface.hh:51
char * membuf
Definition XrdSecInterface.hh:59
~XrdSecBuffer()
Definition XrdSecInterface.hh:56
char * buffer
Pointer to the buffer.
Definition XrdSecInterface.hh:53
int size
Size of the buffer or length of data in the buffer.
Definition XrdSecInterface.hh:52
XrdSecBuffer(char *bp=0, int sz=0)
Definition XrdSecInterface.hh:55