Search in sources :

Example 16 with Asn1Constructed

use of com.android.hotspot2.asn1.Asn1Constructed in project platform_frameworks_base by android.

the class SPVerifier method getImageData.

private static List<LogoTypeImage> getImageData(Asn1Object logoExtension) throws IOException {
    Asn1Constructed logo = castObject(logoExtension, Asn1Constructed.class);
    Asn1Constructed communityLogo = castObject(logo.getChildren().iterator().next(), Asn1Constructed.class);
    if (communityLogo.getTag() != 0) {
        throw new IOException("Expected tag [0] for communityLogos");
    }
    List<LogoTypeImage> images = new ArrayList<>();
    Asn1Constructed communityLogoSeq = castObject(communityLogo.getChildren().iterator().next(), Asn1Constructed.class);
    for (Asn1Object logoTypeData : communityLogoSeq.getChildren()) {
        if (logoTypeData.getTag() != 0) {
            throw new IOException("Expected tag [0] for LogotypeData");
        }
        for (Asn1Object logoTypeImage : castObject(logoTypeData.getChildren().iterator().next(), Asn1Constructed.class).getChildren()) {
            // only read the image SEQUENCE and skip any audio [1] tags
            if (logoTypeImage.getAsn1Class() == Asn1Class.Universal) {
                images.add(new LogoTypeImage(castObject(logoTypeImage, Asn1Constructed.class)));
            }
        }
    }
    return images;
}
Also used : Asn1Constructed(com.android.hotspot2.asn1.Asn1Constructed) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Asn1Object(com.android.hotspot2.asn1.Asn1Object)

Example 17 with Asn1Constructed

use of com.android.hotspot2.asn1.Asn1Constructed in project platform_frameworks_base by android.

the class SPVerifier method checkName.

private void checkName(Asn1Constructed altName) throws IOException {
    Map<String, I18Name> friendlyNames = new HashMap<>();
    for (Asn1Object name : altName.getChildren()) {
        if (name.getAsn1Class() == Asn1Class.Context && name.getTag() == OtherName) {
            Asn1Constructed otherName = (Asn1Constructed) name;
            Iterator<Asn1Object> children = otherName.getChildren().iterator();
            if (children.hasNext()) {
                Asn1Object oidObject = children.next();
                if (OidMappings.sIdWfaHotspotFriendlyName.equals(oidObject) && children.hasNext()) {
                    Asn1Constructed value = castObject(children.next(), Asn1Constructed.class);
                    String text = castObject(value.getChildren().iterator().next(), Asn1String.class).getString();
                    I18Name friendlyName = new I18Name(text);
                    friendlyNames.put(friendlyName.getLanguage(), friendlyName);
                }
            }
        }
    }
    Log.d(OSUManager.TAG, "Friendly names: " + friendlyNames.values());
    for (I18Name osuName : mOSUInfo.getOSUProvider().getNames()) {
        I18Name friendlyName = friendlyNames.get(osuName.getLanguage());
        if (!osuName.equals(friendlyName)) {
            throw new IOException("Friendly name '" + osuName + " not in certificate");
        }
    }
}
Also used : Asn1Constructed(com.android.hotspot2.asn1.Asn1Constructed) HashMap(java.util.HashMap) I18Name(com.android.anqp.I18Name) Asn1String(com.android.hotspot2.asn1.Asn1String) Asn1String(com.android.hotspot2.asn1.Asn1String) IOException(java.io.IOException) Asn1Object(com.android.hotspot2.asn1.Asn1Object)

Example 18 with Asn1Constructed

use of com.android.hotspot2.asn1.Asn1Constructed in project platform_frameworks_base by android.

the class SPVerifier method getExtension.

private static Asn1Object getExtension(X509Certificate certificate, String extension) throws GeneralSecurityException, IOException {
    byte[] data = certificate.getExtensionValue(extension);
    if (data == null) {
        return null;
    }
    Asn1Octets octetString = (Asn1Octets) Asn1Decoder.decode(ByteBuffer.wrap(data)).iterator().next();
    Asn1Constructed sequence = castObject(Asn1Decoder.decode(ByteBuffer.wrap(octetString.getOctets())).iterator().next(), Asn1Constructed.class);
    Log.d(OSUManager.TAG, "Extension " + extension + ": " + sequence);
    return sequence;
}
Also used : Asn1Constructed(com.android.hotspot2.asn1.Asn1Constructed) Asn1Octets(com.android.hotspot2.asn1.Asn1Octets)

Example 19 with Asn1Constructed

use of com.android.hotspot2.asn1.Asn1Constructed in project android_frameworks_base by AOSPA.

the class SPVerifier method getImageData.

private static List<LogoTypeImage> getImageData(Asn1Object logoExtension) throws IOException {
    Asn1Constructed logo = castObject(logoExtension, Asn1Constructed.class);
    Asn1Constructed communityLogo = castObject(logo.getChildren().iterator().next(), Asn1Constructed.class);
    if (communityLogo.getTag() != 0) {
        throw new IOException("Expected tag [0] for communityLogos");
    }
    List<LogoTypeImage> images = new ArrayList<>();
    Asn1Constructed communityLogoSeq = castObject(communityLogo.getChildren().iterator().next(), Asn1Constructed.class);
    for (Asn1Object logoTypeData : communityLogoSeq.getChildren()) {
        if (logoTypeData.getTag() != 0) {
            throw new IOException("Expected tag [0] for LogotypeData");
        }
        for (Asn1Object logoTypeImage : castObject(logoTypeData.getChildren().iterator().next(), Asn1Constructed.class).getChildren()) {
            // only read the image SEQUENCE and skip any audio [1] tags
            if (logoTypeImage.getAsn1Class() == Asn1Class.Universal) {
                images.add(new LogoTypeImage(castObject(logoTypeImage, Asn1Constructed.class)));
            }
        }
    }
    return images;
}
Also used : Asn1Constructed(com.android.hotspot2.asn1.Asn1Constructed) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Asn1Object(com.android.hotspot2.asn1.Asn1Object)

Example 20 with Asn1Constructed

use of com.android.hotspot2.asn1.Asn1Constructed in project android_frameworks_base by AOSPA.

the class SPVerifier method checkName.

private void checkName(Asn1Constructed altName) throws IOException {
    Map<String, I18Name> friendlyNames = new HashMap<>();
    for (Asn1Object name : altName.getChildren()) {
        if (name.getAsn1Class() == Asn1Class.Context && name.getTag() == OtherName) {
            Asn1Constructed otherName = (Asn1Constructed) name;
            Iterator<Asn1Object> children = otherName.getChildren().iterator();
            if (children.hasNext()) {
                Asn1Object oidObject = children.next();
                if (OidMappings.sIdWfaHotspotFriendlyName.equals(oidObject) && children.hasNext()) {
                    Asn1Constructed value = castObject(children.next(), Asn1Constructed.class);
                    String text = castObject(value.getChildren().iterator().next(), Asn1String.class).getString();
                    I18Name friendlyName = new I18Name(text);
                    friendlyNames.put(friendlyName.getLanguage(), friendlyName);
                }
            }
        }
    }
    Log.d(OSUManager.TAG, "Friendly names: " + friendlyNames.values());
    for (I18Name osuName : mOSUInfo.getOSUProvider().getNames()) {
        I18Name friendlyName = friendlyNames.get(osuName.getLanguage());
        if (!osuName.equals(friendlyName)) {
            throw new IOException("Friendly name '" + osuName + " not in certificate");
        }
    }
}
Also used : Asn1Constructed(com.android.hotspot2.asn1.Asn1Constructed) HashMap(java.util.HashMap) I18Name(com.android.anqp.I18Name) Asn1String(com.android.hotspot2.asn1.Asn1String) Asn1String(com.android.hotspot2.asn1.Asn1String) IOException(java.io.IOException) Asn1Object(com.android.hotspot2.asn1.Asn1Object)

Aggregations

Asn1Constructed (com.android.hotspot2.asn1.Asn1Constructed)20 Asn1Object (com.android.hotspot2.asn1.Asn1Object)20 IOException (java.io.IOException)20 ByteBuffer (java.nio.ByteBuffer)10 X509Certificate (java.security.cert.X509Certificate)10 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 I18Name (com.android.anqp.I18Name)5 Asn1Integer (com.android.hotspot2.asn1.Asn1Integer)5 Asn1Octets (com.android.hotspot2.asn1.Asn1Octets)5 Asn1String (com.android.hotspot2.asn1.Asn1String)5 HTTPHandler (com.android.hotspot2.osu.HTTPHandler)5 HTTPResponse (com.android.hotspot2.utils.HTTPResponse)5 DERBitString (com.android.org.bouncycastle.asn1.DERBitString)5 DERIA5String (com.android.org.bouncycastle.asn1.DERIA5String)5 DERPrintableString (com.android.org.bouncycastle.asn1.DERPrintableString)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 URL (java.net.URL)5 CertificateFactory (java.security.cert.CertificateFactory)5