示例#1
0
 def __init__(self, w, b):
     JDialog.__init__(self, w)
     self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
     self.panel = Panel()
     self.getContentPane().add(self.panel)
     t = Text()
     t.addFocusListener(FocusLostListener(self.lostfocus))
     self.panel + t
     view = ""
     for byte in b:
         view += Integer.toString((0xFF & byte), 2).zfill(8)
         view += ' '
     t.settext(view[:-1])
     self.pack()
     self.setVisible(1)
示例#2
0
    def __activate__(self, context):
        self.velocityContext = context
        self.log = self.vc("log")
        self.systemConfig = self.vc("systemConfig")
        self.session = self.vc("sessionState")
        self.response = self.vc("response")
        self.request = self.vc("request")
        self.msg = ""
        self.appId = None

        uri = URLDecoder.decode(self.request.getAttribute("RequestURI"))
        matches = re.match("^(.*?)/(.*?)/(.*?)/(.*?)/(.*?)$", uri)
        if matches and matches.group(5):
            self.appId = matches.group(5)

        if not self.appId:
            self.msg = "No appId specified"
            self.log.error(self.msg)
            return
        self.log.debug("Getting configuration for: " + self.appId)
        self.consumerName = self.systemConfig.getString(
            None, "authserver", self.appId, "name")
        self.sharedKey = self.systemConfig.getString(None, "authserver",
                                                     self.appId, "sharedKey")
        self.aud = self.systemConfig.getString(None, "authserver", self.appId,
                                               "aud")
        self.iss = self.systemConfig.getString(None, "authserver", self.appId,
                                               "iss")
        self.expiry = self.systemConfig.getInteger(None, "authserver",
                                                   self.appId, "expiry")
        self.logoutUrl = self.systemConfig.getString(None, "authserver",
                                                     self.appId, "logoutUrl")
        logout = self.request.getParameter("logout")
        if logout == "1":
            self.session.invalidate()
            self.response.sendRedirect(self.logoutUrl)
            return
        if not self.consumerName:
            self.msg = "Invalid configuration, no app name"
            self.log.error(self.msg)
            return
        if not self.sharedKey:
            self.msg = "Invalid shared Key"
            self.log.error(self.msg)
            return
        if not self.aud:
            self.msg = "Invalid aud"
            self.log.error(self.msg)
            return
        if not self.iss:
            self.msg = "Invalid iss"
            self.log.error(self.msg)
            return
        if not self.expiry:
            self.msg = "Invalid expiry"
            self.log.error(self.msg)
            return

        # Because we don't trust the configuration
        current_user = self.vc("page").authentication.get_username()
        isAdmin = self.vc("page").authentication.is_admin()
        # Admin only...
        if not isAdmin:
            self.msg = "Sorry, this page is only for administrators."
            self.log.error(self.msg)
            return
        # Get the roles...
        typ = "[\"" + "\",\"".join(
            self.vc("page").authentication.get_roles_list()) + "\"]"
        # Generating signature...
        dtNow = Date().getTime()
        now = dtNow / 1000
        iat = now
        nbf = now - 1
        exp = now + self.expiry
        secRandom = SecureRandom()
        jti = Long.toString(dtNow) + "_" + Integer.toString(
            secRandom.nextInt())
        payload = Payload(
            '{"iss":"%s",  "sub":"%s", "aud":"%s", "iat":"%s", "nbf":"%s", "exp":"%s", "jti":"%s", "typ":%s}'
            % (self.iss, current_user, self.aud, iat, nbf, exp, jti, typ))
        jwsHeader = JWSHeader(JWSAlgorithm.HS256)
        macSigner = MACSigner(self.sharedKey)
        jwsObject = JWSObject(jwsHeader, payload)
        jwsObject.sign(macSigner)
        self.jws = jwsObject.serialize()
示例#3
0
# rba_rc is the output parameter that stores the return code from ping command

rba_rc = "2"

if ipaddress is None:
  print "ipaddress cannot be found"
else:
  # format the start of the worklog entry
  incident = scriptHome.getString("TICKETID").strip()
  worklogDesc = "RBAPING script run for Incident: " + incident + "\n"
  worklogDesc = worklogDesc + "CI operated on: " + ipaddress + "\n"
  
  process = Runtime.getRuntime().exec("cmd.exe /C ping " + ipaddress)
  reader = BufferedReader(InputStreamReader(process.getInputStream()))
  while 1:
         lineRead = reader.readLine()
         if lineRead is None: break
         print lineRead
         worklogDesc = worklogDesc + lineRead

  rba_rc = Integer.toString(process.exitValue())

  try:
    # Record the output in a new worklog entry
    worklogSet = scriptHome.getMboSet("MODIFYWORKLOG")
    worklogMbo = worklogSet.add()
    worklogMbo.setValue("description", "RBAPING Results")
    worklogMbo.setValue("description_longdescription", worklogDesc)
  except:
    print "Error writing to results windows: ", sys.exc_info()
    rba_rc = "3"
 def __activate__(self, context):
     self.velocityContext = context
     self.log = self.vc("log")
     self.systemConfig = self.vc("systemConfig")
     self.session = self.vc("sessionState")
     self.response = self.vc("response")
     self.request = self.vc("request")
     self.msg = ""
     self.appId = None
     
     uri = URLDecoder.decode(self.request.getAttribute("RequestURI"))
     matches = re.match("^(.*?)/(.*?)/(.*?)/(.*?)/(.*?)$", uri)
     if matches and matches.group(5):    
         self.appId = matches.group(5)
         
     if not self.appId:
         self.msg = "No appId specified"
         self.log.error(self.msg)
         return
     self.log.debug("Getting configuration for: " + self.appId)
     self.consumerName = self.systemConfig.getString(None, "authserver", self.appId, "name")
     self.sharedKey = self.systemConfig.getString(None, "authserver", self.appId, "sharedKey")
     self.aud = self.systemConfig.getString(None, "authserver", self.appId, "aud")
     self.iss = self.systemConfig.getString(None, "authserver", self.appId, "iss")
     self.expiry = self.systemConfig.getInteger(None, "authserver", self.appId, "expiry")
     self.logoutUrl = self.systemConfig.getString(None, "authserver", self.appId, "logoutUrl")
     logout = self.request.getParameter("logout")
     if logout == "1":
         self.session.invalidate()
         self.response.sendRedirect(self.logoutUrl)
         return
     if not self.consumerName:
         self.msg = "Invalid configuration, no app name"
         self.log.error(self.msg)
         return
     if not self.sharedKey:
         self.msg = "Invalid shared Key"
         self.log.error(self.msg)
         return
     if not self.aud:
         self.msg = "Invalid aud"
         self.log.error(self.msg)
         return
     if not self.iss:
         self.msg = "Invalid iss"
         self.log.error(self.msg)
         return
     if not self.expiry:
         self.msg = "Invalid expiry"
         self.log.error(self.msg)
         return
                         
     # Because we don't trust the configuration
     current_user = self.vc("page").authentication.get_username()
     isAdmin = self.vc("page").authentication.is_admin()
     # Admin only... 
     if not isAdmin:
         self.msg = "Sorry, this page is only for administrators."
         self.log.error(self.msg)
         return
     # Get the roles...
     typ = "[\"" + "\",\"".join(self.vc("page").authentication.get_roles_list()) + "\"]"
     # Generating signature...
     dtNow = Date().getTime()
     now = dtNow / 1000
     iat = now
     nbf = now - 1
     exp = now + self.expiry
     secRandom = SecureRandom()
     jti = Long.toString(dtNow) + "_" + Integer.toString(secRandom.nextInt())
     payload = Payload('{"iss":"%s",  "sub":"%s", "aud":"%s", "iat":"%s", "nbf":"%s", "exp":"%s", "jti":"%s", "typ":%s}' % (self.iss, current_user, self.aud, iat, nbf, exp, jti, typ))
     jwsHeader = JWSHeader(JWSAlgorithm.HS256)
     macSigner = MACSigner(self.sharedKey)
     jwsObject = JWSObject(jwsHeader, payload)
     jwsObject.sign(macSigner)
     self.jws = jwsObject.serialize()
    msg = 'updating Web service'
    t.info(msg)
    wsg.updateWebService(wsObj.getPK(), username, password, wsdlURL)

# ------------------------------------------------------------------------------
# Now that the Web Service was added to the locally saved entity store,
# prepare to create a Deployment Package and associated package
# properties (name value pairs)
# Two things need to be associated with the Deployment Package:
# 1. The package properties file
# 2. The updated entitystore
# -----------------------------------------------------------------------------

# 1. Update the policy package properties with a new comment for adding a Web Service
policyProps = archive.getPolicyProperties()
policyProps[DeploymentArchive.VERSIONCOMMENT_DEFAULT_PROPERTY] = msg
archive.updatePolicyProperties(policyProps)
archive.updateConfiguration(esapi.es)

# 2. Update the entity store in the archive
#adminNM.updateArchiveConfiguration(archive, esapi.es)
res = adminNM.deployToServer(common.defGroupName, common.defServerName,
                             archive)

# Handle any deployment failures.
if res.getStatus() != True:
    t.error("Failed to deploy: " + res.getFailureReason())
    t.error("Failures: " + Integer.toString(res.getErrorCount()))

es.close()