⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jibcardservicefactory.java

📁 这是一个以JAVA编写的程序,本人还没有试过,是一个简单的温度控制系统
💻 JAVA
字号:
/*--------------------------------------------------------------------------- * Copyright (C) 1999,2000 Dallas Semiconductor Corporation, All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of Dallas Semiconductor * shall not be used except as stated in the Dallas Semiconductor * Branding Policy. *--------------------------------------------------------------------------- */package com.dalsemi.onewire.jib.service;import opencard.core.service.*;import java.util.*;import opencard.core.terminal.*;/** * <p>A <code>JiBCardServiceFactory</code> can instantiate <code>CardService</code>s for * the Java Powered iButton. </p> * * <p>A <code>CardServiceFactory</code> in OpenCard provides a device-independent means of  * accessing 'services' on a card.  Services might include a means of selecting or deleting * applets from a JavaCard device such as the Java Powered <u>i</u>Button.</p> * * <p>A <code>CardServiceFactory</code> must be 'registered' in order to be used.  One way to  * do this is through the <code>java.lang.System</code> property methods...</p> * <code><pre> *     System.getProperties().put("OpenCard.services",  *           "com.dalsemi.onewire.jib.service.JiBCardServiceFactory");  * </pre></code> *  * @author  K * * @see JiBAppletAccessCardService * @see JiBAppletManagerCardService */public class JiBCardServiceFactory extends CardServiceFactory{  /** Return an enumeration of known <code>CardService</code> classes.   *   * @param     type   *		The <code>CardType</code> of the smart card for which   *		the enumeration is requested.   * @return    An <code>Enumeration</code> of class objects.   */    public Enumeration getClasses(opencard.core.service.CardType cardtype)    {        int type = cardtype.getType();        // 1 == Modern iButtons        // 2 == JavaOne crusty iButtons                Vector classes = new Vector();        classes.addElement(com.dalsemi.onewire.jib.service.JiBAppletAccessCardService.class);        classes.addElement(com.dalsemi.onewire.jib.service.JiBAppletManagerCardService.class);        return classes.elements();    }      /** Indicate whether this <code>CardServiceFactory</code> "knows" the smart card OS   * and/or installed card applications   * and might be able to instantiate <code>CardService</code>s for it.    *   * @param     cid   *		A <code>CardID</code> received from a <code>Slot</code>.   * @param scheduler   *    A <code>CardServiceScheduler</code> that can be used to communicate with   *    the card to determine its type.   *   * @return A valid CardType if the factory can instantiate services for this   *         card.   *         CardType.UNSUPPORTED if the factory does not know the card.   *   * @see #getClasses   *   */    public CardType getCardType(CardID cardid, CardServiceScheduler scheduler)    {        byte[] ATR = cardid.getATR();        if (ATR==null)            return CardType.UNSUPPORTED;                //see if we recognize the ATR        for (int i=0;i<known_ATRs.length;i++)        {            byte[] this_atr = known_ATRs[i];            boolean valid = true;            if (ATR.length != this_atr.length)                valid = false;            for (int k=0; valid && (k<ATR.length); k++)            {                if (ATR[k] != this_atr[k])                    valid = false;            }            if (valid)            {                CardType jibtype = new CardType(i+1);                if (i==1)                     jibtype.setInfo("JavaOne-Edition Java iButton");                else                     jibtype.setInfo("Java Powered iButton");                return jibtype;                                }        }                return CardType.UNSUPPORTED;    }        private static final byte[][] known_ATRs =     {        //ATR for modern iButtons...        { 00,(byte)0x8f,0x0e,00,00,00,00,00,00,00,00,00,00,0x04,00,00,0x34,(byte)0x90},                //ATR for JavaOne iButtons (0,03,0003 Firmware)        { (byte)0x8f,0x0e,(byte)0x80,0x31,(byte)0xa8,0x52,0x44,0x53,0x64,0x41,0x36,0x00,0x01,0x73,(byte)0x8c,0x21,0x00},                //add more ATRs here if they ever come up    };    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -