📄 onewirecontainer16.java
字号:
throws OneWireException, OneWireIOException, IllegalArgumentException { capdu = new CommandAPDU(CLA, INS, ( byte ) 0x01, ( byte ) 0x06); rapdu = sendAPDU(capdu, runTime); return rapdu; } // getRestoreMode() /** * Gets the Exception Mode. * When Exception Mode is enabled (<code>1</code>), Java API exceptions * are thrown. All uncaught exceptions return 0x6F00 in the SW. * When disabled, an error is returned from the VM. No PIN required. * * @return <code>ResponseAPDU</code> containing the Exception Mode value * <ul> * <li>Success SW 0x9000. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * * @see #setExceptionMode */ public ResponseAPDU getExceptionMode () throws OneWireException, OneWireIOException, IllegalArgumentException { capdu = new CommandAPDU(CLA, INS, ( byte ) 0x01, ( byte ) 0x07); rapdu = sendAPDU(capdu, runTime); return rapdu; } // getExceptionMode() /** * Gets the size of the Commit Buffer. * Committing one field to the buffer requires <code>9</code> bytes. * Therefore the default size of <code>72</code> bytes allows <code>8</code> * field updates. The minimum size allowed is <code>72</code> bytes and the * maximum is restricted by the amount of free RAM. All values will be rounded * up to the next multiple of <code>9</code>. No PIN required. * * @return <code>ResponseAPDU</code> containing the Commit Buffer size in little * endian format * <ul> * <li>Success SW 0x9000. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * * @see #getFreeRAM * @see #setCommitBufferSize */ public ResponseAPDU getCommitBufferSize () throws OneWireException, OneWireIOException, IllegalArgumentException { capdu = new CommandAPDU(CLA, INS, ( byte ) 0x01, ( byte ) 0x0A); rapdu = sendAPDU(capdu, runTime); return rapdu; } // getCommitBufferSize() /** * Sets the Common PIN. * This method is used to change the value of the Common PIN on the Java * iButton. If this Java iButton currently has a PIN, the <code>setPIN()</code> * method should be called prior to this method with the 'oldPIN' value. * * @param newPIN the value of the PIN to be set in this Java iButton * * @return <code>ResponseAPDU</code> indicating success or failure * <ul> * <li>Success SW 0x9000. * <li>Failure SW 0x6681. Invalid PIN. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * * @see #getCommandPINMode * @see #setCommandPINMode * @see #setPIN */ public ResponseAPDU setCommonPIN (String newPIN) throws OneWireException, OneWireIOException, IllegalArgumentException { byte[] data; if (password != null) { data = new byte [newPIN.length() + password.length() + 2]; data [0] = ( byte ) password.length(); System.arraycopy(password.getBytes(), 0, data, 1, password.length()); data [password.length() + 1] = ( byte ) newPIN.length(); System.arraycopy(newPIN.getBytes(), 0, data, password.length() + 2, newPIN.length()); } else { data = new byte [2 + newPIN.length()]; data [0] = ( byte ) 0; data [1] = ( byte ) newPIN.length(); System.arraycopy(newPIN.getBytes(), 0, data, 2, newPIN.length()); } capdu = new CommandAPDU(CLA, INS, ( byte ) 0x00, ( byte ) 0x01, data); rapdu = sendAPDU(capdu, runTime); return rapdu; } // setCommonPin() /** * Sets the Ephemeral Garbage Collection Mode. * A value of <code>1</code> turns the Ephemeral Garbage Collection on * and a value of <code>0</code> turns it off. * * @param mode <code>1</code> to turn on Ephemeral Garbage Collection Mode. * <code>0</code> to turn off. * * @return <code>ResponseAPDU</code> indicating success or failure * <ul> * <li>Success SW 0x9000. * <li>Failure SW 0x6681. Invalid PIN. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * * @see #getEphemeralGCMode */ public ResponseAPDU setEphemeralGCMode (int mode) throws OneWireException, OneWireIOException, IllegalArgumentException { byte[] data; if (password != null) { data = new byte [2 + password.length()]; data [0] = ( byte ) password.length(); System.arraycopy(password.getBytes(), 0, data, 1, password.length()); data [password.length() + 1] = ( byte ) mode; } else { data = new byte [2]; data [0] = ( byte ) 0; data [1] = ( byte ) mode; } capdu = new CommandAPDU(CLA, INS, ( byte ) 0x00, ( byte ) 0x02, data); rapdu = sendAPDU(capdu, runTime); return rapdu; } // set EphemeralGCMode() /** * Sets the Applet Garbage Collection Mode. * A value of <code>1</code> turns the Applet Garbage Collection on * and a value of <code>0</code> turns it off. * * @param mode <code>1</code> to turn on Applet Garbage Collection Mode. * <code>0</code> to turn off. * * @return <code>ResponseAPDU</code> indicating success or failure * <ul> * <li>Success SW 0x9000. * <li>Failure SW 0x6681. Invalid PIN. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * * @see #getAppletGCMode */ public ResponseAPDU setAppletGCMode (int mode) throws OneWireException, OneWireIOException, IllegalArgumentException { byte[] data; if (password != null) { data = new byte [2 + password.length()]; data [0] = ( byte ) password.length(); System.arraycopy(password.getBytes(), 0, data, 1, password.length()); data [password.length() + 1] = ( byte ) mode; } else { data = new byte [2]; data [0] = ( byte ) 0; data [1] = ( byte ) mode; } capdu = new CommandAPDU(CLA, INS, ( byte ) 0x00, ( byte ) 0x03, data); rapdu = sendAPDU(capdu, runTime); return rapdu; } // setAppletGCMode() /** * Sets the Command PIN Mode. * If command PIN mode is set to <code>1</code>, a PIN is required for all * Administrative commands. * * @param mode <code>1</code> to turn on Command PIN Mode. * <code>0</code> to turn off. * * @return <code>ResponseAPDU</code> indicating success or failure * <ul> * <li>Success SW 0x9000. * <li>Failure SW 0x6681. Invalid PIN. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * * @see #getCommandPINMode * @see #setCommonPIN * @see #setPIN */ public ResponseAPDU setCommandPINMode (int mode) throws OneWireException, OneWireIOException, IllegalArgumentException { byte[] data; if (password != null) { data = new byte [2 + password.length()]; data [0] = ( byte ) password.length(); System.arraycopy(password.getBytes(), 0, data, 1, password.length()); data [password.length() + 1] = ( byte ) mode; } else { data = new byte [2]; data [0] = ( byte ) 0; data [1] = ( byte ) mode; } capdu = new CommandAPDU(CLA, INS, ( byte ) 0x00, ( byte ) 0x04, data); rapdu = sendAPDU(capdu, runTime); return rapdu; } // setCommandPINMode() /** * Sets the Load PIN Mode. * If the load PIN mode is set (<code>1</code>), then PINs are required * on applet loading. * * @param mode <code>1</code> to turn on Load PIN Mode. * <code>0</code> to turn off. * * @return <code>ResponseAPDU</code> indicating success or failure * <ul> * <li>Success SW 0x9000. * <li>Failure SW 0x6681. Invalid PIN. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * * @see #getLoadPINMode * @see #loadApplet */ public ResponseAPDU setLoadPINMode (int mode) throws OneWireException, OneWireIOException, IllegalArgumentException { byte[] data; if (password != null) { data = new byte [2 + password.length()]; data [0] = ( byte ) password.length(); System.arraycopy(password.getBytes(), 0, data, 1, password.length()); data [password.length() + 1] = ( byte ) mode; } else { data = new byte [2]; data [0] = ( byte ) 0; data [1] = ( byte ) mode; } capdu = new CommandAPDU(CLA, INS, ( byte ) 0x00, ( byte ) 0x05, data); rapdu = sendAPDU(capdu, runTime); return rapdu; } // setLoadPINMode() /** * Sets the Restore Mode. * When Restore Mode is enabled (<code>1</code>), all field updates and * <code>javacard.framework.System</code> transactions are considered atomic. * If a tear occurs in the middle of these updates, values just prior to the * update are restored. * * @param mode <code>1</code> to turn on Restore Mode. * <code>0</code> to turn off. * * @return <code>ResponseAPDU</code> indicating success or failure * <ul> * <li>Success SW 0x9000. * <li>Failure SW 0x6681. Invalid PIN. * <li>For additional error codes, please see: * <A HREF="http://www.ibutton.com/jibkit/documents/sw.html"> * http://www.ibutton.com/jibkit/documents/sw.html</A> * </ul> * * @throws IllegalArgumentException Invalid run time value * @throws OneWireException Part could not be found [ fatal ] * @throws OneWireIOException Data wasn't transferred properly [ recoverable ] * * @see #getRestoreMode */ public ResponseAPDU setRestoreMode (int mode)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -