xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdSecsss
XrdSecsssID.hh
Go to the documentation of this file.
1
#ifndef __SecsssID__
2
#define __SecsssID__
3
/******************************************************************************/
4
/* */
5
/* X r d S e c s s s I D . h h */
6
/* */
7
/* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* All Rights Reserved */
9
/* Produced by Andrew Hanushevsky for Stanford University under contract */
10
/* DE-AC02-76-SFO0515 with the Department of Energy */
11
/******************************************************************************/
12
13
// $Id$
14
15
#include <string.h>
16
#include <time.h>
17
18
#include "
XrdOuc/XrdOucHash.hh
"
19
#include "
XrdSec/XrdSecEntity.hh
"
20
#include "
XrdSys/XrdSysPthread.hh
"
21
22
// The XrdSecsssID class allows you to establish a registery to map loginid's
23
// to arbitrary entities. By default, the sss security protocol uses the
24
// username as the authenticated username and, if possible, the corresponding
25
// primary group membership of username (i.e., static mapping). The server is
26
// will ignore the username and/or the groupname unless the key is designated
27
// as anyuser, anygroup, respectively. By creating an instance of this class
28
// you can over-ride the default and map the loginid (i.e., the id supplied
29
// at login time which is normally the first 8-characters of the username or
30
// the id specified in the url; i.e., id@host) to arbitrary entities using
31
// the Register() method. You must create one, and only one, such instance
32
// prior to making any contact with a sss security enabled server.
33
34
// In order to include XrdSecsssID methods, you should either link with
35
// libXrdSecsss.so (preferable) or include XrdSecsssID.o and link with
36
// libXrdOuc.a and libXrdSys.a.
37
38
class
XrdSecsssID
39
{
40
public
:
41
42
// Register() creates a mapping from a loginid to an entity description. Only
43
// name, vo, role, group, and endorements pointers in XrdSecEntity
44
// are supported. To de-register a loginid, make the Ident arg zero.
45
// To replace an existing entry, specify 1 for doReplace argument.
46
// TRUE is returned if successful; FALSE otherwise (including the
47
// case where idDynamic was not specified in the constructor or
48
// doReplace is zero and the loginid has already been registered).
49
//
50
int
Register
(
const
char
*loginid,
XrdSecEntity
*Ident,
int
doReplace=0);
51
52
// Find() is an internal look-up method that returns the identification
53
// string in the provided buffer corresponding to the loginid.
54
// If loginid is registered and the data will fit into the buffer the
55
// length moved into the buffer is returned. Otherwise, the default ID
56
// is moved into the buffer and the length copied is returned. If that
57
// is not possible, 0 is returned.
58
//
59
int
Find
(
const
char
*loginid,
char
*Buff,
int
Blen);
60
61
// A single instance of this class may be instantiated. The first parameter
62
// indicates how authentication is to be handled. The second parameter provides
63
// either a fixed or default authenticated identity under control of the aType
64
// parameter, as follows:
65
//
66
enum
authType
{
idDynamic
= 0,
// Mutual: Map loginid to registered identity
67
// Ident is default; if 0 nobody/nogroup
68
idStatic
= 1,
// 1Sided: fixed identity sent to the server
69
// Ident as specified; if 0 process uid/gid
70
// Default if XrdSecsssID not instantiated!
71
idStaticM
= 2
// Mutual: fixed identity sent to the server
72
// Ident as specified; if 0 process uid/gid
73
};
74
75
// getObj() returns the address of a previous created instance of this object or
76
// zero if no instance exists. It also returns authType and default ID
77
// to be used regardless of the return value.
78
//
79
static
80
XrdSecsssID
*
getObj
(
authType
&aType,
char
**dID,
int
&dIDsz);
81
82
XrdSecsssID
(
authType
aType=
idStatic
,
XrdSecEntity
*Ident=0);
83
84
~XrdSecsssID
() {
if
(
defaultID
) free(
defaultID
);}
85
86
private
:
87
88
struct
sssID
{
int
iLen
;
char
iData
[1];};
// Sized appropriately
89
static
sssID
*
genID
(
int
Secure);
90
static
sssID
*
genID
(
XrdSecEntity
*eP);
91
92
static
XrdSysMutex
InitMutex
;
93
sssID
*
defaultID
;
94
XrdSysMutex
myMutex
;
95
XrdOucHash<sssID>
Registry
;
96
authType
myAuth
;
97
};
98
#endif
Generated by
1.8.1.2