1 Reply Latest reply on Jun 3, 2013 10:25 AM by Bill Robinson

    Jython Credential Acquiring

      I am looking for a solution to acquire BSA credentials from within Jython and haven't found a solution so far.

       

      The background around this question is a webservice on top of some Jython logic which serves forever and runs into Session Credential expired error after not using it for a certain period of time (the amount of time it needs for the credential to expire).

       

      Currently I tried using the subprocess module, which does not work though, because the blcred cred acquire command needs to be executed within the current shell rather than within a subshell in order to get valid session credentials acquired.

       

      Using the subprocess module this is what I get:

       

      subprocess.Popen("blcred cred -acquire -profile " + profile + " -username " + username + " -password " + password

      >> Authentication succeeded: acquired session credential

       

      jli = blcli.CLI()

      jli.setUserName(un)

      jli.setPassword(pw)

      jli.setRoleName(rn)

      jli.setAppServerHost(ah)

      jli.setServiceProfileName(sn)

      jli.connect()

      >> com.bladelogic.om.infra.session.client.SessionCredentialExpiredException: Your session credential has expired please login again.

       

      Any clever ideas?

       

      Thanks

        • 1. Re: Jython Credential Acquiring
          Bill Robinson

          so you shouldn't need to set username, password or appserverhost here.  just serviceprofile and the rolename.

           

          to pickup a new credential you need to destroy your existing connection w/ something like this:

          def disconnect(self):

                          from com.bladelogic.client import *

                          i = net.ClientConnectionPool.getInstance();

                          ii = net.ClientConnectionPool.getInstance().closeAllConnections();

                          BRProfile.setSessionCredential(None);

                          return net.ClientConnectionPool.getInstance().getConnectionCount();

           

          take a look here:

          Re: Using Jython Against 2 BL Environments