SIGN: Added new certificate policy 74/16874/3
authorJihoon Song <jihoon80.song@samsung.com>
Tue, 25 Feb 2014 11:34:19 +0000 (20:34 +0900)
committerJihoon Song <jihoon80.song@samsung.com>
Wed, 26 Feb 2014 09:30:48 +0000 (18:30 +0900)
Change-Id: I1d19b060dce354030966f3379da6f04b74da6e01
Signed-off-by: Jihoon Song <jihoon80.song@samsung.com>
13 files changed:
org.tizen.common.sign/META-INF/MANIFEST.MF
org.tizen.common.sign/build.properties
org.tizen.common.sign/certForEmul/author_signer.p12 [new file with mode: 0644]
org.tizen.common.sign/certForEmul/partner_signer.p12 [new file with mode: 0644]
org.tizen.common.sign/certForEmul/password.txt [new file with mode: 0644]
org.tizen.common.sign/certForEmul/platform_signer.p12 [new file with mode: 0644]
org.tizen.common.sign/certForEmul/public_signer.crt [new file with mode: 0644]
org.tizen.common.sign/src/org/tizen/common/sign/model/SignatureConstants.java
org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningPreferencePage.java
org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningProfile.java
org.tizen.common.sign/src/org/tizen/common/sign/signer/SignatureGenerator.java
org.tizen.common.sign/src/org/tizen/common/sign/util/SigningPathUtil.java
org.tizen.common.sign/src/org/tizen/common/sign/util/SigningProfileUtil.java

index e7fbb72..c03e960 100644 (file)
@@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.ui,
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Import-Package: org.eclipse.core.resources,
- org.eclipse.ui.actions
+ org.eclipse.ui.actions,
+ org.tizen.sdblib
 Bundle-Vendor: %Bundle-Vendor
 Export-Package: org.tizen.common.sign,
  org.tizen.common.sign.command,
index cf85054..62a87dc 100644 (file)
@@ -6,4 +6,5 @@ bin.includes = plugin.xml,\
                OSGI-INF/,\
                about_files/,\
                about.html,\
-               lib/
+               lib/,\
+               certForEmul/
diff --git a/org.tizen.common.sign/certForEmul/author_signer.p12 b/org.tizen.common.sign/certForEmul/author_signer.p12
new file mode 100644 (file)
index 0000000..8531d5d
Binary files /dev/null and b/org.tizen.common.sign/certForEmul/author_signer.p12 differ
diff --git a/org.tizen.common.sign/certForEmul/partner_signer.p12 b/org.tizen.common.sign/certForEmul/partner_signer.p12
new file mode 100644 (file)
index 0000000..3e462df
Binary files /dev/null and b/org.tizen.common.sign/certForEmul/partner_signer.p12 differ
diff --git a/org.tizen.common.sign/certForEmul/password.txt b/org.tizen.common.sign/certForEmul/password.txt
new file mode 100644 (file)
index 0000000..edc44a2
--- /dev/null
@@ -0,0 +1,7 @@
+developertest\r
+\r
+platfromtest\r
+\r
+partnertest\r
+\r
+publictest\r
diff --git a/org.tizen.common.sign/certForEmul/platform_signer.p12 b/org.tizen.common.sign/certForEmul/platform_signer.p12
new file mode 100644 (file)
index 0000000..f556030
Binary files /dev/null and b/org.tizen.common.sign/certForEmul/platform_signer.p12 differ
diff --git a/org.tizen.common.sign/certForEmul/public_signer.crt b/org.tizen.common.sign/certForEmul/public_signer.crt
new file mode 100644 (file)
index 0000000..9ba61fb
--- /dev/null
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIIEDTCCAvWgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBuTELMAkGA1UEBhMCS1Ix
+FDASBgNVBAgMC1NvdXRoIEtvcmVhMQ4wDAYDVQQHDAVTdXdvbjEmMCQGA1UECgwd
+U2Ftc3VuZyBFbGVjdHJvbmljcyBDby4sIEx0ZC4xDzANBgNVBAsMBk1vYmlsZTEk
+MCIGA1UEAwwbU2Ftc3VuZ1Rlc3QgUHVibGljIENBIENsYXNzMSUwIwYJKoZIhvcN
+AQkBFhZtLnNlY3VyaXR5QHNhbXN1bmcuY29tMB4XDTEyMTIzMDE1MDAxOFoXDTE0
+MTIzMDE1MDAxOFowgb0xCzAJBgNVBAYTAktSMRQwEgYDVQQIDAtTb3V0aCBLb3Jl
+YTEOMAwGA1UEBwwFU3V3b24xJjAkBgNVBAoMHVNhbXN1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 public interface SignatureConstants {
     
     // for preference store
     public static final String DEFAULT_PROFILE_KEY = "defaultprofile";
+    public static final String NEW_POLICY = "newpolicy";
     
     public static final String PROFILES_FILE = "profiles.xml";
     
index fb6356c..d5eee8c 100755 (executable)
@@ -52,6 +52,7 @@ import org.eclipse.jface.dialogs.IInputValidator;
 import org.eclipse.jface.dialogs.InputDialog;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.viewers.*;
@@ -59,6 +60,7 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ControlAdapter;
 import org.eclipse.swt.events.ControlEvent;
 import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Font;
@@ -147,6 +149,9 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP
         Composite composite = createComposite(
                 parent, SWT.NONE, createGridLayout( 1 ), new GridData( GridData.FILL_BOTH ) );
         
+        if ( SigningProfileUtil.isExistNewCertPlugin() ) {
+            createNewCertControl( composite );
+        }
         createProfilesControl( composite );
         createAuthorControl( composite );
         createDistributorControl( composite );
@@ -192,6 +197,25 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP
                 parent, SWT.NONE, new GridLayout( 2, false ), new GridData( GridData.FILL_HORIZONTAL ) );
     }
     
+    protected void createNewCertControl(Composite parent) {
+        final Button checkBox = new Button( parent, SWT.CHECK );
+        checkBox.setText( "Enable new certificate policy.\nCaution! If change this, reuse of current profiles become impossible." );
+        final IPreferenceStore store = SigningProfileUtil.getPreferenceStore();
+        checkBox.setSelection( store.getBoolean( SignatureConstants.NEW_POLICY ) );
+        checkBox.addSelectionListener( new SelectionAdapter(){
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                store.setValue( SignatureConstants.NEW_POLICY, checkBox.getSelection() );
+                syncEnableButtons();
+            }
+            
+            @Override
+            public void widgetDefaultSelected(SelectionEvent e) {
+                checkBox.setSelection( store.getBoolean( SignatureConstants.NEW_POLICY ) );
+            }
+        } );
+    }
+    
     /**
      * Profile list group creator
      * <ul>
@@ -298,9 +322,26 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP
         return profileListComposite;
     }
     
+    protected void syncEnableButtons() {
+        for ( Button button : this.profileDependsButtons ) {
+            if ( button != null ) {
+                if ( ! "Generate".equals( button.getText() ) ) {
+                    enableButtons( button.getEnabled() );
+                    return;
+                }
+            }
+        }
+    }
+    
     protected void enableButtons(boolean isEnable) {
         for ( Button button : this.profileDependsButtons ) {
             if ( button != null ) {
+                if ( SigningProfileUtil.isExistNewCertPlugin() ) {
+                    if ( "Generate".equals( button.getText() ) ) {
+                        button.setEnabled( ! SigningProfileUtil.isAvailableNewCertPolicy() );
+                        continue;
+                    }
+                }
                 button.setEnabled( isEnable );
             }
         }
index 75bedb7..3d3d6f3 100644 (file)
@@ -312,7 +312,7 @@ public class SigningProfile {
         return createProfileItem(
                 1, // distributor 1
                 SigningPathUtil.getDeveloperKeyPath(),
-                SigningPathUtil.DISTRIBUTOR1_PWD,
+                SigningPathUtil.getDeveloperKeyPassword(),
                 SigningPathUtil.getDeveloperCAPath(),
                 StringUtil.EMPTY_STRING
                 );
index 2c28949..52b6677 100644 (file)
@@ -42,8 +42,12 @@ import org.tizen.common.sign.preferences.Messages;
 import org.tizen.common.sign.preferences.SigningProfile;
 import org.tizen.common.sign.preferences.SigningProfileItem;
 import org.tizen.common.sign.preferences.UIMessages;
+import org.tizen.common.sign.util.SigningPathUtil;
 import org.tizen.common.sign.util.SigningProfileUtil;
+import org.tizen.common.util.ArrayUtil;
 import org.tizen.common.util.StringUtil;
+import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.SmartDevelopmentBridge;
 
 
 /**
@@ -62,6 +66,7 @@ public class SignatureGenerator {
     
     protected boolean bRDS = false;
     
+    protected String deviceSerialNumber;
     
     // Constructor
     public SignatureGenerator() {
@@ -78,6 +83,49 @@ public class SignatureGenerator {
         return this.pStore.getString( SignatureConstants.DEFAULT_PROFILE_KEY );
     }
     
+    
+    protected boolean hasAvailableDevice() {
+        IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
+        return ! ArrayUtil.isEmpty( devices );
+    }
+    
+    protected boolean isEmulator(String deviceSerialNumber) {
+        if ( StringUtil.isEmpty( deviceSerialNumber ) ) {
+            return false;
+        }
+        
+        IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
+        if ( ! ArrayUtil.isEmpty( devices ) ) {
+            for ( IDevice device : devices ) {
+                if ( device.getSerialNumber().equals( deviceSerialNumber ) ) {
+                    return device.isEmulator();
+                }
+            }
+        }
+        
+        return false;
+    }
+    
+    public void setDeviceSerialNumber(String deviceSerialNumber) {
+        this.deviceSerialNumber = deviceSerialNumber;
+    }
+    
+    protected SigningProfile getEmulatorProfile() {
+        SigningProfile profile = new SigningProfile( "emulator default" );
+        
+        profile.createProfileItem( 0,
+                SigningPathUtil.getAuthorKeyPathForEmul(),
+                SigningPathUtil.getAuthorPasswordForEmul(),
+                "", "" );
+        
+        profile.createProfileItem( 1,
+                SigningPathUtil.getDistributorKeyPathForEmul(),
+                SigningPathUtil.getDistributorPasswordForEmul(),
+                "", "" );
+        
+        return profile;
+    }
+    
     /**
      * Load activated profile items with a developer profile from profiles.xml
      * If cannot find a key location in the author certificate, pop up the error dialog with a preference link.
@@ -86,6 +134,16 @@ public class SignatureGenerator {
      * @throws IOException
      */
     public SigningProfile loadProfiles() throws IOException {
+        // Enable by new certification policy
+        if ( SigningProfileUtil.isAvailableNewCertPolicy() ) {
+            if ( hasAvailableDevice() ) {
+                if ( isEmulator( this.deviceSerialNumber ) ) {
+                    // If selected device is an emulator, use default certificates.
+                    return getEmulatorProfile();
+                }
+            }
+        }
+        
         SigningProfile profile = null;
         
         while ( getInsertSignatureOption() ) {
@@ -119,6 +177,14 @@ public class SignatureGenerator {
                         break;
                     }
                 }
+            } else {
+                // Enable by new certification policy
+                if ( SigningProfileUtil.isAvailableNewCertPolicy() ) {
+                    if ( ! hasAvailableDevice() ) {
+                        // If no device and doesn't have a profile, use default certificates.
+                        return getEmulatorProfile();
+                    }
+                }
             }
             
             // interact user for setting profiles
index faafea2..0d20896 100644 (file)
@@ -26,6 +26,7 @@ package org.tizen.common.sign.util;
 
 import org.tizen.common.core.application.InstallPathConfig;
 import org.tizen.common.util.FileUtil;
+import org.tizen.common.util.StringUtil;
 
 public class SigningPathUtil {
 
@@ -40,7 +41,17 @@ public class SigningPathUtil {
     public static final String DISTRIBUTOR1_PWD = "tizenpkcs12passfordsigner";
     public static final String SIGNATURE_DIRECTORY = ".sign";
     
+    public static final String EMUL_AUTHOR_P12 = "author_signer.p12";
+    public static final String EMUL_AUTHOR_PWD = "developertest";
+    public static final String EMUL_DISTRIBUTOR1_P12 = "public_signing.p12";
+    public static final String EMUL_DISTRIBUTOR1_PWD = "publictest";
+    
+    
     public static String getAuthorCAPath() {
+        if ( SigningProfileUtil.isAvailableNewCertPolicy() ) {
+            return StringUtil.EMPTY_STRING;
+        }
+        
         String result = FileUtil.appendPath(InstallPathConfig.getSDKPath(), CERTIFICATE_PATH);
         result = FileUtil.appendPath(result, DEVELOPER);
         result = FileUtil.appendPath(result, AUTHOR_CA);
@@ -48,13 +59,29 @@ public class SigningPathUtil {
     }
     
     public static String getDeveloperKeyPath() {
+        if ( SigningProfileUtil.isAvailableNewCertPolicy() ) {
+            return StringUtil.EMPTY_STRING;
+        }
+        
         String result = FileUtil.appendPath(InstallPathConfig.getSDKPath(), CERTIFICATE_PATH);
         result = FileUtil.appendPath(result, DISTRIBUTOR);
         result = FileUtil.appendPath(result, DISTRIBUTOR1_P12);
         return result;
     }
     
+    public static String getDeveloperKeyPassword() {
+        if ( SigningProfileUtil.isAvailableNewCertPolicy() ) {
+            return StringUtil.EMPTY_STRING;
+        }
+        
+        return DISTRIBUTOR1_PWD;
+    }
+    
     public static String getDeveloperCAPath() {
+        if ( SigningProfileUtil.isAvailableNewCertPolicy() ) {
+            return StringUtil.EMPTY_STRING;
+        }
+        
         String result = FileUtil.appendPath(InstallPathConfig.getSDKPath(), CERTIFICATE_PATH);
         result = FileUtil.appendPath(result, DISTRIBUTOR);
         result = FileUtil.appendPath(result, DISTRIBUTOR1_CA);
@@ -65,6 +92,28 @@ public class SigningPathUtil {
         return FileUtil.appendPath( InstallPathConfig.getToolsPath(), CERTIFICATE_GENERATOR );
     }
     
+    public static String getAuthorKeyPathForEmul() {
+        String result = FileUtil.appendPath(InstallPathConfig.getSDKPath(), CERTIFICATE_PATH);
+        result = FileUtil.appendPath(result, DEVELOPER);
+        result = FileUtil.appendPath(result, EMUL_AUTHOR_P12);
+        return result;
+    }
+    
+    public static String getDistributorKeyPathForEmul() {
+        String result = FileUtil.appendPath(InstallPathConfig.getSDKPath(), CERTIFICATE_PATH);
+        result = FileUtil.appendPath(result, DISTRIBUTOR);
+        result = FileUtil.appendPath(result, EMUL_DISTRIBUTOR1_P12);
+        return result;
+    }
+    
+    public static String getAuthorPasswordForEmul() {
+        return EMUL_AUTHOR_PWD;
+    }
+    
+    public static String getDistributorPasswordForEmul() {
+        return EMUL_DISTRIBUTOR1_PWD;
+    }
+    
     /**
      * Returns signature's directory path for native project only.
      *
index d535734..da6ba98 100644 (file)
@@ -32,6 +32,7 @@ import java.io.InputStream;
 
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -126,4 +127,19 @@ public class SigningProfileUtil
         // <SDK_PATH>/tizen-sdk-data/keystore/author/
         return getCertStorePath().append( SignatureConstants.AUTHOR );
     }
+    
+    public static boolean isExistNewCertPlugin() {
+        try {
+            return Platform.getBundle( "org.tizen.web.cert" ) != null;
+        } catch(NoClassDefFoundError e) {
+            return false;
+        }
+    }
+    
+    public static boolean isAvailableNewCertPolicy() {
+        if ( isExistNewCertPlugin() ) {
+            return getPreferenceStore().getBoolean( SignatureConstants.NEW_POLICY );
+        }
+        return false;
+    }
 }