1 package com.android.hotspot2.osu.commands; 2 3 import com.android.hotspot2.omadm.OMAException; 4 import com.android.hotspot2.omadm.XMLNode; 5 6 import java.util.ArrayList; 7 import java.util.List; 8 9 /* 10 <xsd:element name="useClientCertTLS"> 11 <xsd:annotation> 12 <xsd:documentation>Command to mobile to re-negotiate the TLS connection using a client certificate of the accepted type or Issuer to authenticate with the Subscription server.</xsd:documentation> 13 </xsd:annotation> 14 <xsd:complexType> 15 <xsd:sequence> 16 <xsd:element name="providerIssuerName" minOccurs="0" 17 maxOccurs="unbounded"> 18 <xsd:complexType> 19 <xsd:attribute name="name" type="xsd:string"> 20 <xsd:annotation> 21 <xsd:documentation>The issuer name of an acceptable provider-issued certificate. The text of this element is formatted in accordance with the Issuer Name field in RFC-3280. This element is present only when acceptProviderCerts is true.</xsd:documentation> 22 </xsd:annotation> 23 </xsd:attribute> 24 <xsd:anyAttribute namespace="##other"/> 25 </xsd:complexType> 26 </xsd:element> 27 <xsd:any namespace="##other" minOccurs="0" 28 maxOccurs="unbounded"/> 29 </xsd:sequence> 30 <xsd:attribute name="acceptMfgCerts" type="xsd:boolean" 31 use="optional" default="false"> 32 <xsd:annotation> 33 <xsd:documentation>When this boolean is true, IEEE 802.1ar manufacturing certificates are acceptable for mobile device authentication.</xsd:documentation> 34 </xsd:annotation> 35 </xsd:attribute> 36 <xsd:attribute name="acceptProviderCerts" type="xsd:boolean" 37 use="optional" default="true"> 38 <xsd:annotation> 39 <xsd:documentation>When this boolean is true, X509v3 certificates issued by providers identified in the providerIssuerName child element(s) are acceptable for mobile device authentication.</xsd:documentation> 40 </xsd:annotation> 41 </xsd:attribute> 42 <xsd:anyAttribute namespace="##other"/> 43 </xsd:complexType> 44 </xsd:element> 45 */ 46 47 public class ClientCertInfo implements OSUCommandData { 48 private final boolean mAcceptMfgCerts; 49 private final boolean mAcceptProviderCerts; 50 /* 51 * The issuer name of an acceptable provider-issued certificate. 52 * The text of this element is formatted in accordance with the Issuer Name field in RFC-3280. 53 * This element is present only when acceptProviderCerts is true. 54 */ 55 private final List<String> mIssuerNames; 56 57 public ClientCertInfo(XMLNode commandNode) throws OMAException { 58 mAcceptMfgCerts = Boolean.parseBoolean(commandNode.getAttributeValue("acceptMfgCerts")); 59 mAcceptProviderCerts = 60 Boolean.parseBoolean(commandNode.getAttributeValue("acceptProviderCerts")); 61 62 if (mAcceptMfgCerts) { 63 mIssuerNames = new ArrayList<>(); 64 for (XMLNode node : commandNode.getChildren()) { 65 if (node.getStrippedTag().equals("providerIssuerName")) { 66 mIssuerNames.add(node.getAttributeValue("name")); 67 } 68 } 69 } else { 70 mIssuerNames = null; 71 } 72 } 73 74 public boolean doesAcceptMfgCerts() { 75 return mAcceptMfgCerts; 76 } 77 78 public boolean doesAcceptProviderCerts() { 79 return mAcceptProviderCerts; 80 } 81 82 public List<String> getIssuerNames() { 83 return mIssuerNames; 84 } 85 86 @Override 87 public String toString() { 88 return "ClientCertInfo{" + 89 "acceptMfgCerts=" + mAcceptMfgCerts + 90 ", acceptProviderCerts=" + mAcceptProviderCerts + 91 ", issuerNames=" + mIssuerNames + 92 '}'; 93 } 94 } 95