Home | History | Annotate | Download | only in hotspot2
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.android.server.wifi.hotspot2;
     17 
     18 /**
     19  * Match score for EAP credentials:
     20  * None means that there is a distinct mismatch, i.e. realm, method or parameter is defined
     21  * and mismatches that of the credential.
     22  * Indeterminate means that there is no ANQP information to match against.
     23  * Note: The numeric values given to the constants are used for preference comparison and
     24  * must be maintained accordingly.
     25  */
     26 public abstract class AuthMatch {
     27     public static final int NONE = -1;
     28     public static final int INDETERMINATE = 0;
     29     public static final int REALM = 0x04;
     30     public static final int METHOD = 0x02;
     31     public static final int PARAM = 0x01;
     32     public static final int METHOD_PARAM = METHOD | PARAM;
     33     public static final int EXACT = REALM | METHOD | PARAM;
     34 
     35     public static String toString(int match) {
     36         if (match < 0) {
     37             return "None";
     38         }
     39         else if (match == 0) {
     40             return "Indeterminate";
     41         }
     42 
     43         StringBuilder sb = new StringBuilder();
     44         if ((match & REALM) != 0) {
     45             sb.append("Realm");
     46         }
     47         if ((match & METHOD) != 0) {
     48             sb.append("Method");
     49         }
     50         if ((match & PARAM) != 0) {
     51             sb.append("Param");
     52         }
     53         return sb.toString();
     54     }
     55 }
     56