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,
OSGI-INF/,\
about_files/,\
about.html,\
- lib/
+ lib/,\
+ certForEmul/
--- /dev/null
+developertest\r
+\r
+platfromtest\r
+\r
+partnertest\r
+\r
+publictest\r
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIEDTCCAvWgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBuTELMAkGA1UEBhMCS1Ix
+FDASBgNVBAgMC1NvdXRoIEtvcmVhMQ4wDAYDVQQHDAVTdXdvbjEmMCQGA1UECgwd
+U2Ftc3VuZyBFbGVjdHJvbmljcyBDby4sIEx0ZC4xDzANBgNVBAsMBk1vYmlsZTEk
+MCIGA1UEAwwbU2Ftc3VuZ1Rlc3QgUHVibGljIENBIENsYXNzMSUwIwYJKoZIhvcN
+AQkBFhZtLnNlY3VyaXR5QHNhbXN1bmcuY29tMB4XDTEyMTIzMDE1MDAxOFoXDTE0
+MTIzMDE1MDAxOFowgb0xCzAJBgNVBAYTAktSMRQwEgYDVQQIDAtTb3V0aCBLb3Jl
+YTEOMAwGA1UEBwwFU3V3b24xJjAkBgNVBAoMHVNhbXN1bmcgRWxlY3Ryb25pY3Mg
+Q28uLCBMdGQuMQ8wDQYDVQQLDAZNb2JpbGUxKDAmBgNVBAMMH1NhbXN1bmdUZXN0
+IFB1YmxpYyBTaWduZXIgQ2xhc3MxJTAjBgkqhkiG9w0BCQEWFm0uc2VjdXJpdHlA
+c2Ftc3VuZy5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC0SlB5
+2nMXbt2xBDjk2UzPQi70x7VDDzN9exjNIcRa2vTAhRuiFnfgA15e55gsXxKh20kW
++SKiEY2p1aBiZUIQkDqnBhrw40zGGGFlFLDYqccIcUbK+HcP1YI8aOdtOBBFAvMQ
+tA+Ec7CZP6Vii/Vt+ZhPnvTGm9yFHLETfLcpiItmJZ2GLXniB7vkarKKEJv7YS0W
+e1NSbRR8A5sF3m5/7KiK9xgTuT77rn72wCKP4SP6WGC6Z39Cj1U9XyeSAKvK2TUy
+JE9/feply+N+Xhd4ELDUGhn5OCgc+ImwPdGMU31v+Hd2tcuRAf+r6H6S9JuL4ZB5
+/FFffao+cdCybzhzAgMBAAGjGjAYMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgeAMA0G
+CSqGSIb3DQEBBQUAA4IBAQAoXmMGlRs4DA4ZmiLd+RHnA/mw42Ch8tAmbTq2YAST
+jpRCJyHNOYDyGFrX96eH3SuFdtTJ7VxbwuC/z+wCWGW+b1PgLxSBgJcpV+MvJ26v
+d7iGUY0nY6sUIE7+bQLmzfovRq1zcKdeeAEU/4Gbpji2f9tB8Nqy/iwojCtqvjFE
+R9fQea8hbv8XRdI9KI7jb4p01z8zclysNFExgyXuZl1cQMDk/VDbSh1Wom4hgIqd
+RCviIHhw+v8uhh3rkrzhgHuoJ5yYt3U0SlvXkiTb/Z6tmdzgW4GjV7+5cT8OLses
+2FFrDiq99BKUK2Nlm2rPbYv2Q4/igEaDrLmithJJ+2Fb
+-----END CERTIFICATE-----
// 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";
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.*;
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;
Composite composite = createComposite(
parent, SWT.NONE, createGridLayout( 1 ), new GridData( GridData.FILL_BOTH ) );
+ if ( SigningProfileUtil.isExistNewCertPlugin() ) {
+ createNewCertControl( composite );
+ }
createProfilesControl( composite );
createAuthorControl( composite );
createDistributorControl( composite );
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>
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 );
}
}
return createProfileItem(
1, // distributor 1
SigningPathUtil.getDeveloperKeyPath(),
- SigningPathUtil.DISTRIBUTOR1_PWD,
+ SigningPathUtil.getDeveloperKeyPassword(),
SigningPathUtil.getDeveloperCAPath(),
StringUtil.EMPTY_STRING
);
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;
/**
protected boolean bRDS = false;
+ protected String deviceSerialNumber;
// Constructor
public 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.
* @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() ) {
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
import org.tizen.common.core.application.InstallPathConfig;
import org.tizen.common.util.FileUtil;
+import org.tizen.common.util.StringUtil;
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);
}
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);
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.
*
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;
// <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;
+ }
}