Exemplo n.º 1
0
 def uploadProxy(self, userGroup=False):
     issuerCert = self.getIssuerCert()
     userDN = issuerCert.getSubjectDN()['Value']
     if not userGroup:
         userGroup = self.__piParams.diracGroup
     gLogger.notice("Uploading proxy for %s..." % userGroup)
     if userGroup in self.__proxiesUploaded:
         gLogger.info("Proxy already uploaded")
         return S_OK()
     if userDN in self.__uploadedInfo:
         expiry = self.__uploadedInfo[userDN].get(userGroup)
         if expiry:
             if issuerCert.getNotAfterDate()['Value'] - datetime.timedelta(
                     minutes=10) < expiry:
                 gLogger.info(
                     "SKipping upload for group %s. Already uploaded" %
                     userGroup)
                 return S_OK()
     gLogger.info("Uploading %s proxy to ProxyManager..." %
                  self.__piParams.diracGroup)
     upParams = ProxyUpload.CLIParams()
     upParams.onTheFly = True
     upParams.proxyLifeTime = issuerCert.getRemainingSecs()['Value'] - 300
     upParams.rfcIfPossible = self.__piParams.rfc
     upParams.diracGroup = userGroup
     for k in ('certLoc', 'keyLoc', 'userPasswd'):
         setattr(upParams, k, getattr(self.__piParams, k))
     result = ProxyUpload.uploadProxy(upParams)
     if not result['OK']:
         gLogger.error(result['Message'])
         sys.exit(1)
     self.__uploadedInfo = result['Value']
     self.__proxiesUploaded.append(userGroup)
     gLogger.info("Proxy uploaded")
     return S_OK()
Exemplo n.º 2
0
    def uploadProxy(self):
        """ Upload the proxy to the proxyManager service
    """
        issuerCert = self.getIssuerCert()
        resultUserDN = issuerCert.getSubjectDN()  # pylint: disable=no-member
        if not resultUserDN['OK']:
            return resultUserDN
        userDN = resultUserDN['Value']

        gLogger.notice("Uploading proxy..")
        if userDN in self.__uploadedInfo:
            expiry = self.__uploadedInfo[userDN].get('')
            if expiry:
                if issuerCert.getNotAfterDate()['Value'] - datetime.timedelta(
                        minutes=10) < expiry:  # pylint: disable=no-member
                    gLogger.info('Proxy with DN "%s" already uploaded' %
                                 userDN)
                    return S_OK()
        gLogger.info("Uploading %s proxy to ProxyManager..." % userDN)
        upParams = ProxyUpload.CLIParams()
        upParams.onTheFly = True
        upParams.proxyLifeTime = issuerCert.getRemainingSecs()['Value'] - 300  # pylint: disable=no-member
        upParams.rfcIfPossible = self.__piParams.rfc
        for k in ('certLoc', 'keyLoc', 'userPasswd'):
            setattr(upParams, k, getattr(self.__piParams, k))
        resultProxyUpload = ProxyUpload.uploadProxy(upParams)
        if not resultProxyUpload['OK']:
            gLogger.error(resultProxyUpload['Message'])
            sys.exit(1)
        self.__uploadedInfo = resultProxyUpload['Value']
        gLogger.info("Proxy uploaded")
        return S_OK()
Exemplo n.º 3
0
    def uploadProxy(self):
        """Upload the proxy to the proxyManager service"""
        issuerCert = self.getIssuerCert()
        resultUserDN = issuerCert.getSubjectDN()  # pylint: disable=no-member
        if not resultUserDN["OK"]:
            return resultUserDN
        userDN = resultUserDN["Value"]

        gLogger.notice("Uploading proxy..")
        if userDN in self.__uploadedInfo:
            expiry = self.__uploadedInfo[userDN].get("")
            if expiry:
                if (
                    issuerCert.getNotAfterDate()["Value"] - datetime.timedelta(minutes=10) < expiry
                ):  # pylint: disable=no-member
                    gLogger.info('Proxy with DN "%s" already uploaded' % userDN)
                    return S_OK()
        gLogger.info("Uploading %s proxy to ProxyManager..." % userDN)
        upParams = ProxyUpload.CLIParams()
        upParams.onTheFly = True
        upParams.proxyLifeTime = issuerCert.getRemainingSecs()["Value"] - 300  # pylint: disable=no-member
        for k in ("certLoc", "keyLoc", "userPasswd"):
            setattr(upParams, k, getattr(self.__piParams, k))
        resultProxyUpload = ProxyUpload.uploadProxy(upParams)
        if not resultProxyUpload["OK"]:
            gLogger.error(resultProxyUpload["Message"])
            return resultProxyUpload
        self.__uploadedInfo = resultProxyUpload["Value"]
        gLogger.info("Proxy uploaded")
        return S_OK()
Exemplo n.º 4
0
      proxyChain = X509Chain()

      result = proxyChain.loadChainFromFile(keyDict["pub"])

      if not result[ 'OK' ]:
        self.finish({"error":"Could not load the proxy: %s" % result[ 'Message' ], "success": "false"})
        return

      result = proxyChain.getIssuerCert()

      if not result[ 'OK' ]:
        self.finish({"error":"Could not load the proxy: %s" % result[ 'Message' ], "success": "false"})
        return
      issuerCert = result['Value']

      upParams = ProxyUpload.CLIParams()

      upParams.onTheFly = True
      upParams.proxyLifeTime = issuerCert.getRemainingSecs()[ 'Value' ] - 300
      upParams.diracGroup = group
      upParams.certLoc = keyDict["pub"]
      upParams.keyLoc = keyDict["private"]
      upParams.userPasswd = pemPassword
      result = ProxyUpload.uploadProxy(upParams)

      if not result[ 'OK' ]:
        self.finish({"error":result[ 'Message' ], "success": "false"})
        return
    shutil.rmtree(storePath)

    groups = ", ".join(groupList)