InnerAuthEAP.java revision 7b2caa25fb57f2d95e0d0421704c49d3af4b8e6f
1package com.android.server.wifi.anqp.eap;
2
3import java.net.ProtocolException;
4import java.nio.ByteBuffer;
5
6import static com.android.server.wifi.anqp.Constants.BYTE_MASK;
7
8/**
9 * An EAP authentication parameter, IEEE802.11-2012, table 8-188
10 */
11public class InnerAuthEAP implements AuthParam {
12
13    private final EAP.EAPMethodID mEapMethodID;
14
15    public InnerAuthEAP(int length, ByteBuffer payload) throws ProtocolException {
16        if (length != 1) {
17            throw new ProtocolException("Bad length: " + length);
18        }
19        int typeID = payload.get() & BYTE_MASK;
20        mEapMethodID = EAP.mapEAPMethod(typeID);
21    }
22
23    @Override
24    public EAP.AuthInfoID getAuthInfoID() {
25        return EAP.AuthInfoID.InnerAuthEAPMethodType;
26    }
27
28    public EAP.EAPMethodID getEAPMethodID() {
29        return mEapMethodID;
30    }
31
32    @Override
33    public int hashCode() {
34        return mEapMethodID != null ? mEapMethodID.hashCode() : 0;
35    }
36
37    @Override
38    public boolean equals(Object thatObject) {
39        if (thatObject == this) {
40            return true;
41        } else if (thatObject == null || thatObject.getClass() != InnerAuthEAP.class) {
42            return false;
43        } else {
44            return ((InnerAuthEAP) thatObject).getEAPMethodID() == getEAPMethodID();
45        }
46    }
47
48    @Override
49    public String toString() {
50        return "Auth method InnerAuthEAP, inner = " + mEapMethodID + '\n';
51    }
52}
53