< prev index next >

## src/java.smartcardio/share/classes/javax/smartcardio/ResponseAPDU.java

Print this page

      1 /*
      2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
      3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      4  *
      5  * This code is free software; you can redistribute it and/or modify it
      6  * under the terms of the GNU General Public License version 2 only, as
      7  * published by the Free Software Foundation.  Oracle designates this
      8  * particular file as subject to the "Classpath" exception as provided
      9  * by Oracle in the LICENSE file that accompanied this code.
     10  *
     11  * This code is distributed in the hope that it will be useful, but WITHOUT
     12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14  * version 2 for more details (a copy is included in the LICENSE file that
     15  * accompanied this code).
     16  *
     17  * You should have received a copy of the GNU General Public License version
     18  * 2 along with this work; if not, write to the Free Software Foundation,
     19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     20  *
     21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     22  * or visit www.oracle.com if you need additional information or have any
     23  * questions.
     24  */
     25
     26 package javax.smartcardio;
     27
     28 import java.util.Arrays;

     29
     30 /**
     31  * A response APDU as defined in ISO/IEC 7816-4. It consists of a conditional
     32  * body and a two byte trailer.
     33  * This class does not attempt to verify that the APDU encodes a semantically
     34  * valid response.
     35  *
     36  * <p>Instances of this class are immutable. Where data is passed in or out
     37  * via byte arrays, defensive cloning is performed.
     38  *
     39  * @see CommandAPDU
     40  * @see CardChannel#transmit CardChannel.transmit
     41  *
     42  * @since   1.6
     43  * @author  Andreas Sterbenz
     44  * @author  JSR 268 Expert Group
     45  */
     46 public final class ResponseAPDU implements java.io.Serializable {
     47
     48     private static final long serialVersionUID = 6962744978375594225L;
    159     public boolean equals(Object obj) {
    160         if (this == obj) {
    161             return true;
    162         }
    163         if (obj instanceof ResponseAPDU == false) {
    164             return false;
    165         }
    166         ResponseAPDU other = (ResponseAPDU)obj;
    167         return Arrays.equals(this.apdu, other.apdu);
    168     }
    169
    170     /**
    171      * Returns the hash code value for this response APDU.
    172      *
    173      * @return the hash code value for this response APDU.
    174      */
    175     public int hashCode() {
    176         return Arrays.hashCode(apdu);
    177     }
    178

    179     private void readObject(java.io.ObjectInputStream in)
    180             throws java.io.IOException, ClassNotFoundException {
    181         apdu = (byte[])in.readUnshared();
    182         check(apdu);
    183     }
    184
    185 }
      1 /*
      2  * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
      3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      4  *
      5  * This code is free software; you can redistribute it and/or modify it
      6  * under the terms of the GNU General Public License version 2 only, as
      7  * published by the Free Software Foundation.  Oracle designates this
      8  * particular file as subject to the "Classpath" exception as provided
      9  * by Oracle in the LICENSE file that accompanied this code.
     10  *
     11  * This code is distributed in the hope that it will be useful, but WITHOUT
     12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14  * version 2 for more details (a copy is included in the LICENSE file that
     15  * accompanied this code).
     16  *
     17  * You should have received a copy of the GNU General Public License version
     18  * 2 along with this work; if not, write to the Free Software Foundation,
     19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     20  *
     21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
     22  * or visit www.oracle.com if you need additional information or have any
     23  * questions.
     24  */
     25
     26 package javax.smartcardio;
     27
     28 import java.util.Arrays;
     29 import java.io.IOException;
     30
     31 /**
     32  * A response APDU as defined in ISO/IEC 7816-4. It consists of a conditional
     33  * body and a two byte trailer.
     34  * This class does not attempt to verify that the APDU encodes a semantically
     35  * valid response.
     36  *
     37  * <p>Instances of this class are immutable. Where data is passed in or out
     38  * via byte arrays, defensive cloning is performed.
     39  *
     40  * @see CommandAPDU
     41  * @see CardChannel#transmit CardChannel.transmit
     42  *
     43  * @since   1.6
     44  * @author  Andreas Sterbenz
     45  * @author  JSR 268 Expert Group
     46  */
     47 public final class ResponseAPDU implements java.io.Serializable {
     48
     49     private static final long serialVersionUID = 6962744978375594225L;
    160     public boolean equals(Object obj) {
    161         if (this == obj) {
    162             return true;
    163         }
    164         if (obj instanceof ResponseAPDU == false) {
    165             return false;
    166         }
    167         ResponseAPDU other = (ResponseAPDU)obj;
    168         return Arrays.equals(this.apdu, other.apdu);
    169     }
    170
    171     /**
    172      * Returns the hash code value for this response APDU.
    173      *
    174      * @return the hash code value for this response APDU.
    175      */
    176     public int hashCode() {
    177         return Arrays.hashCode(apdu);
    178     }
    179
    180     /**
    181      * Restores the state of this object from the stream.
    182      *
    183      * @param  in the {@code ObjectInputStream} from which data is read
    184      * @throws IOException if an I/O error occurs
    185      * @throws ClassNotFoundException if a serialized class cannot be loaded
    186      */
    187     private void readObject(java.io.ObjectInputStream in)
    188             throws IOException, ClassNotFoundException {
    189         apdu = (byte[])in.readUnshared();
    190         check(apdu);
    191     }
    192
    193 }

< prev index next >