All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yoti.api.client.spi.remote.AttributeListReader Maven / Gradle / Ivy

The newest version!
package com.yoti.api.client.spi.remote;

import java.security.Key;
import java.util.ArrayList;
import java.util.List;

import com.yoti.api.client.Attribute;
import com.yoti.api.client.ProfileException;

public class AttributeListReader {

    private final EncryptedDataReader encryptedDataReader;
    private final AttributeListConverter attributeListConverter;

    private AttributeListReader(
            EncryptedDataReader encryptedDataReader,
            AttributeListConverter attributeListConverter) {
        this.encryptedDataReader = encryptedDataReader;
        this.attributeListConverter = attributeListConverter;
    }

    public static AttributeListReader newInstance() {
        return new AttributeListReader(
                EncryptedDataReader.newInstance(),
                AttributeListConverter.newInstance()
        );
    }

    public List> read(byte[] encryptedProfileBytes, Key secretKey) throws ProfileException {
        List> attributeList = new ArrayList<>();
        if (encryptedProfileBytes != null && encryptedProfileBytes.length > 0) {
            byte[] profileData = encryptedDataReader.decryptBytes(encryptedProfileBytes, secretKey);
            attributeList = attributeListConverter.parseAttributeList(profileData);
        }
        return attributeList;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy