首页 > 解决方案 > 如何使用 IAIK 包装器 1.6.2 读取数据对象

问题描述

我的问题是我正在使用带有令牌的以下 IAIK 版本

现在我想使用最新版本:

最大的问题是我无法再读取数据对象,即使

 session.findObjectsInit(null);

对于旧版本,使用以下模板我可以获得数据对象:

 private static GenericTemplate getTokenObjectTemplate3(String label) {
        Preconditions.checkArgument(label != null);

        GenericTemplate template = new GenericTemplate();

        LongAttribute objectClassAttribute = new LongAttribute(PKCS11Constants.CKA_CLASS);
        objectClassAttribute.setLongValue(new Long(PKCS11Constants.CKO_DATA));
        template.addAttribute(objectClassAttribute);

        CharArrayAttribute labelAttribute = new CharArrayAttribute(PKCS11Constants.CKA_LABEL);
        labelAttribute.setCharArrayValue("oostatus".toCharArray());
        template.addAttribute(labelAttribute);

        BooleanAttribute tokenAttribute = new BooleanAttribute(PKCS11Constants.CKA_TOKEN);
        tokenAttribute.setBooleanValue(Boolean.TRUE);
        template.addAttribute(tokenAttribute);

        BooleanAttribute privateAttribute = new BooleanAttribute(PKCS11Constants.CKA_PRIVATE);
        privateAttribute.setBooleanValue(Boolean.FALSE);
        template.addAttribute(privateAttribute);

        CharArrayAttribute applicationAttribute = new CharArrayAttribute(PKCS11Constants.CKA_APPLICATION);
        applicationAttribute.setCharArrayValue(TOKEN_APPLICATION.toCharArray());
        template.addAttribute(applicationAttribute);

        return template;
    }

现在我正在使用以下内容但徒劳无功:

private static Data getTokenObjectTemplate4() {
        Data dataObjectTemplate = new Data();
        dataObjectTemplate.getLabel().setCharArrayValue(TOKEN_STATUS_LABEL.toCharArray());
        return dataObjectTemplate;
    }

请问运行代码有什么帮助或和平吗?

标签: pkcs#11safenet

解决方案


推荐阅读