Ejemplo n.º 1
0
def main():
    ironboxDXRestObj = IronBoxDXRESTClient(
        apiKeyPublicID = apiKeyPublicID, 
        apiKeySecret = apiKeySecret, 
        showDebugInfo= False, 
        verbose= True)

    # Enable or disable the user's organization membership
    ironboxDXRestObj.management_setEntityOrganizationMembershipStatus(memberEmail=memberEmail, enabled=enabled)

    pass
def main():
    ironboxDXRestObj = IronBoxDXRESTClient(
        apiKeyPublicID = apiKeyPublicID, 
        apiKeySecret = apiKeySecret, 
        showDebugInfo= False, 
        verbose= True)

    # Create the organization entity
    ironboxDXRestObj.management_createOrganizationEntity(memberEmail=memberEmail, memberPassword=memberPassword, enabled=enabled)

    pass
def main():
    ironboxDXRestObj = IronBoxDXRESTClient(apiKeyPublicID=apiKeyPublicID,
                                           apiKeySecret=apiKeySecret,
                                           showDebugInfo=False,
                                           verbose=True)

    #--------------------------------------------------------------------------
    # Get a listing of the blobs in the server-side encrypted container
    # State values:
    #
    #   0 = waiting for upload
    #   1 = ready
    #--------------------------------------------------------------------------
    blobsInContainerJson = ironboxDXRestObj.listSSEContainerBlobs(
        containerPublicID=containerPublicID,
        skipPastNumItems=0,
        takeNumItems=500,
        state=1)
    print(
        "There are %i 'ready' blobs in the container with public ID = %s:\n" %
        (len(blobsInContainerJson["blobs"]),
         blobsInContainerJson["containerPublicID"]))
    for blob in blobsInContainerJson["blobs"]:
        print(json.dumps(blob, indent=4, sort_keys=True))

    #--------------------------------------------------------------------------
    # Download each blob into the destionation folder path
    #--------------------------------------------------------------------------
    for blob in blobsInContainerJson["blobs"]:
        destinationFilePath = os.path.join(destinationFolderPath,
                                           blob["blobName"])
        count = 1
        while path.exists(destinationFilePath):
            # Create a new file path and recheck if it exists until we find one that doesn't
            destinationFilePath = os.path.join(
                destinationFolderPath, "(%i)%s" % (count, blob["blobName"]))
            count += 1

        print("Downloading blob with publicID = %s and blobName = %s to %s" %
              (blob["blobPublicID"], blob["blobName"], destinationFilePath))
        ironboxDXRestObj.downloadSSEContainerBlobToPath(
            blobPublicID=blob["blobPublicID"],
            destinationFilePath=destinationFilePath)

        # Delete the blob from IronBox DX (optional)
        #ironboxDXRestObj.deleteSSEContainerBlob(blobPublicID = blob["blobPublicID"])
    pass
Ejemplo n.º 4
0
def main():
    ironboxDXRestObj = IronBoxDXRESTClient(apiKeyPublicID=apiKeyPublicID,
                                           apiKeySecret=apiKeySecret,
                                           showDebugInfo=False,
                                           verbose=True)

    # List the members of the security group
    groupInfo = ironboxDXRestObj.management_readBuiltInSecurityGroup(
        groupName=groupName)
    print(json.dumps(groupInfo, indent=4, sort_keys=True))

    # Add a user to the security group
    print("Starting add ...")
    addResult = ironboxDXRestObj.management_addMemberToBuiltInSecurityGroup(
        groupName=groupName, memberEmail=memberEmail)

    # List the members of the security group, new member should be added
    print("Group membership after add")
    groupInfo = ironboxDXRestObj.management_readBuiltInSecurityGroup(
        groupName=groupName)
    print(json.dumps(groupInfo, indent=4, sort_keys=True))

    # Remove the user from the security group
    print("Trying remove ...")
    removeResult = ironboxDXRestObj.management_removeMemberFromBuiltInSecurityGroup(
        groupName=groupName, memberEmail=memberEmail)

    # List the members of the security group, new member should be removed
    print("Group membership after remove")
    groupInfo = ironboxDXRestObj.management_readBuiltInSecurityGroup(
        groupName=groupName)
    print(json.dumps(groupInfo, indent=4, sort_keys=True))

    pass
Ejemplo n.º 5
0
def main():
    ironboxDXRestObj = IronBoxDXRESTClient(apiKeyPublicID=apiKeyPublicID,
                                           apiKeySecret=apiKeySecret,
                                           showDebugInfo=False,
                                           verbose=True)

    #--------------------------------------------------------------------------
    # Get a list of the storage endpoints that the user has access to
    #--------------------------------------------------------------------------
    listResponseJson = ironboxDXRestObj.listStorageEndpointsForUser()
    print("There are %i storage endpoints the current user has access to:" %
          len(listResponseJson["endpoints"]))
    for storageEndpoint in listResponseJson["endpoints"]:
        print(json.dumps(storageEndpoint, indent=4, sort_keys=True))

    #--------------------------------------------------------------------------
    # Create a SSE container on the selected storage endpoint
    #--------------------------------------------------------------------------
    createJsonResponse = ironboxDXRestObj.createSSEContainer(
        name="My Test Container",
        storageEndpointPublicID=listResponseJson["endpoints"][0]
        ["publicID"],  # Just select the first storage endpoint
        description="Description of your new container (optional)",
        anonymousAccessEnabled=False,
        anonymousAccessPassword=
        "******",
        humanReadableID=
        "A field you can use to set internally used IDs (optional)")
    print("The public ID of the container created is " +
          createJsonResponse["containerPublicID"])

    #--------------------------------------------------------------------------
    # Delete the container
    #--------------------------------------------------------------------------
    deleteJsonResponse = ironboxDXRestObj.deleteSSEContainer(
        containerPublicID=createJsonResponse["containerPublicID"])
    if (deleteJsonResponse != None):
        print("Delete container successful")
    else:
        print("Unable to delete container")

    pass
Ejemplo n.º 6
0
def main():
    ironboxDXRestObj = IronBoxDXRESTClient(apiKeyPublicID=apiKeyPublicID,
                                           apiKeySecret=apiKeySecret,
                                           showDebugInfo=False,
                                           verbose=True)

    # Get current settings
    print("Container link-based access settings are currently:")
    currentSettings = ironboxDXRestObj.management_readContainerLinkBasedAccessSettings(
        publicID=containerPublicID)
    print(json.dumps(currentSettings, indent=4, sort_keys=True))

    # Apply new settings
    print("Applying new link-based access settings")
    ironboxDXRestObj.management_setContainerLinkBasedAccessSettings(
        publicID=containerPublicID,
        enabled=enabled,
        canRead=canRead,
        canWrite=canWrite,
        accessPassword=accessPassword)

    # Get the new link-based access settings
    print("Container link-based access settings are now:")
    newSettings = ironboxDXRestObj.management_readContainerLinkBasedAccessSettings(
        publicID=containerPublicID)
    print(json.dumps(newSettings, indent=4, sort_keys=True))

    pass
def main():
    ironboxDXRestObj = IronBoxDXRESTClient(apiKeyPublicID=apiKeyPublicID,
                                           apiKeySecret=apiKeySecret,
                                           showDebugInfo=False,
                                           verbose=True)

    # Upload a server-side encrypted blob using a source path
    ironboxDXRestObj.uploadBlobToSSEContainerFromPath(
        containerPublicID=containerPublicID,
        blobName=filePathUploadBlobName,
        sourceFilePath=sourceFilePath)

    # Upload a server-side encrypted blob using text string as the source
    ironboxDXRestObj.uploadBlobToSSEContainerFromText(
        containerPublicID=containerPublicID,
        blobName=textUploadBlobName,
        sourceText=textUploadBody)
    pass
Ejemplo n.º 8
0
def main():
    ironboxDXRestObj = IronBoxDXRESTClient(apiKeyPublicID=apiKeyPublicID,
                                           apiKeySecret=apiKeySecret,
                                           showDebugInfo=False,
                                           verbose=True)

    #--------------------------------------------------------------------------
    #   Get a list of the current container notification lists and add to each
    #   list
    #--------------------------------------------------------------------------
    currentNotificationLists = ironboxDXRestObj.getContainerNotificationSettings(
        containerPublicID=containerPublicID)
    print("Current container notification lists:")
    print(json.dumps(currentNotificationLists, indent=4, sort_keys=True))

    # Add the notification emails to the existing lists
    currentNotificationLists["downloadNotificationList"].append(
        notificationEmailToAdd1)
    currentNotificationLists["uploadNotificationList"].append(
        notificationEmailToAdd2)
    ironboxDXRestObj.setContainerNotificationSettings(
        containerPublicID=containerPublicID,
        uploadNotificationList=currentNotificationLists[
            "uploadNotificationList"],
        downloadNotificationList=currentNotificationLists[
            "downloadNotificationList"])

    #currentNotificationLists = ironboxDXRestObj.getContainerNotificationSettings(containerPublicID)
    #print(json.dumps(currentNotificationLists, indent=4, sort_keys=True))

    #--------------------------------------------------------------------------
    #   Add a user to the container ACLs, if the email is not a registered
    #   user within the organization, it will be added to the external access
    #   lists for the container, otherwise registered access will be used.
    #
    #   If the user already exists in the ACLs, this will fail as a security
    #   precaution to preserve any existing ACLs. If you need to modify
    #   existing ACLs for a user, remove them first and re-add with new
    #   settings.
    #--------------------------------------------------------------------------
    addUserToACLResponse = ironboxDXRestObj.addUserToSSEContainerACLs(
        containerPublicID=containerPublicID,
        userEmail=userEmailToAdd,
        canRead=True,
        canWrite=True,
        # Note: This will always be False if the user is an external user, only registered users can have admin access on containers
        isAdmin=False,
        enabled=True,
        availableUtc="",
        expiresUtc="")
    print("Membership public ID of user {0} is {1}".format(
        userEmailToAdd, addUserToACLResponse["membershipRecordPublicID"]))

    #--------------------------------------------------------------------------
    #   Add a custom security group to the container ACLs
    #--------------------------------------------------------------------------
    addCustomSecurityGroupToACLResponse = ironboxDXRestObj.addCustomSecurityGroupToSSEContainerACLs(
        containerPublicID=containerPublicID,
        customSecurityGroupPublicID=customSecurityGroupPublicID,
        canRead=True,
        canWrite=True,
        isAdmin=False,
        enabled=True,
        availableUtc="",
        expiresUtc="")
    print("Membership public ID of custom security group {0} is {1}".format(
        customSecurityGroupPublicID,
        addCustomSecurityGroupToACLResponse["membershipRecordPublicID"]))

    #--------------------------------------------------------------------------
    #   Read the container current ACLs
    #--------------------------------------------------------------------------
    currentContainerACLs = ironboxDXRestObj.listSSEContainerACLs(
        containerPublicID=containerPublicID)
    print("Current container ACLs:")
    print(json.dumps(currentContainerACLs, indent=4, sort_keys=True))

    # Clean up and remove the user and custom security group ACLs added
    ironboxDXRestObj.deleteSSEContainerACL(
        containerPublicID=containerPublicID,
        membershipPublicID=addUserToACLResponse["membershipRecordPublicID"])
    ironboxDXRestObj.deleteSSEContainerACL(
        containerPublicID=containerPublicID,
        membershipPublicID=addCustomSecurityGroupToACLResponse[
            "membershipRecordPublicID"])