1 | """ |
---|
2 | Session Manager Authentication interface returning a user cert/private key - |
---|
3 | for use with Session Manager unittests |
---|
4 | |
---|
5 | NERC Data Grid Project |
---|
6 | """ |
---|
7 | __author__ = "P J Kershaw" |
---|
8 | __date__ = "29/10/08" |
---|
9 | __copyright__ = "(C) 2009 Science and Technology Facilities Council" |
---|
10 | __license__ = "BSD - see LICENSE file in top-level directory" |
---|
11 | __contact__ = "Philip.Kershaw@stfc.ac.uk" |
---|
12 | __revision__ = '$Id$' |
---|
13 | import logging |
---|
14 | log = logging.getLogger(__name__) |
---|
15 | |
---|
16 | from ndg.security.server.sessionmanager import SessionManager, \ |
---|
17 | AbstractAuthNService, AuthNServiceInvalidCredentials, AuthNServiceError |
---|
18 | from ndg.security.common.myproxy import MyProxyClient |
---|
19 | |
---|
20 | class UserX509CertAuthN(AbstractAuthNService): |
---|
21 | '''Test Authentication interface to the Session Manager |
---|
22 | returning a certificate and private key |
---|
23 | |
---|
24 | For use with SessionManager unittests only''' |
---|
25 | |
---|
26 | def __init__(self, **prop): |
---|
27 | '''Instantiate client object from X.509 cert and private key file path |
---|
28 | inputs. Private key must be none password protected.''' |
---|
29 | self.userX509Cert = open(prop['userX509CertFilePath']).read() |
---|
30 | self.userPriKey = open(prop['userPriKeyFilePath']).read() |
---|
31 | |
---|
32 | def logon(self, username, passphrase): |
---|
33 | '''Implementation of AbstractAuthNService logon for Session Manager |
---|
34 | unittests. TEST ONLY - no check is carried out on username/passphrase |
---|
35 | credentials |
---|
36 | |
---|
37 | @type username: basestring |
---|
38 | @param username: username for account login |
---|
39 | @type passphrase: basestring |
---|
40 | @param passphrase: passphrase (or password) for user account |
---|
41 | @rtype: tuple |
---|
42 | @return: user PKI credentials. |
---|
43 | ''' |
---|
44 | |
---|
45 | return self.userX509Cert, self.userPriKey |
---|