Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5106476b authored by Brian Carlstrom's avatar Brian Carlstrom Committed by Android (Google) Code Review
Browse files

Merge "Moving ssl_certificate layout, resources, and helper code to...

Merge "Moving ssl_certificate layout, resources, and helper code to SslCertificate Add IKeyChainService.deleteCaCertificate"
parents da1fa1e4 6da00334
Loading
Loading
Loading
Loading
+74 −8
Original line number Diff line number Diff line
@@ -16,15 +16,19 @@

package android.net.http;

import android.content.Context;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import java.security.cert.X509Certificate;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;

import java.security.cert.X509Certificate;

import com.android.org.bouncycastle.asn1.DERObjectIdentifier;
import com.android.org.bouncycastle.asn1.x509.X509Name;

@@ -108,8 +112,10 @@ public class SslCertificate {
     * Creates a new SSL certificate object
     * @param issuedTo The entity this certificate is issued to
     * @param issuedBy The entity that issued this certificate
     * @param validNotBefore The not-before date from the certificate validity period in ISO 8601 format
     * @param validNotAfter The not-after date from the certificate validity period in ISO 8601 format
     * @param validNotBefore The not-before date from the certificate
     *     validity period in ISO 8601 format
     * @param validNotAfter The not-after date from the certificate
     *     validity period in ISO 8601 format
     * @deprecated Use {@link #SslCertificate(X509Certificate)}
     */
    @Deprecated
@@ -202,9 +208,8 @@ public class SslCertificate {
     * @return A string representation of this certificate for debugging
     */
    public String toString() {
        return
            "Issued to: " + mIssuedTo.getDName() + ";\n" +
            "Issued by: " + mIssuedBy.getDName() + ";\n";
        return ("Issued to: " + mIssuedTo.getDName() + ";\n"
                + "Issued by: " + mIssuedBy.getDName() + ";\n");
    }

    /**
@@ -328,4 +333,65 @@ public class SslCertificate {
            return mUName != null ? mUName : "";
        }
    }

    /**
     * Inflates the SSL certificate view (helper method).
     * @return The resultant certificate view with issued-to, issued-by,
     * issued-on, expires-on, and possibly other fields set.
     * If the input certificate is null, returns null.
     *
     * @hide Used by Browser and Settings
     */
    public View inflateCertificateView(Context context) {
        LayoutInflater factory = LayoutInflater.from(context);

        View certificateView = factory.inflate(
            com.android.internal.R.layout.ssl_certificate, null);

        // issued to:
        SslCertificate.DName issuedTo = getIssuedTo();
        if (issuedTo != null) {
            ((TextView) certificateView.findViewById(com.android.internal.R.id.to_common))
                .setText(issuedTo.getCName());
            ((TextView) certificateView.findViewById(com.android.internal.R.id.to_org))
                .setText(issuedTo.getOName());
            ((TextView) certificateView.findViewById(com.android.internal.R.id.to_org_unit))
                .setText(issuedTo.getUName());
        }

        // issued by:
        SslCertificate.DName issuedBy = getIssuedBy();
        if (issuedBy != null) {
            ((TextView) certificateView.findViewById(com.android.internal.R.id.by_common))
                .setText(issuedBy.getCName());
            ((TextView) certificateView.findViewById(com.android.internal.R.id.by_org))
                .setText(issuedBy.getOName());
            ((TextView) certificateView.findViewById(com.android.internal.R.id.by_org_unit))
                .setText(issuedBy.getUName());
        }

        // issued on:
        String issuedOn = formatCertificateDate(context, getValidNotBeforeDate());
        ((TextView) certificateView.findViewById(com.android.internal.R.id.issued_on))
            .setText(issuedOn);

        // expires on:
        String expiresOn = formatCertificateDate(context, getValidNotAfterDate());
        ((TextView) certificateView.findViewById(com.android.internal.R.id.expires_on))
            .setText(expiresOn);

        return certificateView;
    }

    /**
     * Formats the certificate date to a properly localized date string.
     * @return Properly localized version of the certificate date string and
     * the "" if it fails to localize.
     */
    private String formatCertificateDate(Context context, Date certificateDate) {
        if (certificateDate == null) {
            return "";
        }
        return DateFormat.getDateFormat(context).format(certificateDate);
    }
}
+228 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <!-- Placeholder for the success message or one or more warnings -->
        <LinearLayout
            android:id="@+id/placeholder"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_marginTop="12dip"
            android:orientation="vertical" />

        <!-- Dialog-title line separator -->
        <ImageView
            android:id="@+id/title_separator"
            android:src="@android:drawable/divider_horizontal_dark"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitXY"
            android:layout_weight="1"
            android:gravity="fill_horizontal"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_marginBottom="12dip" />

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:shrinkColumns="1"
            android:orientation="vertical">

            <!-- Issued to: -->
            <TextView
                android:id="@+id/issued_to_header"
                android:text="@string/issued_to"
                android:textStyle="bold"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="7dip" />

            <!-- Common name: -->
            <TableRow>
                <TextView
                    android:id="@+id/to_common_header"
                    android:text="@string/common_name"
                    android:gravity="left"
                    android:layout_marginLeft="20dip" />

                <TextView
                    android:id="@+id/to_common"
                    android:gravity="left"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="20dip"
                    android:layout_marginBottom="7dip" />
            </TableRow>

            <!-- Organization: -->
            <TableRow>
                <TextView
                    android:id="@+id/to_org_header"
                    android:text="@string/org_name"
                    android:gravity="left"
                    android:layout_marginLeft="20dip" />

                <TextView
                    android:id="@+id/to_org"
                    android:gravity="left"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="20dip"
                    android:layout_marginBottom="7dip" />
            </TableRow>

            <!-- Organizational unit: -->
            <TableRow>
                <TextView
                    android:id="@+id/to_org_unit_header"
                    android:text="@string/org_unit"
                    android:gravity="left"
                    android:layout_marginLeft="20dip" />

                <TextView
                    android:id="@+id/to_org_unit"
                    android:gravity="left"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="20dip"
                    android:layout_marginBottom="12dip" />
            </TableRow>

            <!-- Issued by: -->
            <TextView
                android:id="@+id/issued_to_header"
                android:text="@string/issued_by"
                android:textStyle="bold"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="7dip" />

            <!-- Common name: -->
            <TableRow>
                <TextView
                    android:id="@+id/by_common_header"
                    android:text="@string/common_name"
                    android:gravity="left"
                    android:layout_marginLeft="20dip" />

                <TextView
                    android:id="@+id/by_common"
                    android:gravity="left"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="20dip"
                    android:layout_marginBottom="7dip" />
            </TableRow>

            <!-- Organization: -->
            <TableRow>
                <TextView
                    android:id="@+id/by_org_header"
                    android:text="@string/org_name"
                    android:gravity="left"
                    android:layout_marginLeft="20dip" />

                <TextView
                    android:id="@+id/by_org"
                    android:gravity="left"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="20dip"
                    android:layout_marginBottom="7dip" />
            </TableRow>

            <!-- Organizational unit: -->
            <TableRow>
                <TextView
                    android:id="@+id/by_org_unit_header"
                    android:text="@string/org_unit"
                    android:gravity="left"
                    android:layout_marginLeft="20dip" />

                <TextView
                    android:id="@+id/by_org_unit"
                    android:gravity="left"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="20dip"
                    android:layout_marginBottom="12dip" />
            </TableRow>

            <!-- Validity Dates: -->
            <TextView
                android:id="@+id/validity_header"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/validity_period"
                android:textStyle="bold"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="7dip" />

            <!-- Issued On: -->
            <TableRow>
                <TextView
                    android:id="@+id/issued_on_header"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/issued_on"
                    android:gravity="left"
                    android:layout_marginLeft="20dip" />

                <TextView
                    android:id="@+id/issued_on"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:gravity="left"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="20dip"
                    android:layout_marginBottom="7dip" />

            </TableRow>

            <!-- Expires On: -->
            <TableRow>
                <TextView
                    android:id="@+id/expires_on_header"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/expires_on"
                    android:gravity="left"
                    android:layout_marginLeft="20dip" />

                <TextView
                    android:id="@+id/expires_on"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:gravity="left"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="20dip"
                    android:layout_marginBottom="12dip" />
            </TableRow>

        </TableLayout>

    </LinearLayout>

</ScrollView>
+242 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <!-- Placeholder for the success message or one or more warnings -->
        <LinearLayout
            android:id="@+id/placeholder"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_marginTop="12dip"
            android:orientation="vertical" />

        <!-- Dialog-title line separator -->
        <ImageView
            android:id="@+id/title_separator"
            android:src="@android:drawable/divider_horizontal_dark"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitXY"
            android:layout_weight="1"
            android:gravity="fill_horizontal"
            android:layout_marginRight="20dip"
            android:layout_marginLeft="20dip"
            android:layout_marginBottom="12dip" />

        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <!-- Issued to: -->
            <TextView
                android:id="@+id/issued_to_header"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/issued_to"
                android:textStyle="bold"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="10dip" />

            <!-- Common name: -->
            <TextView
                android:id="@+id/to_common_header"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/common_name"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip" />

            <TextView
                android:id="@+id/to_common"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="10dip" />

            <!-- Organization: -->
            <TextView
                android:id="@+id/to_org_header"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/org_name"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip" />

            <TextView
                android:id="@+id/to_org"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="10dip" />

            <!-- Organizational unit: -->
            <TextView
                android:id="@+id/to_org_unit_header"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/org_unit"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip" />

            <TextView
                android:id="@+id/to_org_unit"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="12dip" />

            <!-- Issued by: -->
            <TextView
                android:id="@+id/issued_to_header"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/issued_by"
                android:textStyle="bold"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="10dip" />

            <!-- Common name: -->
            <TextView
                android:id="@+id/by_common_header"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/common_name"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip" />

            <TextView
                android:id="@+id/by_common"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="10dip" />

            <!-- Organization: -->
            <TextView
                android:id="@+id/by_org_header"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/org_name"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip" />

            <TextView
                android:id="@+id/by_org"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="10dip" />

            <!-- Organizational unit: -->
            <TextView
                android:id="@+id/by_org_unit_header"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/org_unit"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip" />

            <TextView
                android:id="@+id/by_org_unit"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="12dip" />

            <!-- Validity Dates: -->
            <TextView
                android:id="@+id/validity_header"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:text="@string/validity_period"
                android:textStyle="bold"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="10dip" />

            <!-- Issued On: -->
            <TextView
                android:id="@+id/issued_on_header"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/issued_on"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip" />

            <TextView
                android:id="@+id/issued_on"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="10dip" />

            <!-- Expires On: -->
            <TextView
                android:id="@+id/expires_on_header"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/expires_on"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip" />

            <TextView
                android:id="@+id/expires_on"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:gravity="left"
                android:layout_marginLeft="20dip"
                android:layout_marginRight="20dip"
                android:layout_marginBottom="12dip" />

        </TableLayout>

    </LinearLayout>

</ScrollView>
+10 −0
Original line number Diff line number Diff line
@@ -1106,4 +1106,14 @@
    <skip />
    <!-- no translation found for data_usage_limit_body (2182247539226163759) -->
    <skip />
    <string name="ssl_certificate" msgid="5226747157992111668">"شهادة الأمان"</string>
    <string name="ssl_certificate_is_valid" msgid="7096160815933145579">"هذه الشهادة صالحة."</string>
    <string name="issued_to" msgid="9032338008819841339">"تم الإصدار إلى:"</string>
    <string name="common_name" msgid="5745530093500062357">"الاسم الشائع:"</string>
    <string name="org_name" msgid="8868889052889991293">"المؤسسة:"</string>
    <string name="org_unit" msgid="4489056376307768196">"وحدة تنظيمية:"</string>
    <string name="issued_by" msgid="6959484326943152487">"تم الإصدار بواسطة:"</string>
    <string name="validity_period" msgid="57988851973181309">"الصلاحية:"</string>
    <string name="issued_on" msgid="2082890654801808368">"تم الإصدار في:"</string>
    <string name="expires_on" msgid="8061200430557020704">"تنتهي الصلاحية في:"</string>
</resources>
+10 −0
Original line number Diff line number Diff line
@@ -1106,4 +1106,14 @@
    <skip />
    <!-- no translation found for data_usage_limit_body (2182247539226163759) -->
    <skip />
    <string name="ssl_certificate" msgid="5226747157992111668">"Сертификат за сигурност"</string>
    <string name="ssl_certificate_is_valid" msgid="7096160815933145579">"Сертификатът е валиден."</string>
    <string name="issued_to" msgid="9032338008819841339">"Издаден на:"</string>
    <string name="common_name" msgid="5745530093500062357">"Общо име:"</string>
    <string name="org_name" msgid="8868889052889991293">"Организация:"</string>
    <string name="org_unit" msgid="4489056376307768196">"Организационна единица:"</string>
    <string name="issued_by" msgid="6959484326943152487">"Издаден от:"</string>
    <string name="validity_period" msgid="57988851973181309">"Валидност:"</string>
    <string name="issued_on" msgid="2082890654801808368">"Издаден на:"</string>
    <string name="expires_on" msgid="8061200430557020704">"Изтича на:"</string>
</resources>
Loading