javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/CertificateDetailsView.java
changeset 21 2a9601315dfc
child 23 98ccebc37403
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 package com.nokia.mj.impl.installer.ui.eswt2;
       
    20 
       
    21 import com.nokia.mj.impl.rt.support.ApplicationInfo;
       
    22 import com.nokia.mj.impl.security.midp.common.SigningCertificate;
       
    23 
       
    24 import org.eclipse.swt.SWT;
       
    25 import org.eclipse.swt.widgets.Composite;
       
    26 import org.eclipse.swt.widgets.Label;
       
    27 
       
    28 /**
       
    29  * CertificateDetailsView displays certificate details to the user.
       
    30  */
       
    31 public class CertificateDetailsView extends ConfirmationViewBase
       
    32 {
       
    33     private SigningCertificate[] iCerts = null;
       
    34     private int iCertIndex = 0;
       
    35 
       
    36     /** Constructor */
       
    37     protected CertificateDetailsView()
       
    38     {
       
    39         super();
       
    40     }
       
    41 
       
    42     /** Constructor */
       
    43     protected CertificateDetailsView(
       
    44         InstallerUiEswt aInstaller, Composite aParent, String aTitle,
       
    45         SigningCertificate[] aCerts, int aCertIndex)
       
    46     {
       
    47         super(aInstaller, aParent, 1, true);
       
    48         iCerts = aCerts;
       
    49         iCertIndex = aCertIndex;
       
    50         setTitle(aTitle);
       
    51         setCommands(null, InstallerUiTexts.get(InstallerUiTexts.OK));
       
    52     }
       
    53 
       
    54     /**
       
    55      * This method is called once before view is opened.
       
    56      * Inheriting class must implement this method.
       
    57      */
       
    58     protected void createView()
       
    59     {
       
    60         if (iCertIndex == -1)
       
    61         {
       
    62             createUncertifiedView();
       
    63         }
       
    64         else
       
    65         {
       
    66             createCertificateDetailsView();
       
    67         }
       
    68     }
       
    69 
       
    70     /**
       
    71      * Creates certificate details view for uncertified appliction.
       
    72      */
       
    73     private void createUncertifiedView()
       
    74     {
       
    75         int horizontalSpan = getColumns();
       
    76         int labelStyle = SWT.WRAP;
       
    77 
       
    78         // Add title label.
       
    79         Label detailsLabel = createLabel(
       
    80                                  InstallerUiTexts.get(InstallerUiTexts.NOT_CERTIFIED_TITLE),
       
    81                                  horizontalSpan, labelStyle);
       
    82         detailsLabel.setFont(iInstallerUi.getBoldFont());
       
    83 
       
    84         // Add warning label.
       
    85         Label warningLabel = createLabel(
       
    86                                  InstallerUiTexts.get(InstallerUiTexts.NOT_CERTIFIED_WARNING),
       
    87                                  horizontalSpan, labelStyle);
       
    88 
       
    89     }
       
    90 
       
    91     /**
       
    92      * Creates certificate details view.
       
    93      */
       
    94     private void createCertificateDetailsView()
       
    95     {
       
    96         int horizontalSpan = getColumns();
       
    97         int labelStyle = SWT.WRAP;
       
    98 
       
    99         // Add title label.
       
   100         Label detailsLabel = createLabel
       
   101                              (InstallerUiTexts.get
       
   102                               (InstallerUiTexts.CERTIFICATE_INFO_FOR_APP),
       
   103                               horizontalSpan, labelStyle);
       
   104         detailsLabel.setFont(iInstallerUi.getBoldFont());
       
   105 
       
   106         SigningCertificate certificate = iCerts[iCertIndex];
       
   107 
       
   108         Label domainLabel = createLabel
       
   109                             (InstallerUiTexts.get
       
   110                              (InstallerUiTexts.DOMAIN,
       
   111                               new String[] { getDomainCategoryString(certificate) }),
       
   112                              horizontalSpan, labelStyle);
       
   113 
       
   114         Label issuerLabel = createLabel
       
   115                             (InstallerUiTexts.get
       
   116                              (InstallerUiTexts.ISSUER,
       
   117                               new String[] { certificate.getFormattedIssuer() }),
       
   118                              horizontalSpan, labelStyle);
       
   119 
       
   120         Label subjectLabel = createLabel
       
   121                              (InstallerUiTexts.get
       
   122                               (InstallerUiTexts.SUBJECT,
       
   123                                new String[] { certificate.getFormattedSubject() }),
       
   124                               horizontalSpan, labelStyle);
       
   125 
       
   126         Label validFromLabel = createLabel
       
   127                                (InstallerUiTexts.get
       
   128                                 (InstallerUiTexts.VALID_FROM,
       
   129                                  new Object[] { certificate.getValidFrom() }),
       
   130                                 horizontalSpan, labelStyle);
       
   131 
       
   132         Label validUntilLabel = createLabel
       
   133                                 (InstallerUiTexts.get
       
   134                                  (InstallerUiTexts.VALID_UNTIL,
       
   135                                   new Object[] { certificate.getValidUntil() }),
       
   136                                  horizontalSpan, labelStyle);
       
   137 
       
   138         Label serialNumberLabel = createLabel
       
   139                                   (InstallerUiTexts.get
       
   140                                    (InstallerUiTexts.SERIAL_NUMBER,
       
   141                                     new String[] { certificate.getSerialNumber() }),
       
   142                                    horizontalSpan, labelStyle);
       
   143 
       
   144         Label fingerprintLabel = createLabel
       
   145                                  (InstallerUiTexts.get
       
   146                                   (InstallerUiTexts.FINGERPRINT,
       
   147                                    new String[] { certificate.getFormattedFingerprint() }),
       
   148                                   horizontalSpan, labelStyle);
       
   149     }
       
   150 
       
   151     /**
       
   152      * This method is called after user has answered
       
   153      * to confirmation.
       
   154      * Inheriting class must implement this method.
       
   155      */
       
   156     protected void getDataFromView()
       
   157     {
       
   158         // nop
       
   159     }
       
   160 
       
   161     /**
       
   162      * Returns SWT style for this view.
       
   163      */
       
   164     protected int getStyle()
       
   165     {
       
   166         return SWT.V_SCROLL;
       
   167     }
       
   168 
       
   169     /**
       
   170      * Returns localised domain category text for the given certificate.
       
   171      */
       
   172     private String getDomainCategoryString(SigningCertificate aCertificate)
       
   173     {
       
   174         String result = "";
       
   175         String domainCategory = aCertificate.getProtectionDomain().getCategory();
       
   176         if (domainCategory.equals(ApplicationInfo.MANUFACTURER_DOMAIN))
       
   177         {
       
   178             result = InstallerUiTexts.get(InstallerUiTexts.DOMAIN_MANU);
       
   179         }
       
   180         else if (domainCategory.equals(ApplicationInfo.OPERATOR_DOMAIN))
       
   181         {
       
   182             result = InstallerUiTexts.get(InstallerUiTexts.DOMAIN_OPER);
       
   183         }
       
   184         else if (domainCategory.equals(ApplicationInfo.IDENTIFIED_THIRD_PARTY_DOMAIN))
       
   185         {
       
   186             result = InstallerUiTexts.get(InstallerUiTexts.DOMAIN_ITP);
       
   187         }
       
   188         else if (domainCategory.equals(ApplicationInfo.UNIDENTIFIED_THIRD_PARTY_DOMAIN))
       
   189         {
       
   190             result = InstallerUiTexts.get(InstallerUiTexts.DOMAIN_UTP);
       
   191         }
       
   192         return result;
       
   193     }
       
   194 }