ExpandedEAPMethod.java revision 3be1b3fc037bef7fb4448dec89aea3f2e1318853
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.INT_MASK; 7import static com.android.server.wifi.anqp.Constants.getInteger; 8 9/** 10 * An EAP authentication parameter, IEEE802.11-2012, table 8-188 11 */ 12public class ExpandedEAPMethod implements AuthParam { 13 14 private final EAP.AuthInfoID m_authInfoID; 15 private final int m_vendorID; 16 private final long m_vendorType; 17 18 public ExpandedEAPMethod(EAP.AuthInfoID authInfoID, int length, ByteBuffer payload) 19 throws ProtocolException { 20 if (length != 7) { 21 throw new ProtocolException("Bad length: " + payload.remaining()); 22 } 23 24 m_authInfoID = authInfoID; 25 m_vendorID = (int) getInteger(payload, 3); 26 m_vendorType = payload.getInt() & INT_MASK; 27 } 28 29 @Override 30 public EAP.AuthInfoID getAuthInfoID() { 31 return m_authInfoID; 32 } 33 34 @Override 35 public int hashCode() { 36 return (m_authInfoID.hashCode() * 31 + m_vendorID) * 31 + (int) m_vendorType; 37 } 38 39 @Override 40 public boolean equals(Object thatObject) { 41 if (thatObject == this) { 42 return true; 43 } else if (thatObject == null || thatObject.getClass() != ExpandedEAPMethod.class) { 44 return false; 45 } else { 46 ExpandedEAPMethod that = (ExpandedEAPMethod) thatObject; 47 return that.getVendorID() == getVendorID() && that.getVendorType() == getVendorType(); 48 } 49 } 50 51 public int getVendorID() { 52 return m_vendorID; 53 } 54 55 public long getVendorType() { 56 return m_vendorType; 57 } 58 59 @Override 60 public String toString() { 61 return "ExpandedEAPMethod{" + 62 "m_authInfoID=" + m_authInfoID + 63 ", m_vendorID=" + m_vendorID + 64 ", m_vendorType=" + m_vendorType + 65 '}'; 66 } 67} 68