1 package com.android.anqp.eap; 2 3 import java.util.HashMap; 4 import java.util.Iterator; 5 import java.util.Map; 6 7 /** 8 * EAP Related constants for the ANQP NAIRealm element, IEEE802.11-2012 section 8.4.4.10 9 */ 10 public abstract class EAP { 11 12 private static final Map<Integer, EAPMethodID> sEapIds = new HashMap<>(); 13 private static final Map<EAPMethodID, Integer> sRevEapIds = new HashMap<>(); 14 private static final Map<Integer, AuthInfoID> sAuthIds = new HashMap<>(); 15 16 public static final int EAP_MD5 = 4; 17 public static final int EAP_OTP = 5; 18 public static final int EAP_RSA = 9; 19 public static final int EAP_KEA = 11; 20 public static final int EAP_KEA_VALIDATE = 12; 21 public static final int EAP_TLS = 13; 22 public static final int EAP_LEAP = 17; 23 public static final int EAP_SIM = 18; 24 public static final int EAP_TTLS = 21; 25 public static final int EAP_AKA = 23; 26 public static final int EAP_3Com = 24; 27 public static final int EAP_MSCHAPv2 = 26; 28 public static final int EAP_PEAP = 29; 29 public static final int EAP_POTP = 32; 30 public static final int EAP_ActiontecWireless = 35; 31 public static final int EAP_HTTPDigest = 38; 32 public static final int EAP_SPEKE = 41; 33 public static final int EAP_MOBAC = 42; 34 public static final int EAP_FAST = 43; 35 public static final int EAP_ZLXEAP = 44; 36 public static final int EAP_Link = 45; 37 public static final int EAP_PAX = 46; 38 public static final int EAP_PSK = 47; 39 public static final int EAP_SAKE = 48; 40 public static final int EAP_IKEv2 = 49; 41 public static final int EAP_AKAPrim = 50; 42 public static final int EAP_GPSK = 51; 43 public static final int EAP_PWD = 52; 44 public static final int EAP_EKE = 53; 45 public static final int EAP_TEAP = 55; 46 47 public enum EAPMethodID { 48 EAP_MD5, 49 EAP_OTP, 50 EAP_RSA, 51 EAP_KEA, 52 EAP_KEA_VALIDATE, 53 EAP_TLS, 54 EAP_LEAP, 55 EAP_SIM, 56 EAP_TTLS, 57 EAP_AKA, 58 EAP_3Com, 59 EAP_MSCHAPv2, 60 EAP_PEAP, 61 EAP_POTP, 62 EAP_ActiontecWireless, 63 EAP_HTTPDigest, 64 EAP_SPEKE, 65 EAP_MOBAC, 66 EAP_FAST, 67 EAP_ZLXEAP, 68 EAP_Link, 69 EAP_PAX, 70 EAP_PSK, 71 EAP_SAKE, 72 EAP_IKEv2, 73 EAP_AKAPrim, 74 EAP_GPSK, 75 EAP_PWD, 76 EAP_EKE, 77 EAP_TEAP 78 } 79 80 public static final int ExpandedEAPMethod = 1; 81 public static final int NonEAPInnerAuthType = 2; 82 public static final int InnerAuthEAPMethodType = 3; 83 public static final int ExpandedInnerEAPMethod = 4; 84 public static final int CredentialType = 5; 85 public static final int TunneledEAPMethodCredType = 6; 86 public static final int VendorSpecific = 221; 87 88 public enum AuthInfoID { 89 Undefined, 90 ExpandedEAPMethod, 91 NonEAPInnerAuthType, 92 InnerAuthEAPMethodType, 93 ExpandedInnerEAPMethod, 94 CredentialType, 95 TunneledEAPMethodCredType, 96 VendorSpecific 97 } 98 99 static { 100 sEapIds.put(EAP_MD5, EAPMethodID.EAP_MD5); 101 sEapIds.put(EAP_OTP, EAPMethodID.EAP_OTP); 102 sEapIds.put(EAP_RSA, EAPMethodID.EAP_RSA); 103 sEapIds.put(EAP_KEA, EAPMethodID.EAP_KEA); 104 sEapIds.put(EAP_KEA_VALIDATE, EAPMethodID.EAP_KEA_VALIDATE); 105 sEapIds.put(EAP_TLS, EAPMethodID.EAP_TLS); 106 sEapIds.put(EAP_LEAP, EAPMethodID.EAP_LEAP); 107 sEapIds.put(EAP_SIM, EAPMethodID.EAP_SIM); 108 sEapIds.put(EAP_TTLS, EAPMethodID.EAP_TTLS); 109 sEapIds.put(EAP_AKA, EAPMethodID.EAP_AKA); 110 sEapIds.put(EAP_3Com, EAPMethodID.EAP_3Com); 111 sEapIds.put(EAP_MSCHAPv2, EAPMethodID.EAP_MSCHAPv2); 112 sEapIds.put(EAP_PEAP, EAPMethodID.EAP_PEAP); 113 sEapIds.put(EAP_POTP, EAPMethodID.EAP_POTP); 114 sEapIds.put(EAP_ActiontecWireless, EAPMethodID.EAP_ActiontecWireless); 115 sEapIds.put(EAP_HTTPDigest, EAPMethodID.EAP_HTTPDigest); 116 sEapIds.put(EAP_SPEKE, EAPMethodID.EAP_SPEKE); 117 sEapIds.put(EAP_MOBAC, EAPMethodID.EAP_MOBAC); 118 sEapIds.put(EAP_FAST, EAPMethodID.EAP_FAST); 119 sEapIds.put(EAP_ZLXEAP, EAPMethodID.EAP_ZLXEAP); 120 sEapIds.put(EAP_Link, EAPMethodID.EAP_Link); 121 sEapIds.put(EAP_PAX, EAPMethodID.EAP_PAX); 122 sEapIds.put(EAP_PSK, EAPMethodID.EAP_PSK); 123 sEapIds.put(EAP_SAKE, EAPMethodID.EAP_SAKE); 124 sEapIds.put(EAP_IKEv2, EAPMethodID.EAP_IKEv2); 125 sEapIds.put(EAP_AKAPrim, EAPMethodID.EAP_AKAPrim); 126 sEapIds.put(EAP_GPSK, EAPMethodID.EAP_GPSK); 127 sEapIds.put(EAP_PWD, EAPMethodID.EAP_PWD); 128 sEapIds.put(EAP_EKE, EAPMethodID.EAP_EKE); 129 sEapIds.put(EAP_TEAP, EAPMethodID.EAP_TEAP); 130 131 for (Map.Entry<Integer, EAPMethodID> entry : sEapIds.entrySet()) { 132 sRevEapIds.put(entry.getValue(), entry.getKey()); 133 } 134 135 sAuthIds.put(ExpandedEAPMethod, AuthInfoID.ExpandedEAPMethod); 136 sAuthIds.put(NonEAPInnerAuthType, AuthInfoID.NonEAPInnerAuthType); 137 sAuthIds.put(InnerAuthEAPMethodType, AuthInfoID.InnerAuthEAPMethodType); 138 sAuthIds.put(ExpandedInnerEAPMethod, AuthInfoID.ExpandedInnerEAPMethod); 139 sAuthIds.put(CredentialType, AuthInfoID.CredentialType); 140 sAuthIds.put(TunneledEAPMethodCredType, AuthInfoID.TunneledEAPMethodCredType); 141 sAuthIds.put(VendorSpecific, AuthInfoID.VendorSpecific); 142 } 143 144 public static EAPMethodID mapEAPMethod(int methodID) { 145 return sEapIds.get(methodID); 146 } 147 148 public static Integer mapEAPMethod(EAPMethodID methodID) { 149 return sRevEapIds.get(methodID); 150 } 151 152 public static AuthInfoID mapAuthMethod(int methodID) { 153 return sAuthIds.get(methodID); 154 } 155 } 156