class KeyConverter {

    public Key convert(KeyInfo keyInfo) {
        Key key = new Key();
        key.setId(keyInfo.getId());
        key.setName(keyInfo.getFriendlyName());
        key.setLabel(keyInfo.getLabel());
        if (keyInfo.getUsage() != null) {
            if (keyInfo.isForSigning()) {
                key.setUsage(KeyUsageType.SIGNING);
            } else {
                key.setUsage(KeyUsageType.AUTHENTICATION);
            }
        }

        key.setAvailable(keyInfo.isAvailable());
        key.setSavedToConfiguration(isSavedToConfiguration(keyInfo));

        key.setCertificates(tokenCertificateConverter.convert(keyInfo.getCerts()));
        key.setCertificateSigningRequests(tokenCsrConverter.convert(keyInfo.getCertRequests()));

        return key;
    }

    @Autowired public  KeyConverter(TokenCertificateConverter tokenCertificateConverter,
            TokenCertificateSigningRequestConverter tokenCsrConverter);

}