Example #1
0
def getDpsk(nbi_password, nbi_url, client_mac, wlan):

    # Create XML string to retrieve the newly created DPSK for the user
    xml_request = xmlcommon.createXmlFetchDpsk(nbi_password, client_mac, wlan)

    # Send the request to the ZD and capture response. The response is in XML format
    xml_response = xmlcommon.sendXmlString(xml_request, nbi_url)

    # Check response
    success = False
    if not xml_response:
        print "Content-type: text/html \n\n"
        print "Retrieve DPSK failed: No response from ZoneDirector"
    else:
        response_code = xmlcommon.checkXmlResponse(xml_response)
        # Lookup the code returned to see if it indicates successful authentication
        success = xmlcommon.statusCodeLookup(response_code, "dpsk")

    if not success:
        return False

    passphrase = xmlcommon.getXmlAttribute(xml_response, "dpsk", "passphrase")
    expiration = xmlcommon.getXmlAttribute(xml_response, "dpsk", "expiration")

    return passphrase, expiration
def authenticateUser(nbi_password,nbi_url,client_ip,client_mac,username,password):

  # Create the XML authentication request 
  xml_request = xmlcommon.createXmlAuthReq(nbi_password,client_ip,client_mac,username,password)

  # Send the XML authentication request to the ZD and capture response. The response is in XML format
  xml_response =  xmlcommon.sendXmlString(xml_request,nbi_url)

  # Check response
  success = ''
  if not xml_response:
   	print "Content-type: text/html \n\n"
        print "Authentication request failed: No response from ZoneDirector."
	return 
  else:
        response_code = xmlcommon.checkXmlResponse(xml_response)
        # Lookup the code returned to see if it indicates successful authentication
        success = xmlcommon.statusCodeLookup(response_code, "auth")

  return success
Example #3
0
def createDpsk(
    nbi_password, nbi_url, client_ip, client_mac, username, password, expiration, key_length, wlan, vlan, restricted
):

    # Create XML string to generate a DPSK for the user
    xml_request = xmlcommon.createXmlDpskReq(
        nbi_password, client_ip, client_mac, username, password, expiration, key_length, wlan, vlan, restricted
    )

    # Send the request to the ZD and capture response. The response is in XML format
    xml_response = xmlcommon.sendXmlString(xml_request, nbi_url)

    # Check response
    success = False
    if not xml_response:
        print "Content-type: text/html \n\n"
        print "DPSK generation failed: No response from ZoneDirector"
    else:
        response_code = xmlcommon.checkXmlResponse(xml_response)
        # Lookup the code returned to see if it indicates successful authentication
        success = xmlcommon.statusCodeLookup(response_code, "dpsk")

    return success