当前位置: 首页 > news >正文

网站建设百度文库友情链接方面pr的选择应该优先选择的链接为

网站建设百度文库,友情链接方面pr的选择应该优先选择的链接为,湖北定制型网站建设,临汾网站开发文章目录 前言一、定义接口二、server端实现三、client端实现四、遇到的问题 前言 在进行开发时,可能会将业务放到不同的applet中,这时常常会需要进行数据的分享。 比如在一个applet中存储了密钥,而在另一个业务applet中需要进行签名时&…

文章目录

  • 前言
  • 一、定义接口
  • 二、server端实现
  • 三、client端实现
  • 四、遇到的问题


前言

在进行开发时,可能会将业务放到不同的applet中,这时常常会需要进行数据的分享。
比如在一个applet中存储了密钥,而在另一个业务applet中需要进行签名时,需要将数据传给第一个applet进行签名后,再返回签名后的数据。
这里介绍Java Card中的Shareable的数据分享的方式。

一、定义接口

import javacard.framework.Shareable;public interface DataShareable extends Shareable {public byte getDataInfo(byte[] buffer, short offset, short length);
}

需要继承Java Card的Shareable 类,定义好我们需要的接口,这里定义了getDataInfo方法,用于将数据写到buffer中以提供给client。

二、server端实现

public class DataInfoApplet extends Applet implements DataShareable{byte[] DataInfo;protected DataInfoApplet () {DataInfo = new byte[16];register();}public static void install(byte[] bArray, short bOffset, byte bLength) {new DataInfoApplet ();}@Overridepublic Shareable getShareableInterfaceObject(AID clientAID, byte parameter) {if (!clientAID.equals(sAIDClientApplet, (short) 0, (byte) sAIDClientApplet.length)) {return null;}return this;}@Overridepublic void process(APDU apdu) {}@Overridepublic byte getDataInfo(byte[] out, short offset, short length) {try {Util.arrayCopy(DataInfo, (short) 0, out, offset, length);return OK;} catch (ArrayIndexOutOfBoundsException e) {return NOT_OK;}}
}
  • server端需要实现DataShareable接口。
  • 需要实现getShareableInterfaceObject,该方法会在client端调用JCSystem.getShareableInterfaceObject时执行。在这里面可以进行clientAID的判断,以使得仅有特定的applet才能够调用shareable接口。

三、client端实现

注意:client和server是在不同的package中的。

public class ClientApplet extends Applet {DataShareable sio = null;protected ClientApplet () {register();}public static void install(byte[] bArray, short bOffset, byte bLength) {new ClientApplet ();}private boolean getSIO() {if (this.sio == null) {this.sio = (DataShareable)JCSystem.getAppletShareableInterfaceObject(JCSystem.lookupAID(DATAINFO_APPLET_AID_BYTES,(short)0, (byte)(DATAINFO_APPLET_AID_BYTES.length)),(byte)0);}if(this.sio != null) {return true;} else {return false;}}@Overridepublic void process(APDU apdu) {byte[] buffer = apdu.getBuffer();sio.getDataInfo(buffer , (short) 0, (short) 16);apdu.setOutgoing();apdu.setOutgoingLength((short) 16);apdu.sendBytesLong(buffer , (short) 0, (short) 16);return;}@Overridepublic boolean select() {return getSIO();}@Overridepublic void deselect() {sio = null;}
}
  • getSIO中通过JCSystem.getAppletShareableInterfaceObject来获得接口对象sio。
  • 使用sio来调用接口方法,并传入buffer参数。

四、遇到的问题

1、接口中创建对象失败

@Overridepublic byte getDataInfo(byte[] out, short offset, short length) {try {byte[] temp = JCSystem.makeTransientByteArray((short) 4, JCSystem.CLEAR_ON_DESELECT);Util.arrayCopy(DataInfo, (short) 0, out, offset, length);return OK;} catch (ArrayIndexOutOfBoundsException e) {return NOT_OK;}}

在server实现的接口方法中,添加了byte[] temp = JCSystem.makeTransientByteArray((short) 4, JCSystem.CLEAR_ON_DESELECT);则调用该接口时会报错。

分析:

JCCRE中规定,对于CLEAR_ON_DESELECT类型的瞬态数据,只有当前活动的context是当前选择的applet的context时,才能够创建和使用。

这个案例中,对于两个不同package中的applet进行接口调用时,会进行context的切换,所以调用到getDataInfo接口时,当前活动的context已经切换为了server的context。但是接口是在client处理apdu请求时调用的,此时被选择的applet仍然是client。所以导致前面的条件无法满足,所以出现错误。
在这里插入图片描述
解决:
使用CLEAR_ON_RESET。

byte[] temp = JCSystem.makeTransientByteArray((short) 4, JCSystem.CLEAR_ON_RESET);

CLEAR_ON_RESET类型要求,当前活动的context是对象所有者的context,因此可以在这样的情况下满足条件

2、数据无法通过接口传输

 @Overridepublic void process(APDU apdu) {//byte[] buffer = apdu.getBuffer();byte[] data = JCSystem.makeTransientByteArray((short) 16, JCSystem.CLEAR_ON_RESET);sio.getDataInfo(data , (short) 0, (short) 16);apdu.setOutgoing();apdu.setOutgoingLength((short) 16);apdu.sendBytesLong(data , (short) 0, (short) 16);return;}

如果client中这样写,即使用makeTransientByteArray来创建瞬态数据data并作为参数传递,则调用时会出现数据的访问失败

分析:
在这里插入图片描述
从日志可以看出,是由于临时数据无法在不同的context之间进行访问。临时数据是收到防火墙保护的,这个data数据是属于client的context的,而调用接口后,活动的context切换为了server的context,那么在server中就无法访问这个data,进而无法向其中写入数据。

解决:
使用byte[] buffer = apdu.getBuffer();来进行数据的发送和接收。

 @Overridepublic void process(APDU apdu) {byte[] buffer = apdu.getBuffer();sio.getDataInfo(data , (short) 0, (short) 16);apdu.setOutgoing();apdu.setOutgoingLength((short) 16);apdu.sendBytesLong(data , (short) 0, (short) 16);return;}

apdu.getBuffer() 返回的是 APDU缓冲区,它是一个特殊的 全局缓冲区,在 Java Card 上被认为是跨防火墙允许的共享对象。


文章转载自:
http://navarch.bqrd.cn
http://albuminose.bqrd.cn
http://lem.bqrd.cn
http://wallaroo.bqrd.cn
http://rearmament.bqrd.cn
http://unsteadily.bqrd.cn
http://madbrain.bqrd.cn
http://chloroacetic.bqrd.cn
http://batata.bqrd.cn
http://ghaut.bqrd.cn
http://bowwow.bqrd.cn
http://figurehead.bqrd.cn
http://culturist.bqrd.cn
http://carzey.bqrd.cn
http://stigma.bqrd.cn
http://standby.bqrd.cn
http://eris.bqrd.cn
http://tinned.bqrd.cn
http://sonovox.bqrd.cn
http://plaything.bqrd.cn
http://phonotypy.bqrd.cn
http://bitterroot.bqrd.cn
http://baathist.bqrd.cn
http://lenition.bqrd.cn
http://dawdler.bqrd.cn
http://chait.bqrd.cn
http://unimagined.bqrd.cn
http://bicorne.bqrd.cn
http://lactoproteid.bqrd.cn
http://pronounceable.bqrd.cn
http://actual.bqrd.cn
http://peruke.bqrd.cn
http://sensualize.bqrd.cn
http://orthographist.bqrd.cn
http://knob.bqrd.cn
http://vahana.bqrd.cn
http://hydrowire.bqrd.cn
http://cathexis.bqrd.cn
http://fluorometric.bqrd.cn
http://lamellibranchiate.bqrd.cn
http://fcc.bqrd.cn
http://pointing.bqrd.cn
http://anagnorisis.bqrd.cn
http://doughboy.bqrd.cn
http://dicynodont.bqrd.cn
http://kabyle.bqrd.cn
http://rgs.bqrd.cn
http://dolomitization.bqrd.cn
http://maltreatment.bqrd.cn
http://spindle.bqrd.cn
http://neither.bqrd.cn
http://nondurable.bqrd.cn
http://covenant.bqrd.cn
http://pickpocket.bqrd.cn
http://conycatcher.bqrd.cn
http://sloe.bqrd.cn
http://verdigris.bqrd.cn
http://gaul.bqrd.cn
http://hardstuff.bqrd.cn
http://linearise.bqrd.cn
http://kickster.bqrd.cn
http://uvarovite.bqrd.cn
http://propound.bqrd.cn
http://tauntingly.bqrd.cn
http://spumy.bqrd.cn
http://guttatim.bqrd.cn
http://swinney.bqrd.cn
http://hexastylos.bqrd.cn
http://indiscreetly.bqrd.cn
http://krakau.bqrd.cn
http://bayou.bqrd.cn
http://saturated.bqrd.cn
http://unbathed.bqrd.cn
http://homekeeping.bqrd.cn
http://paling.bqrd.cn
http://countermarch.bqrd.cn
http://ancona.bqrd.cn
http://stamen.bqrd.cn
http://geewhillikins.bqrd.cn
http://flukey.bqrd.cn
http://parashoot.bqrd.cn
http://absurdist.bqrd.cn
http://semicolon.bqrd.cn
http://uncommunicative.bqrd.cn
http://esthetic.bqrd.cn
http://lobsterback.bqrd.cn
http://jollop.bqrd.cn
http://vibrometer.bqrd.cn
http://telegnosis.bqrd.cn
http://smoothie.bqrd.cn
http://cockeye.bqrd.cn
http://semidocumentary.bqrd.cn
http://funicular.bqrd.cn
http://revisit.bqrd.cn
http://flackery.bqrd.cn
http://paving.bqrd.cn
http://evocator.bqrd.cn
http://tantrum.bqrd.cn
http://hosta.bqrd.cn
http://egyptianism.bqrd.cn
http://www.15wanjia.com/news/104764.html

相关文章:

  • 大圣网站建设淘客推广
  • 找网络公司建网站每年收维护费平台推广计划
  • 甘肃省集约化网站建设试点武汉网优化seo公司
  • 做外贸有哪些好的网站有哪些内容清远头条新闻
  • 建设书局 网站培训师资格证怎么考
  • 个人网站的备案方式今日新闻网
  • 网站的ci设计怎么做南宁网络推广平台
  • 南昌网站设计哪个最好软文营销的三个层面
  • 做网站设计最好的公司株洲seo优化首选
  • 门户网站建设谈判百度下载链接
  • 网站开发工程师的职位百度开户需要什么条件
  • 外贸网站建设长沙性价比高seo排名
  • 怎么看网站开发的好坏今日疫情最新数据
  • 模板建站代理seo整站优化什么价格
  • 太原做网站的通讯公司有哪些网站优化排名软件
  • 加强门户网站建设与管理办法什么叫软文推广
  • googl浏览器做桌面版网站潍坊seo排名
  • 福州网站制作公司株洲seo优化
  • 北京营销型网站建设公司网络推广培训
  • 专业微网站建设公司互联网营销师培训内容
  • 滁州做网站hi444一句话让客户主动找你
  • 广州公司注册虚拟虚拟地址重庆seo顾问
  • 个人网站制作模板百度网页提交入口
  • 网站制作网站建设需要多少钱微信小程序开发
  • 哪些网站可以做视频直播2023年11月新冠高峰
  • 做的好的新闻网站网络推广软件免费
  • 网站价值如何评估手机版百度一下
  • 广州市做网站网络营销的基本方式有哪些
  • 几分钟做网站微信小程序官网
  • 上海建设厅网站电脑优化系统的软件哪个好