Exemple #1
0
 def wrapped_func(*args, **kwargs):
     logger = logging.getLogger("CRABLogger.Utils")
     myproxyserver = "myproxy.cern.ch"
     userdn = kwargs['userdn']
     defaultDelegation = {
         'logger': logger,
         'proxyValidity': '192:00',
         'min_time_left': 36000,
         'server_key': serverKey,
         'server_cert': serverCert,
     }
     timeleftthreshold = 60 * 60 * 24
     mypclient = SimpleMyProxy(defaultDelegation)
     userproxy = None
     try:
         userproxy = mypclient.logonRenewMyProxy(
             username=sha1(kwargs['userdn']).hexdigest(),
             myproxyserver=myproxyserver,
             myproxyport=7512)
     except MyProxyException, me:
         import cherrypy
         cherrypy.log(str(me))
         cherrypy.log(str(serverKey))
         cherrypy.log(str(serverCert))
         invalidp = InvalidParameter(
             "Impossible to retrieve proxy from %s for %s." %
             (myproxyserver, kwargs['userdn']))
         setattr(invalidp, 'trace', str(me))
         raise invalidp
Exemple #2
0
    def wrapped_func(*args, **kwargs):
        logger = logging.getLogger("CRABLogger.Utils")
        myproxyserver = "myproxy.cern.ch"
        userdn = kwargs['userdn']
        defaultDelegation = {'logger': logger,
                             'proxyValidity' : '192:00',
                             'min_time_left' : 36000,
                             'server_key': serverKey,
                             'server_cert': serverCert,}
        timeleftthreshold = 60 * 60 * 24
        mypclient = SimpleMyProxy(defaultDelegation)
        userproxy = None
        userhash  = sha1(kwargs['userdn']).hexdigest()
        if serverDN:
            try:
                userproxy = mypclient.logonRenewMyProxy(username=userhash, myproxyserver=myproxyserver, myproxyport=7512)
            except MyProxyException, me:
                # Unsure if this works in standalone mode...
                cherrypy.log(str(me))
                cherrypy.log(str(serverKey))
                cherrypy.log(str(serverCert))
                invalidp = InvalidParameter("Impossible to retrieve proxy from %s for %s and hash %s" %
                                                (myproxyserver, kwargs['userdn'], userhash))
                setattr(invalidp, 'trace', str(me))
                raise invalidp

            else:
                if not re.match(RX_CERT, userproxy):
                    raise InvalidParameter("Retrieved malformed proxy from %s for %s and hash %s" %
                                                (myproxyserver, kwargs['userdn'], userhash))
Exemple #3
0
    def wrapped_func(*args, **kwargs):
        logger = logging.getLogger("CRABLogger.Utils")
        myproxyserver = "myproxy.cern.ch"
        userdn = kwargs['userdn']
        defaultDelegation = {'logger': logger,
                             'proxyValidity' : '192:00',
                             'min_time_left' : 36000,
                             'server_key': serverKey,
                             'server_cert': serverCert,}
        timeleftthreshold = 60 * 60 * 24
        mypclient = SimpleMyProxy(defaultDelegation)
        userproxy = None
        userhash  = sha1(kwargs['userdn']).hexdigest()
        if serverDN:
            try:
                userproxy = mypclient.logonRenewMyProxy(username=userhash, myproxyserver=myproxyserver, myproxyport=7512)
            except MyProxyException, me:
                # Unsure if this works in standalone mode...
                cherrypy.log(str(me))
                cherrypy.log(str(serverKey))
                cherrypy.log(str(serverCert))
                invalidp = InvalidParameter("Impossible to retrieve proxy from %s for %s and hash %s" %
                                                (myproxyserver, kwargs['userdn'], userhash))
                setattr(invalidp, 'trace', str(me))
                raise invalidp

            else:
                if not re.match(RX_CERT, userproxy):
                    raise InvalidParameter("Retrieved malformed proxy from %s for %s and hash %s" %
                                                (myproxyserver, kwargs['userdn'], userhash))
Exemple #4
0
 def setUp(self):
     """
     Setup for unit tests
     """
     logging.basicConfig(
         level=logging.DEBUG,
         format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
         datefmt='%m-%d %H:%M',
         filename='proxy_unittests.log',
         filemode='w')
     logger_name = 'SimpleMyProxyTest'
     self.logger = logging.getLogger(logger_name)
     self.simplemyproxy = SimpleMyProxy({'logger': self.logger})
Exemple #5
0
class SimpleMyProxyTest(unittest.TestCase):
    def setUp(self):
        """
        Setup for unit tests
        """
        logging.basicConfig(
            level=logging.DEBUG,
            format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
            datefmt='%m-%d %H:%M',
            filename='proxy_unittests.log',
            filemode='w')
        logger_name = 'SimpleMyProxyTest'
        self.logger = logging.getLogger(logger_name)
        self.simplemyproxy = SimpleMyProxy({'logger': self.logger})

    def tearDown(self):
        """
        _tearDown_
        """
        return

    @attr("integration")
    def testgetMyProxyInfo(self):
        """
        Test if it's possible to get myproxy information
        """
        myproxyinfo = self.simplemyproxy.checkMyProxy(
            username=USERNAME,
            myproxyserver=MYPROXYSERVER,
            myproxyport=MYPROXYPORT,
            keyfile=USERKEY,
            certfile=USERCERT)
        assert 'retriever' in myproxyinfo
        assert 'owner' in myproxyinfo
        assert 'start' in myproxyinfo
        assert 'end' in myproxyinfo
        assert myproxyinfo['end'] > myproxyinfo['start']

    @attr("integration")
    def testgetMyProxy(self):
        """
        Test if it is possible to retrieve a proxy from an existing myproxy
        """
        myproxy = self.simplemyproxy.logonRenewMyProxy(
            username=USERNAME,
            myproxyserver=MYPROXYSERVER,
            myproxyport=MYPROXYPORT,
            keyfile=SERVERKEY,
            certfile=SERVERCERT,
            lifetime=43200)
        self.assertTrue(REGCERT.match(myproxy))
Exemple #6
0
 def wrapped_func(*args, **kwargs):
     logger = logging.getLogger("CRABLogger.Utils")
     myproxyserver = "myproxy.cern.ch"
     userdn = kwargs['userdn']
     defaultDelegation = {'logger': logger,
                          'proxyValidity' : '192:00',
                          'min_time_left' : 36000,
                          'server_key': serverKey,
                          'server_cert': serverCert,}
     timeleftthreshold = 60 * 60 * 24
     mypclient = SimpleMyProxy(defaultDelegation)
     userproxy = None
     try:
         userproxy = mypclient.logonRenewMyProxy(username=sha1(serverDN+kwargs['userdn']).hexdigest(), myproxyserver=myproxyserver, myproxyport=7512)
     except MyProxyException, me:
         raise InvalidParameter("Impossible to retrieve proxy from %s for %s." %(myproxyserver, kwargs['userdn']))
class SimpleMyProxyTest(unittest.TestCase):

    def setUp(self):
        """
        Setup for unit tests
        """
        logging.basicConfig(level=logging.DEBUG,
                            format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                            datefmt='%m-%d %H:%M',
                            filename='proxy_unittests.log',
                            filemode='w')
        logger_name = 'SimpleMyProxyTest'
        self.logger = logging.getLogger(logger_name)
        self.simplemyproxy = SimpleMyProxy({'logger': self.logger})

    def tearDown(self):
        """
        _tearDown_
        """
        return

    @attr("integration")
    def testgetMyProxyInfo(self):
        """
        Test if it's possible to get myproxy information
        """
        myproxyinfo = self.simplemyproxy.checkMyProxy(username=USERNAME, myproxyserver=MYPROXYSERVER, myproxyport=MYPROXYPORT,
                                                      keyfile=USERKEY, certfile=USERCERT)
        assert 'retriever' in myproxyinfo
        assert 'owner' in myproxyinfo
        assert 'start' in myproxyinfo
        assert 'end' in myproxyinfo
        assert myproxyinfo['end'] > myproxyinfo['start']

    @attr("integration")
    def testgetMyProxy(self):
        """
        Test if it is possible to retrieve a proxy from an existing myproxy
        """
        myproxy = self.simplemyproxy.logonRenewMyProxy(username=USERNAME, myproxyserver=MYPROXYSERVER, myproxyport=MYPROXYPORT,
                                                       keyfile=SERVERKEY, certfile=SERVERCERT, lifetime=43200)
        self.assertTrue(REGCERT.match(myproxy))
 def setUp(self):
     """
     Setup for unit tests
     """
     logging.basicConfig(level=logging.DEBUG,
                         format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                         datefmt='%m-%d %H:%M',
                         filename='proxy_unittests.log',
                         filemode='w')
     logger_name = 'SimpleMyProxyTest'
     self.logger = logging.getLogger(logger_name)
     self.simplemyproxy = SimpleMyProxy({'logger': self.logger})
from __future__ import print_function
import logging, sys
from hashlib import sha1
from WMCore.Credential.SimpleMyProxy import SimpleMyProxy

if len(sys.argv) is not 5:
    print("Usage example: ")
    print(
        'python logon_openssl.py "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=mcinquil/CN=660800/CN=Mattia Cinquilli" /data/certs/hostkey.pem /data/certs/hostcert.pem "/DC=ch/DC=cern/OU=computers/CN=mattia-dev01.cern.ch"'
    )
    sys.exit(1)

logger = logging.getLogger("OpenSSL MyProxy test")
myproxyserver = "myproxy.cern.ch"
userdn = sys.argv[1]
defaultDelegation = {
    'logger': logger,
    'proxyValidity': '192:00',
    'min_time_left': 36000,
    'server_key': sys.argv[2],
    'server_cert': sys.argv[3],
}
timeleftthreshold = 60 * 60 * 24
mypclient = SimpleMyProxy(defaultDelegation)
userproxy = mypclient.logonRenewMyProxy(username=sha1(sys.argv[4] +
                                                      userdn).hexdigest(),
                                        myproxyserver=myproxyserver,
                                        myproxyport=7512)
print("Proxy Retrieved with len ", len(userproxy))
from __future__ import print_function
import logging, sys
from hashlib import sha1
from WMCore.Credential.SimpleMyProxy import SimpleMyProxy

if len(sys.argv) is not 5:
    print ("Usage example: ")
    print ('python logon_openssl.py "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=mcinquil/CN=660800/CN=Mattia Cinquilli" /data/certs/hostkey.pem /data/certs/hostcert.pem "/DC=ch/DC=cern/OU=computers/CN=mattia-dev01.cern.ch"')
    sys.exit(1)

logger = logging.getLogger("OpenSSL MyProxy test")
myproxyserver = "myproxy.cern.ch"
userdn = sys.argv[1]
defaultDelegation = {'logger': logger,
                     'proxyValidity' : '192:00',
                     'min_time_left' : 36000,
                     'server_key': sys.argv[2],
                     'server_cert': sys.argv[3],}
timeleftthreshold = 60 * 60 * 24
mypclient = SimpleMyProxy(defaultDelegation)
userproxy = mypclient.logonRenewMyProxy(username=sha1(sys.argv[4]+userdn).hexdigest(), myproxyserver=myproxyserver, myproxyport=7512)
print ("Proxy Retrieved with len ", len(userproxy))