JDK 7u79中javax.smartcardio.Card.disconnect(boolean reset)的行为?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了JDK 7u79中javax.smartcardio.Card.disconnect(boolean reset)的行为?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3213字,纯文字阅读大概需要5分钟。
内容图文
![JDK 7u79中javax.smartcardio.Card.disconnect(boolean reset)的行为?](/upload/InfoBanner/zyjiaocheng/767/3d55002c683d4f3ebf84a3c6d8393bea.jpg)
Change in javax.smartcardio.Card.disconnect(boolean reset) method
behaviorPrior to the JDK 8u20 and JDK 7u72 releases, the
javax.smartcardio.Card.disconnect(boolean reset) method had inverted
logic for the ‘reset’ boolean value passed to it. The card was reset
upon a disconnect if false was passed to it and vice versa. Starting
with JDK 7u72 and JDK 8u20, the correct behavior as per API
documentation has been implemented.In order to provide backwards compatibility to users who rely on the
old behavior, a new system property has been introduced. The following
command-line option can be used to enforce the old broken behavior:-Dsun.security.smartcardio.invertCardReset=true
This property is set by default for 7u72 and later JDK 7 update
releases. By default, no behavioral change will be noticed in this
area for JDK 7 update releases.Also the following command-line option can be used to enforce the new
correct behavior:-Dsun.security.smartcardio.invertCardReset=false
This is default for 8u20 and later JDK 8 update releases. In future
Java releases, the property will be ignored/disabled and default
disconnect method behavior will be as specified by API.
当调用javax.smartcardio.Card.disconnect(true)时,即使我有JDK 7u79,卡也不会重置.当我传递false或使用选项-Dsun.security.smartcardio.invertCardReset = true到VM时,一切正常.怎么会这样? JDK 7u79附带了旧版本的JRE吗?
解决方法:
在我看来,JRE表现得像预期的那样.
拥有版本>的Java 7 JRE; 7u72,你必须调用disconnect(false)来重置(默认情况下.你可能会被系统属性覆盖).原因在于,您必须调用断开连接(false)以实际断开连接的错误已经很老了,所以很多软件都采用并调用disconnect(false)来重置.如果Oracle在一些次要的发布/错误修复中改变了这种行为,他们就会为所有软件项目创建一个安全漏洞,他们通过调用disconnect(false)修复了代码中的这个JRE / JDK错误.为此原因:
By default, no behavioral change will be noticed in this area for JDK 7 update releases.
(这是您从文档中引用的内容的一部分)
如果你有一些Java 8 JRE,你必须默认调用disconnect(true),可能被系统属性覆盖.
所以,如果你现在想要创建一些代码,确保你的卡将被重置,这适用于java 7和8(甚至更老和更新版本),你必须评估,你必须提交什么,即:
final static boolean TRUE;
static{
String ven = System.getProperty("java.vendor");
String ver = System.getProperty("java.runtime.version");
String r = System.getProperty("sun.security.smartcardio.invertCardReset");
TRUE=!invertReset(ven, ver, r);
}
static boolean invertReset(String vendor, String version, String reset){
if("Oracle Corporation".equals(vendor)){
String[] javaVersionElements = version.split("\\.|_|-b");
//String discard = javaVersionElements[0];
int major = Integer.parseInt(javaVersionElements[1]);
//String minor = javaVersionElements[2];
int update = Integer.parseInt(javaVersionElements[3]);
//String build = javaVersionElements[4];
// version to small for existing reset property:
if((major == 7 && update<72) || major < 7){
return true;
}
if(null != reset){
// version recent enough and we have property:
return "true".equals(reset);
}else{
// version recent enough, but no property:
return major<8;
}
}
return false;
}
现在,你可以拨打card.disconnect(TRUE);如果需要,则TRUE应为false.使用前请仔细测试.我没有.
请注意,我从SO文章Getting Java version at runtime中获取了版本检测/拆分代码
内容总结
以上是互联网集市为您收集整理的JDK 7u79中javax.smartcardio.Card.disconnect(boolean reset)的行为?全部内容,希望文章能够帮你解决JDK 7u79中javax.smartcardio.Card.disconnect(boolean reset)的行为?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。