WifiPasspointCredential.java revision 7c28c3663470ce5eb818cfa2ce4a993e4bae8f33
1/* 2 * Copyright (C) 2014 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 17package android.net.wifi.passpoint; 18 19import android.net.wifi.WifiEnterpriseConfig; 20import android.os.Parcelable; 21import android.os.Parcel; 22 23import java.util.Collection; 24import java.util.Set; 25import java.util.Iterator; 26import java.util.Map; 27 28/** 29 * A class representing a Wi-Fi Passpoint credential. 30 */ 31public class WifiPasspointCredential implements Parcelable { 32 33 private final static String TAG = "PasspointCredential"; 34 private String mWifiTreePath; 35 private String mWifiSPFQDN; 36 private String mCredentialName; 37 private String mUpdateIdentifier; 38 private String mSubscriptionUpdateMethod; 39 private String mType; 40 private String mInnerMethod; 41 private String mCertType; 42 private String mCertSha256Fingerprint; 43 private String mUsername; 44 private String mPasswd; 45 private String mImsi; 46 private String mMcc; 47 private String mMnc; 48 private String mCaRootCert; 49 private String mRealm; 50 private int mPriority; //User preferred priority; The smaller, the higher 51 private boolean mUserPreferred = false; 52 private String mHomeSpFqdn; 53 private String mFriendlyName; 54 private String mOtherhomepartnerFqdn; 55 private String mClientCert; 56 private String mCreationDate; 57 private String mExpirationDate; 58 59 private String mSubscriptionDMAccUsername; 60 private String mSubscriptionDMAccPassword; 61 private String mSubscriptionUpdateInterval; 62 63 private String mPolicyUpdateURI; 64 private String mPolicyUpdateInterval; 65 private String mPolicyDMAccUsername; 66 private String mPolicyDMAccPassword; 67 private String mPolicyUpdateRestriction; 68 private String mPolicyUpdateMethod; 69 70 private Collection<WifiPasspointDmTree.PreferredRoamingPartnerList> mPreferredRoamingPartnerList; 71 private Collection<WifiPasspointDmTree.HomeOIList> mHomeOIList; 72 private Collection<WifiPasspointDmTree.MinBackhaulThresholdNetwork> mMinBackhaulThresholdNetwork; 73 private Collection<WifiPasspointDmTree.RequiredProtoPortTuple> mRequiredProtoPortTuple; 74 private Collection<WifiPasspointDmTree.SPExclusionList> mSpExclusionList; 75 private String mMaxBssLoad; 76 77 private boolean mIsMachineRemediation; 78 79 private String mAAACertURL; 80 private String mAAASha256Fingerprint; 81 82 private String mSubscriptionUpdateRestriction; 83 private String mSubscriptionUpdateURI; 84 85 private boolean mCheckAaaServerCertStatus; 86 87 /** @hide */ 88 public WifiPasspointCredential() { 89 90 } 91 92 /** 93 * Constructor 94 * @param realm Realm of the passpoint credential 95 * @param fqdn Fully qualified domain name (FQDN) of the credential 96 * @param config Credential information, must be either EAP-TLS or EAP-TTLS 97 * @see WifiEnterpriseConfig 98 */ 99 public WifiPasspointCredential(String realm, String fqdn, WifiEnterpriseConfig config) { 100 mRealm = realm; 101 switch (config.getEapMethod()) { 102 case WifiEnterpriseConfig.Eap.TLS: 103 // TODO; 104 break; 105 case WifiEnterpriseConfig.Eap.TTLS: 106 // TODO; 107 break; 108 default: 109 // ignore 110 } 111 } 112 113 /** @hide */ 114 public WifiPasspointCredential(String type, 115 String caroot, 116 String clientcert, 117 WifiPasspointDmTree.SpFqdn sp, 118 WifiPasspointDmTree.CredentialInfo credinfo) { 119 120 if (credinfo == null) { 121 return; 122 } 123 124 mType = type; 125 mCaRootCert = caroot; 126 mClientCert = clientcert; 127 128 mWifiSPFQDN = sp.nodeName; 129 mUpdateIdentifier = sp.perProviderSubscription.UpdateIdentifier; 130 131 mCredentialName = credinfo.nodeName; 132 Set set = credinfo.homeSP.otherHomePartners.entrySet(); 133 Iterator i = set.iterator(); 134 if (i.hasNext()) { 135 Map.Entry entry3 = (Map.Entry) i.next(); 136 WifiPasspointDmTree.OtherHomePartners ohp = (WifiPasspointDmTree.OtherHomePartners) entry3.getValue(); 137 mOtherhomepartnerFqdn = ohp.FQDN; 138 } 139 140 set = credinfo.aAAServerTrustRoot.entrySet(); 141 i = set.iterator(); 142 if (i.hasNext()) { 143 Map.Entry entry3 = (Map.Entry) i.next(); 144 WifiPasspointDmTree.AAAServerTrustRoot aaa = (WifiPasspointDmTree.AAAServerTrustRoot) entry3.getValue(); 145 mAAACertURL = aaa.CertURL; 146 mAAASha256Fingerprint = aaa.CertSHA256Fingerprint; 147 } 148 149 mCertType = credinfo.credential.digitalCertificate.CertificateType; 150 mCertSha256Fingerprint = credinfo.credential.digitalCertificate.CertSHA256Fingerprint; 151 mUsername = credinfo.credential.usernamePassword.Username; 152 mPasswd = credinfo.credential.usernamePassword.Password; 153 mIsMachineRemediation = credinfo.credential.usernamePassword.MachineManaged; 154 mInnerMethod = credinfo.credential.usernamePassword.eAPMethod.InnerMethod; 155 mImsi = credinfo.credential.sim.IMSI; 156 mCreationDate = credinfo.credential.CreationDate; 157 mExpirationDate = credinfo.credential.ExpirationDate; 158 mRealm = credinfo.credential.Realm; 159 160 if (credinfo.credentialPriority == null) { 161 credinfo.credentialPriority = "128"; 162 } 163 mPriority = Integer.parseInt(credinfo.credentialPriority); 164 165 mHomeSpFqdn = credinfo.homeSP.FQDN; 166 167 mSubscriptionUpdateInterval = credinfo.subscriptionUpdate.UpdateInterval; 168 mSubscriptionUpdateMethod = credinfo.subscriptionUpdate.UpdateMethod; 169 mSubscriptionUpdateRestriction = credinfo.subscriptionUpdate.Restriction; 170 mSubscriptionUpdateURI = credinfo.subscriptionUpdate.URI; 171 mSubscriptionDMAccUsername = credinfo.subscriptionUpdate.usernamePassword.Username; 172 mSubscriptionDMAccPassword = credinfo.subscriptionUpdate.usernamePassword.Password; 173 174 mPolicyUpdateURI = credinfo.policy.policyUpdate.URI; 175 mPolicyUpdateInterval = credinfo.policy.policyUpdate.UpdateInterval; 176 mPolicyDMAccUsername = credinfo.policy.policyUpdate.usernamePassword.Username; 177 mPolicyDMAccPassword = credinfo.policy.policyUpdate.usernamePassword.Password; 178 mPolicyUpdateRestriction = credinfo.policy.policyUpdate.Restriction; 179 mPolicyUpdateMethod = credinfo.policy.policyUpdate.UpdateMethod; 180 mPreferredRoamingPartnerList = credinfo.policy.preferredRoamingPartnerList.values(); 181 mMinBackhaulThresholdNetwork = credinfo.policy.minBackhaulThreshold.values(); 182 mRequiredProtoPortTuple = credinfo.policy.requiredProtoPortTuple.values(); 183 mMaxBssLoad = credinfo.policy.maximumBSSLoadValue; 184 mSpExclusionList = credinfo.policy.sPExclusionList.values(); 185 186 mHomeOIList = credinfo.homeSP.homeOIList.values(); 187 mFriendlyName = credinfo.homeSP.FriendlyName; 188 mCheckAaaServerCertStatus = credinfo.credential.CheckAAAServerCertStatus; 189 } 190 191 /** @hide */ 192 public WifiPasspointCredential(String type, 193 String caroot, 194 String clientcert, 195 String mcc, 196 String mnc, 197 WifiPasspointDmTree.SpFqdn sp, 198 WifiPasspointDmTree.CredentialInfo credinfo) { 199 200 if (credinfo == null) { 201 return; 202 } 203 204 mType = type; 205 mCaRootCert = caroot; 206 mClientCert = clientcert; 207 208 mWifiSPFQDN = sp.nodeName; 209 mUpdateIdentifier = sp.perProviderSubscription.UpdateIdentifier; 210 211 mCredentialName = credinfo.nodeName; 212 Set set = credinfo.homeSP.otherHomePartners.entrySet(); 213 Iterator i = set.iterator(); 214 if (i.hasNext()) { 215 Map.Entry entry3 = (Map.Entry) i.next(); 216 WifiPasspointDmTree.OtherHomePartners ohp = (WifiPasspointDmTree.OtherHomePartners) entry3.getValue(); 217 mOtherhomepartnerFqdn = ohp.FQDN; 218 } 219 220 set = credinfo.aAAServerTrustRoot.entrySet(); 221 i = set.iterator(); 222 if (i.hasNext()) { 223 Map.Entry entry3 = (Map.Entry) i.next(); 224 WifiPasspointDmTree.AAAServerTrustRoot aaa = (WifiPasspointDmTree.AAAServerTrustRoot) entry3.getValue(); 225 mAAACertURL = aaa.CertURL; 226 mAAASha256Fingerprint = aaa.CertSHA256Fingerprint; 227 } 228 229 mCertType = credinfo.credential.digitalCertificate.CertificateType; 230 mCertSha256Fingerprint = credinfo.credential.digitalCertificate.CertSHA256Fingerprint; 231 mUsername = credinfo.credential.usernamePassword.Username; 232 mPasswd = credinfo.credential.usernamePassword.Password; 233 mIsMachineRemediation = credinfo.credential.usernamePassword.MachineManaged; 234 mInnerMethod = credinfo.credential.usernamePassword.eAPMethod.InnerMethod; 235 mImsi = credinfo.credential.sim.IMSI; 236 mMcc = mcc; 237 mMnc = mnc; 238 mCreationDate = credinfo.credential.CreationDate; 239 mExpirationDate = credinfo.credential.ExpirationDate; 240 mRealm = credinfo.credential.Realm; 241 242 if (credinfo.credentialPriority == null) { 243 credinfo.credentialPriority = "128"; 244 } 245 mPriority = Integer.parseInt(credinfo.credentialPriority); 246 247 mHomeSpFqdn = credinfo.homeSP.FQDN; 248 249 mSubscriptionUpdateMethod = credinfo.subscriptionUpdate.UpdateMethod; 250 mSubscriptionUpdateRestriction = credinfo.subscriptionUpdate.Restriction; 251 mSubscriptionUpdateURI = credinfo.subscriptionUpdate.URI; 252 mSubscriptionDMAccUsername = credinfo.subscriptionUpdate.usernamePassword.Username; 253 mSubscriptionDMAccPassword = credinfo.subscriptionUpdate.usernamePassword.Password; 254 255 mPolicyUpdateURI = credinfo.policy.policyUpdate.URI; 256 mPolicyUpdateInterval = credinfo.policy.policyUpdate.UpdateInterval; 257 mPolicyDMAccUsername = credinfo.policy.policyUpdate.usernamePassword.Username; 258 mPolicyDMAccPassword = credinfo.policy.policyUpdate.usernamePassword.Password; 259 mPolicyUpdateRestriction = credinfo.policy.policyUpdate.Restriction; 260 mPolicyUpdateMethod = credinfo.policy.policyUpdate.UpdateMethod; 261 mPreferredRoamingPartnerList = credinfo.policy.preferredRoamingPartnerList.values(); 262 mMinBackhaulThresholdNetwork = credinfo.policy.minBackhaulThreshold.values(); 263 mRequiredProtoPortTuple = credinfo.policy.requiredProtoPortTuple.values(); 264 mMaxBssLoad = credinfo.policy.maximumBSSLoadValue; 265 mSpExclusionList = credinfo.policy.sPExclusionList.values(); 266 267 mHomeOIList = credinfo.homeSP.homeOIList.values(); 268 mFriendlyName = credinfo.homeSP.FriendlyName; 269 } 270 271 /** @hide */ 272 public String getUpdateIdentifier() { 273 return mUpdateIdentifier; 274 } 275 276 /** @hide */ 277 public String getUpdateMethod() { 278 return mSubscriptionUpdateMethod; 279 } 280 281 /** @hide */ 282 public void setUpdateMethod(String method) { 283 mSubscriptionUpdateMethod = method; 284 } 285 286 /** @hide */ 287 public String getWifiSPFQDN() { 288 return mWifiSPFQDN; 289 } 290 291 /** @hide */ 292 public String getCredName() { 293 return mCredentialName; 294 } 295 296 /** @hide */ 297 public String getEapMethodStr() { 298 return mType; 299 } 300 301 /** 302 * Get EAP method of this Passpoint credential. 303 * @return EAP method, refer to {@link WifiEnterpriseConfig.Eap} for possible return values 304 */ 305 public int getEapMethod() { 306 return 0; 307 } 308 309 /** @hide */ 310 public String getCertType() { 311 return mCertType; 312 } 313 314 /** @hide */ 315 public String getCertSha256Fingerprint() { 316 return mCertSha256Fingerprint; 317 } 318 319 /** 320 * Get the user name of this Passpoint credential, for EAP-TTLS only. 321 * @return user name 322 */ 323 public String getUserName() { 324 return mUsername; 325 } 326 327 /** @hide */ 328 public String getPassword() { 329 // TODO: guarded by connectivity internal 330 return mPasswd; 331 } 332 333 /** @hide */ 334 public String getImsi() { 335 return mImsi; 336 } 337 338 /** @hide */ 339 public String getMcc() { 340 return mMcc; 341 } 342 343 /** @hide */ 344 public String getMnc() { 345 return mMnc; 346 } 347 348 /** 349 * Get the CA root certificate path of this Passpoint credential. 350 * @return CA root certificate path 351 */ 352 public String getCaRootCertPath() { 353 return mCaRootCert; 354 } 355 356 /** 357 * Get the client certificate path of this Passpoint credential, for EAP-TLS only. 358 * @return client certificate path 359 */ 360 public String getClientCertPath() { 361 return mClientCert; 362 } 363 364 /** 365 * Set credential information of this Passpoint credential. 366 * @param config Credential information, must be either EAP-TLS or EAP-TTLS 367 */ 368 public void setCredential(WifiEnterpriseConfig config) { 369 // TODO 370 } 371 372 /** 373 * Get the realm of this Passpoint credential. 374 * @return Realm 375 */ 376 public String getRealm() { 377 return mRealm; 378 } 379 380 /** 381 * Set the ream of this Passpoint credential. 382 * @param realm Realm 383 */ 384 public void setRealm(String realm) { 385 mRealm = realm; 386 } 387 388 /** @hide */ 389 public int getPriority() { 390 if (mUserPreferred) { 391 return 0; 392 } 393 394 return mPriority; 395 } 396 397 /** 398 * Get the fully qualified domain name (FQDN) of this Passpoint credential. 399 * @return FQDN 400 */ 401 public String getFqdn() { 402 return mHomeSpFqdn; 403 } 404 405 /** 406 * Set the fully qualified domain name (FQDN) of this Passpoint credential. 407 * @param fqdn FQDN 408 */ 409 public void setFqdn(String fqdn) { 410 mHomeSpFqdn = fqdn; 411 } 412 413 414 /** @hide */ 415 public String getOtherhomepartners() { 416 return mOtherhomepartnerFqdn; 417 } 418 419 /** @hide */ 420 public String getSubscriptionDMAccUsername() { 421 return mSubscriptionDMAccUsername; 422 } 423 424 /** @hide */ 425 public String getSubscriptionDMAccPassword() { 426 return mSubscriptionDMAccPassword; 427 } 428 429 /** @hide */ 430 public String getPolicyUpdateURI() { 431 return mPolicyUpdateURI; 432 } 433 434 /** @hide */ 435 public String getPolicyUpdateInterval() { 436 return mPolicyUpdateInterval; 437 } 438 439 /** @hide */ 440 public String getPolicyDMAccUsername() { 441 return mPolicyDMAccUsername; 442 } 443 444 /** @hide */ 445 public String getPolicyDMAccPassword() { 446 return mPolicyDMAccPassword; 447 } 448 449 /** @hide */ 450 public String getPolicyUpdateRestriction() { 451 return mPolicyUpdateRestriction; 452 } 453 454 /** @hide */ 455 public String getPolicyUpdateMethod() { 456 return mPolicyUpdateMethod; 457 } 458 459 /** @hide */ 460 public String getCreationDate() { 461 return mCreationDate; 462 } 463 464 /** @hide */ 465 public String getExpirationDate() { 466 return mExpirationDate; 467 } 468 469 /** @hide */ 470 public void setExpirationDate(String expirationdate) { 471 mExpirationDate = expirationdate; 472 } 473 474 /** @hide */ 475 public Collection<WifiPasspointDmTree.PreferredRoamingPartnerList> getPrpList() { 476 return mPreferredRoamingPartnerList; 477 } 478 479 /** @hide */ 480 public Collection<WifiPasspointDmTree.HomeOIList> getHomeOIList() { 481 return mHomeOIList; 482 } 483 484 /** @hide */ 485 public Collection<WifiPasspointDmTree.MinBackhaulThresholdNetwork> getBackhaulThresholdList() { 486 return mMinBackhaulThresholdNetwork; 487 } 488 489 /** @hide */ 490 public Collection<WifiPasspointDmTree.RequiredProtoPortTuple> getRequiredProtoPortList() { 491 return mRequiredProtoPortTuple; 492 } 493 494 /** @hide */ 495 public Collection<WifiPasspointDmTree.SPExclusionList> getSPExclusionList() { 496 return mSpExclusionList; 497 } 498 499 /** @hide */ 500 public boolean getIsMachineRemediation() { 501 return mIsMachineRemediation; 502 } 503 504 /** @hide */ 505 public String getAAACertURL() { 506 return mAAACertURL; 507 } 508 509 /** @hide */ 510 public String getAAASha256Fingerprint() { 511 return mAAASha256Fingerprint; 512 } 513 514 /** @hide */ 515 public String getSubscriptionUpdateRestriction() { 516 return mSubscriptionUpdateRestriction; 517 } 518 519 /** @hide */ 520 public String getSubscriptionUpdateURI() { 521 return mSubscriptionUpdateURI; 522 } 523 524 /** @hide */ 525 public String getSubscriptionUpdateInterval() { 526 return mSubscriptionUpdateInterval; 527 } 528 529 /** @hide */ 530 public String getFriendlyName() { 531 return mFriendlyName; 532 } 533 534 /** @hide */ 535 public String getMaxBssLoad() { 536 return mMaxBssLoad; 537 } 538 539 /** @hide */ 540 public boolean getUserPreference() { 541 return mUserPreferred; 542 } 543 544 /** @hide */ 545 public boolean getCheckAaaServerCertStatus() { 546 return mCheckAaaServerCertStatus; 547 } 548 549 /** @hide */ 550 public void setUserPreference(boolean value) { 551 mUserPreferred = value; 552 } 553 554 @Override 555 /** @hide */ 556 public boolean equals(Object obj) { 557 boolean result = false; 558 if (obj instanceof WifiPasspointCredential) { 559 final WifiPasspointCredential other = (WifiPasspointCredential) obj; 560 if (this.mType.equals(other.mType)) { 561 if (this.mType.equals("TTLS")) { 562 result = this.mUsername.equals(other.mUsername) && 563 this.mPasswd.equals(other.mPasswd) && 564 this.mRealm.equals(other.mRealm) && 565 this.mHomeSpFqdn.equals(other.mHomeSpFqdn); 566 } 567 if (this.mType.equals("TLS")) { 568 result = this.mRealm.equals(other.mRealm) && 569 this.mHomeSpFqdn.equals(other.mHomeSpFqdn); 570 } 571 if (this.mType.equals("SIM")) { 572 result = this.mMcc.equals(other.mMcc) && 573 this.mMnc.equals(other.mMnc) && 574 this.mImsi.equals(other.mImsi) && 575 this.mHomeSpFqdn.equals(other.mHomeSpFqdn); 576 } 577 } 578 } 579 return result; 580 } 581 582 @Override 583 /** @hide */ 584 public String toString() { 585 StringBuffer sb = new StringBuffer(); 586 String none = "<none>"; 587 588 sb.append(", UpdateIdentifier: ") 589 .append(mUpdateIdentifier == null ? none : mUpdateIdentifier). 590 append(", SubscriptionUpdateMethod: ") 591 .append(mSubscriptionUpdateMethod == null ? none : mSubscriptionUpdateMethod). 592 append(", Type: ").append(mType == null ? none : mType). 593 append(", Username: ").append(mUsername == null ? none : mUsername). 594 append(", Passwd: ").append(mPasswd == null ? none : mPasswd). 595 append(", SubDMAccUsername: ") 596 .append(mSubscriptionDMAccUsername == null ? none : mSubscriptionDMAccUsername). 597 append(", SubDMAccPassword: ") 598 .append(mSubscriptionDMAccPassword == null ? none : mSubscriptionDMAccPassword). 599 append(", PolDMAccUsername: ") 600 .append(mPolicyDMAccUsername == null ? none : mPolicyDMAccUsername). 601 append(", PolDMAccPassword: ") 602 .append(mPolicyDMAccPassword == null ? none : mPolicyDMAccPassword). 603 append(", Imsi: ").append(mImsi == null ? none : mImsi). 604 append(", Mcc: ").append(mMcc == null ? none : mMcc). 605 append(", Mnc: ").append(mMnc == null ? none : mMnc). 606 append(", CaRootCert: ").append(mCaRootCert == null ? none : mCaRootCert). 607 append(", Realm: ").append(mRealm == null ? none : mRealm). 608 append(", Priority: ").append(mPriority). 609 append(", Fqdn: ").append(mHomeSpFqdn == null ? none : mHomeSpFqdn). 610 append(", Otherhomepartners: ") 611 .append(mOtherhomepartnerFqdn == null ? none : mOtherhomepartnerFqdn). 612 append(", ExpirationDate: ") 613 .append(mExpirationDate == null ? none : mExpirationDate). 614 append(", MaxBssLoad: ").append(mMaxBssLoad == null ? none : mMaxBssLoad). 615 append(", SPExclusionList: ").append(mSpExclusionList); 616 617 if (mPreferredRoamingPartnerList != null) { 618 sb.append("PreferredRoamingPartnerList:"); 619 for (WifiPasspointDmTree.PreferredRoamingPartnerList prpListItem : mPreferredRoamingPartnerList) { 620 sb.append("[fqdnmatch:").append(prpListItem.FQDN_Match). 621 append(", priority:").append(prpListItem.Priority). 622 append(", country:").append(prpListItem.Country).append("]"); 623 } 624 } 625 626 if (mHomeOIList != null) { 627 sb.append("HomeOIList:"); 628 for (WifiPasspointDmTree.HomeOIList HomeOIListItem : mHomeOIList) { 629 sb.append("[HomeOI:").append(HomeOIListItem.HomeOI). 630 append(", HomeOIRequired:").append(HomeOIListItem.HomeOIRequired). 631 append("]"); 632 } 633 } 634 635 if (mMinBackhaulThresholdNetwork != null) { 636 sb.append("BackHaulThreshold:"); 637 for (WifiPasspointDmTree.MinBackhaulThresholdNetwork BhtListItem : mMinBackhaulThresholdNetwork) { 638 sb.append("[networkType:").append(BhtListItem.NetworkType). 639 append(", dlBandwidth:").append(BhtListItem.DLBandwidth). 640 append(", ulBandwidth:").append(BhtListItem.ULBandwidth). 641 append("]"); 642 } 643 } 644 645 if (mRequiredProtoPortTuple != null) { 646 sb.append("WifiMORequiredProtoPortTupleList:"); 647 for (WifiPasspointDmTree.RequiredProtoPortTuple RpptListItem : mRequiredProtoPortTuple) { 648 sb.append("[IPProtocol:").append(RpptListItem.IPProtocol). 649 append(", PortNumber:").append(RpptListItem.PortNumber). 650 append("]"); 651 } 652 } 653 654 return sb.toString(); 655 } 656 657 /** Implement the Parcelable interface {@hide} */ 658 public int describeContents() { 659 return 0; 660 } 661 662 /** Implement the Parcelable interface {@hide} */ 663 public void writeToParcel(Parcel dest, int flags) { 664 dest.writeString(mType); 665 dest.writeString(mUsername); 666 dest.writeString(mPasswd); 667 dest.writeString(mImsi); 668 dest.writeString(mMcc); 669 dest.writeString(mMnc); 670 dest.writeString(mCaRootCert); 671 dest.writeString(mRealm); 672 dest.writeInt(mPriority); 673 dest.writeString(mHomeSpFqdn); 674 dest.writeString(mOtherhomepartnerFqdn); 675 dest.writeString(mClientCert); 676 dest.writeString(mExpirationDate); 677 } 678 679 /** Implement the Parcelable interface {@hide} */ 680 public static final Creator<WifiPasspointCredential> CREATOR = 681 new Creator<WifiPasspointCredential>() { 682 public WifiPasspointCredential createFromParcel(Parcel in) { 683 WifiPasspointCredential pc = new WifiPasspointCredential(); 684 pc.mType = in.readString(); 685 pc.mUsername = in.readString(); 686 pc.mPasswd = in.readString(); 687 pc.mImsi = in.readString(); 688 pc.mMcc = in.readString(); 689 pc.mMnc = in.readString(); 690 pc.mCaRootCert = in.readString(); 691 pc.mRealm = in.readString(); 692 pc.mPriority = in.readInt(); 693 pc.mHomeSpFqdn = in.readString(); 694 pc.mOtherhomepartnerFqdn = in.readString(); 695 pc.mClientCert = in.readString(); 696 pc.mExpirationDate = in.readString(); 697 return pc; 698 } 699 700 public WifiPasspointCredential[] newArray(int size) { 701 return new WifiPasspointCredential[size]; 702 } 703 }; 704 705 /** @hide */ 706 public int compareTo(WifiPasspointCredential another) { 707 708 //The smaller the higher 709 if (mPriority < another.mPriority) { 710 return -1; 711 } else if (mPriority == another.mPriority) { 712 return this.mType.compareTo(another.mType); 713 } else { 714 return 1; 715 } 716 } 717 718 @Override 719 /** @hide */ 720 public int hashCode() { 721 int hash = 208; 722 if (mType != null) { 723 hash += mType.hashCode(); 724 } 725 if (mRealm != null) { 726 hash += mRealm.hashCode(); 727 } 728 if (mHomeSpFqdn != null) { 729 hash += mHomeSpFqdn.hashCode(); 730 } 731 if (mUsername != null) { 732 hash += mUsername.hashCode(); 733 } 734 if (mPasswd != null) { 735 hash += mPasswd.hashCode(); 736 } 737 738 return hash; 739 } 740} 741