Find Container

View this page for | |

Each time an end user triggers the registration process, a new container is provisioned containing cyptographic keys and policy information corresponding to a service. This implies that an integrating application might need to manage multiple containers from either the same or multiple servers.

The HID Approve SDK provides an API to list and filter all registered containers. Identifying the relevant container is generally the starting point for most operations.

Typical Use Case

The mobile application locates a container as follows:

  1. Create an instance of the HIDDevice (HIDDeviceFactory.newInstance).

  2. Define the filter parameter to search for a container (or, by default, list all):

    • CONTAINER_NAME – friendly name of container

    • CONTAINER_URL – server URL

    • CONTAINER_USERID – User identifier

  3. Get the instance of the HIDContainer (HIDDevice.findContainers).

Copy
do{
    
        // Get Device instance with default connection configuration
        let config = HIDConnectionConfiguration()
        let deviceFactory = HIDDeviceFactory.factory() as! HIDDeviceFactory
        let device = try deviceFactory.newInstance(config)

        // We assume that you have already provisioned one or several containers.
        // findContainers will provide you the full list of containers registered, sorted by the creation date
        let containers = try device.findContainers([])
        
        // Find the container you want
        for item in containers {
            if let c = item as? HIDContainer {
                NSLog("Found container: %@", c.getName());
            }
        }
        
        //Alternatively, you can search a container through a filter for example, the user id and the name
        let userId = HIDParameter(string: sUserId, forKey: HID_CONTAINER_USERID)
        let name = HIDParameter(string: sName, forKey: HID_CONTAINER_NAME)
        let filter:[Any]? = [userId!, name!]
        
        let filteredContainers = try device.findContainers(filter)

    }
    catch let error as NSError{
        NSLog("Failed to load containers: %@",error.localizedDescription);
    }
Copy
// Get Device instance with default connection configuration
    NSError* error;
    HIDConnectionConfiguration* connectionConfig = [[HIDConnectionConfiguration alloc] init];
    id<HIDDevice> pDevice = [[HIDDeviceFactory alloc] newInstance:connectionConfig error:&error];

    // We assume that you have already provisioned one or several containers.
    // findContainers will provide you the full list of containers registered, sorted by the creation date
    NSMutableArray* filter = [NSMutableArray array];
    NSArray<id<HIDContainer>>* containers = [pDevice findContainers:filter error:&error];
    
    // Find the container you want
    for (HIDContainer* c in containers) {
        NSLog(@"Found container: %@", [c getName]);
    }
    
    //Alternatively, you can search a container through a filter for example, the user id and the name
    [filter addObject:[HIDParameter parameterWithString:sUserId forKey:HID_CONTAINER_USERID]];
    [filter addObject:[HIDParameter parameterWithString:sName forKey:HID_CONTAINER_NAME]];
    NSArray<id<HIDContainer>>* filteredContainers = [pDevice findContainers:filter error:&error];