blob: d2c8f4b6e8a5612f005f760557886989b4837353 [file] [log] [blame]
package org.eclipse.update.internal.ui.security;
/*
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.update.core.IVerificationResult;
import org.eclipse.update.internal.ui.UpdateUIPlugin;
/**
*
*/
public class JarVerificationPage extends BannerPage {
private IVerificationResult _VerificationResult = null;
private String _fileName = null;
private String _strFeatureName = null;
private String _strId = null;
private String _strProviderName = null;
private TitleAreaDialog _Dialog;
private boolean okToInstall = false;
private String componentVerified;
/*
* Constructor for JarVerificationPage.
*/
public JarVerificationPage(IVerificationResult verificationResult) {
super(UpdateUIPlugin.getResourceString("JarVerificationDialog.Verification"));
_fileName = verificationResult.getContentReference().getIdentifier();
_VerificationResult = verificationResult;
_strId = verificationResult.getFeature().getVersionedIdentifier().toString();
_strFeatureName = verificationResult.getFeature().getLabel();
_strProviderName = verificationResult.getFeature().getProvider();
componentVerified =
(verificationResult.isFeatureVerification()) ? "feature" : "feature file";
okToInstall = false;
}
/* (non-Javadoc)
* Method declared on Dialog.
*/
protected Control createContents(Composite compositeParent) {
// Composite: Client
//------------------
Composite compositeClient = new Composite(compositeParent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.marginHeight = layout.marginWidth = 0;
compositeClient.setLayout(layout);
compositeClient.setLayoutData(new GridData(GridData.FILL_BOTH));
// Text Information
//------------------
createTextArea(compositeClient);
// Certificate Area
//------------------
createCertificateArea(compositeClient);
// File and Feature Information
//-----------------------------
createInformationArea(compositeClient);
// Choice Area
//------------
createChoiceArea(compositeClient);
return compositeClient;
}
/*
* Continue install or cancel install
*/
private void createChoiceArea(Composite compositeClient) {
if (_VerificationResult.getVerificationCode()
!= IVerificationResult.TYPE_ENTRY_CORRUPTED) {
// Text: Instruction
//------------------
Text textInstruction = new Text(compositeClient, SWT.MULTI | SWT.READ_ONLY);
textInstruction.setLayoutData(
new GridData(
GridData.VERTICAL_ALIGN_BEGINNING
| GridData.GRAB_VERTICAL
| GridData.FILL_HORIZONTAL));
if (_VerificationResult.isFeatureVerification()) {
textInstruction.setText(
UpdateUIPlugin.getResourceString("JarVerificationDialog.MayChooseToInstall"));
//$NON-NLS-1$
} else {
textInstruction.setText(
UpdateUIPlugin.getResourceString("JarVerificationDialog.MayChooseToContinue"));
//$NON-NLS-1$
}
//$NON-NLS-1$
}
}
/*
* Creates the Information text
*/
private void createTextArea(Composite compositeClient) {
// Text: Information
//------------------
Text textInformation =
new Text(compositeClient, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
textInformation.setLayoutData(
new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL));
StringBuffer strb = new StringBuffer();
switch (_VerificationResult.getVerificationCode()) {
case IVerificationResult.TYPE_ENTRY_NOT_SIGNED :
String msg =
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.AboutToInstall",
componentVerified);
setMessage(msg, WARNING);
strb.append(
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.NotDigitallySigned",
componentVerified));
//$NON-NLS-1$
strb.append("\r\n"); //$NON-NLS-1$
strb.append(
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.CannotVerifyProvider",
componentVerified));
//$NON-NLS-1$
strb.append("\r\n"); //$NON-NLS-1$
if (_VerificationResult.isFeatureVerification()) {
strb.append(
UpdateUIPlugin.getResourceString("JarVerificationDialog.InstallMayCorrupt"));
//$NON-NLS-1$
} else {
strb.append(
UpdateUIPlugin.getResourceString("JarVerificationDialog.ContinueMayCorrupt"));
//$NON-NLS-1$
}
textInformation.setText(strb.toString());
break;
case IVerificationResult.TYPE_ENTRY_CORRUPTED :
msg =
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.CorruptedContent",
componentVerified);
setMessage(msg, ERROR);
//$NON-NLS-1$
strb.append(
UpdateUIPlugin.getResourceString(
"JarVerificationDialog.ComponentNotInstalled"));
//$NON-NLS-1$
textInformation.setText(strb.toString());
break;
case IVerificationResult.TYPE_ENTRY_SIGNED_UNRECOGNIZED :
msg =
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.SignedComponent",
componentVerified);
//$NON-NLS-1$
setMessage(msg, WARNING);
strb.append(
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.UnknownCertificate",
componentVerified));
//$NON-NLS-1$
strb.append("\r\n"); //$NON-NLS-1$
strb.append(
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.UnableToVerifyProvider",
componentVerified));
//$NON-NLS-1$
strb.append("\r\n"); //$NON-NLS-1$
if (_VerificationResult.isFeatureVerification()) {
strb.append(
UpdateUIPlugin.getResourceString("JarVerificationDialog.InstallMayCorrupt"));
//$NON-NLS-1$
} else {
strb.append(
UpdateUIPlugin.getResourceString("JarVerificationDialog.ContinueMayCorrupt"));
//$NON-NLS-1$
}
textInformation.setText(strb.toString());
break;
case IVerificationResult.TYPE_ENTRY_SIGNED_RECOGNIZED :
msg =
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.SignedComponent",
componentVerified);
//$NON-NLS-1$
setMessage(msg, WARNING);
strb.append(
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.KnownCertificate",
componentVerified));
//$NON-NLS-1$
strb.append("\r\n"); //$NON-NLS-1$
strb.append(
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.ProviderKnown",
componentVerified));
//$NON-NLS-1$
strb.append("\r\n"); //$NON-NLS-1$
textInformation.setText(strb.toString());
createCautionArea(compositeClient);
break;
}
}
/*
* Caution Label and text
*/
private void createCautionArea(Composite compositeClient) {
// Composite: Caution
//------------------------------
Composite compositeCaution = new Composite(compositeClient, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = layout.marginHeight = 0;
compositeCaution.setLayout(layout);
compositeCaution.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Icon
//-----
Label label = new Label(compositeCaution,SWT.LEFT);
label.setImage(JFaceResources.getImage(_Dialog.DLG_IMG_MESSAGE_WARNING));
// Text
//-----
Text textInformationCaution =
new Text(compositeCaution, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
textInformationCaution.setText(
UpdateUIPlugin.getFormattedMessage(
"JarVerificationDialog.Caution",
_strProviderName));
//$NON-NLS-1$
}
/*
* Presents File & Feature information
*/
private void createInformationArea(Composite compositeClient) {
// Composite: Information labels
//------------------------------
Composite compositeInformation = new Composite(compositeClient, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = layout.marginHeight = 0;
compositeInformation.setLayout(layout);
compositeInformation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Feature name
//---------------
Label label = null;
Text text = null;
if (_strFeatureName != null && _strFeatureName.length() > 0) {
label = new Label(compositeInformation, SWT.NULL);
label.setText(
UpdateUIPlugin.getResourceString("JarVerificationDialog.FeatureName"));
//$NON-NLS-1$
text = new Text(compositeInformation, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
text.setFont(JFaceResources.getBannerFont());
text.setText(_strFeatureName);
}
// Feature identifier
//---------------------
if (_strId != null && _strId.length() > 0) {
label = new Label(compositeInformation, SWT.NULL);
label.setText(
UpdateUIPlugin.getResourceString("JarVerificationDialog.FeatureIdentifier"));
//$NON-NLS-1$
text = new Text(compositeInformation, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
text.setFont(JFaceResources.getBannerFont());
text.setText(_strId);
}
// Provider name
//--------------
if (_strProviderName != null && _strProviderName.length() > 0) {
label = new Label(compositeInformation, SWT.NULL);
label.setText(
UpdateUIPlugin.getResourceString("JarVerificationDialog.Provider"));
//$NON-NLS-1$
text = new Text(compositeInformation, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
text.setFont(JFaceResources.getBannerFont());
text.setText(_strProviderName);
}
// Label: File name
//-----------------
label = new Label(compositeInformation, SWT.NULL);
label.setText(
UpdateUIPlugin.getResourceString("JarVerificationDialog.FileName"));
//$NON-NLS-1$
text = new Text(compositeInformation, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
text.setFont(JFaceResources.getBannerFont());
text.setText(_fileName);
}
/*
* Show certificate information
*/
private void createCertificateArea(Composite compositeClient) {
if (_VerificationResult.getVerificationCode()
== IVerificationResult.TYPE_ENTRY_SIGNED_UNRECOGNIZED
|| _VerificationResult.getVerificationCode()
== IVerificationResult.TYPE_ENTRY_SIGNED_RECOGNIZED) {
// Group box
//----------
Group group = new Group(compositeClient, SWT.SHADOW_ETCHED_IN);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = layout.marginHeight = 0;
group.setLayout(layout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setText("JarVerificationResult.CertificateInfo");
// Signer
//-------------------
Label label = null;
Text text = null;
//data = new GridData(GridData.FILL_HORIZONTAL);
//data.horizontalIndent = 0;
//textInformation.setLayoutData(data);
if (_VerificationResult.getSignerInfo() != null) {
label = new Label(group, SWT.NULL);
label.setText(UpdateUIPlugin.getResourceString("JarVerificationDialog.SubjectCA"));
label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
//$NON-NLS-1$
text = new Text(group, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
text.setText(_VerificationResult.getSignerInfo());
}
// Authenticator
//---------------------
if (_VerificationResult.getVerifierInfo() != null) {
label = new Label(group, SWT.NULL);
label.setText(UpdateUIPlugin.getResourceString("JarVerificationDialog.RootCA"));
label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
//$NON-NLS-1$
text = new Text(group, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
text.setText(_VerificationResult.getVerifierInfo());
}
}
}
/*
* Sets the Dialog
*/
public void setTitleAreaDialog(TitleAreaDialog dialog) {
_Dialog = dialog;
};
/*
*
*/
public void setMessage(String newMessage, int newType) {
super.setMessage(newMessage, newType);
if (_Dialog != null) {
_Dialog.setMessage(newMessage, newType);
}
}
}