1 11 package org.eclipse.update.internal.ui.security; 12 import org.eclipse.jface.dialogs.Dialog; 13 import org.eclipse.jface.dialogs.TitleAreaDialog; 14 import org.eclipse.jface.resource.FontRegistry; 15 import org.eclipse.jface.resource.JFaceResources; 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.custom.CLabel; 18 import org.eclipse.swt.graphics.Font; 19 import org.eclipse.swt.layout.GridData; 20 import org.eclipse.swt.layout.GridLayout; 21 import org.eclipse.swt.widgets.Composite; 22 import org.eclipse.swt.widgets.Control; 23 import org.eclipse.swt.widgets.Group; 24 import org.eclipse.swt.widgets.Label; 25 import org.eclipse.swt.widgets.Text; 26 import org.eclipse.ui.*; 27 import org.eclipse.update.core.IVerificationResult; 28 import org.eclipse.update.internal.ui.UpdateUIMessages; 29 import org.eclipse.update.internal.ui.wizards.BannerPage; 30 31 34 public class JarVerificationPage extends BannerPage { 35 36 private IVerificationResult _VerificationResult = null; 37 private String _fileName = null; 38 private String _strFeatureName = null; 39 private String _strId = null; 40 private String _strProviderName = null; 41 private TitleAreaDialog _Dialog; 42 43 46 public JarVerificationPage(IVerificationResult verificationResult) { 47 super(UpdateUIMessages.JarVerificationDialog_Verification); 48 _fileName = verificationResult.getContentReference().getIdentifier(); 49 _VerificationResult = verificationResult; 50 _strId = verificationResult.getFeature().getVersionedIdentifier().toString(); 51 _strFeatureName = verificationResult.getFeature().getLabel(); 52 _strProviderName = verificationResult.getFeature().getProvider(); 53 } 54 55 58 protected Control createContents(Composite compositeParent) { 59 PlatformUI.getWorkbench().getHelpSystem().setHelp(compositeParent, "org.eclipse.update.ui.JarVerificationPage"); Composite compositeClient = new Composite(compositeParent, SWT.NULL); 63 GridLayout layout = new GridLayout(); 64 layout.marginHeight = layout.marginWidth = 0; 65 compositeClient.setLayout(layout); 66 compositeClient.setLayoutData(new GridData(GridData.FILL_BOTH)); 67 68 createTextArea(compositeClient); 71 72 createCertificateArea(compositeClient); 75 76 createInformationArea(compositeClient); 79 80 84 Dialog.applyDialogFont(compositeParent); 85 return compositeClient; 86 87 } 88 89 92 private void createTextArea(Composite compositeClient) { 93 94 Label labelInformation = 97 new Label(compositeClient, SWT.WRAP); 98 labelInformation.setLayoutData( 99 new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL)); 100 101 String actionMsg = null; 102 if (_VerificationResult.isFeatureVerification()) { 103 actionMsg = UpdateUIMessages.JarVerificationDialog_MayChooseToInstall; 104 } else { 105 actionMsg = UpdateUIMessages.JarVerificationDialog_MayChooseToContinue; 106 } 107 108 StringBuffer strb = new StringBuffer (); 109 switch (_VerificationResult.getVerificationCode()) { 110 111 case IVerificationResult.TYPE_ENTRY_NOT_SIGNED : 112 String msg = (_VerificationResult.isFeatureVerification()? 113 UpdateUIMessages.JarVerificationDialog_AboutToInstall_Feature: 114 UpdateUIMessages.JarVerificationDialog_AboutToInstall_File)+ 115 "\r\n" + actionMsg; setMessage(msg, WARNING); 117 strb.append(_VerificationResult.isFeatureVerification()? 118 UpdateUIMessages.JarVerificationDialog_NotDigitallySigned_Feature: 119 UpdateUIMessages.JarVerificationDialog_NotDigitallySigned_File); 120 strb.append("\r\n"); strb.append(_VerificationResult.isFeatureVerification()? 122 UpdateUIMessages.JarVerificationDialog_CannotVerifyProvider_Feature: 123 UpdateUIMessages.JarVerificationDialog_CannotVerifyProvider_File); 124 125 134 labelInformation.setText(strb.toString()); 135 break; 136 137 case IVerificationResult.TYPE_ENTRY_CORRUPTED : 138 msg = _VerificationResult.isFeatureVerification()? 139 UpdateUIMessages.JarVerificationDialog_CorruptedContent_Feature: 140 UpdateUIMessages.JarVerificationDialog_CorruptedContent_File; 141 setMessage(msg, ERROR); 142 strb.append( 143 UpdateUIMessages.JarVerificationDialog_ComponentNotInstalled); 144 labelInformation.setText(strb.toString()); 145 break; 146 147 case IVerificationResult.TYPE_ENTRY_SIGNED_UNRECOGNIZED : 148 msg = (_VerificationResult.isFeatureVerification()? 149 UpdateUIMessages.JarVerificationDialog_SignedComponent_Feature: 150 UpdateUIMessages.JarVerificationDialog_SignedComponent_Feature) + 151 "\r\n" + actionMsg; 153 setMessage(msg, WARNING); 154 strb.append(_VerificationResult.isFeatureVerification()? 155 UpdateUIMessages.JarVerificationDialog_UnknownCertificate_Feature: 156 UpdateUIMessages.JarVerificationDialog_UnknownCertificate_File); 157 strb.append("\r\n"); strb.append(_VerificationResult.isFeatureVerification()? 159 UpdateUIMessages.JarVerificationDialog_UnableToVerifyProvider_Feature: 160 UpdateUIMessages.JarVerificationDialog_UnableToVerifyProvider_File); 161 170 labelInformation.setText(strb.toString()); 171 break; 172 173 case IVerificationResult.TYPE_ENTRY_SIGNED_RECOGNIZED : 174 msg = (_VerificationResult.isFeatureVerification()? 175 UpdateUIMessages.JarVerificationDialog_SignedComponent_Feature: 176 UpdateUIMessages.JarVerificationDialog_SignedComponent_File) + 177 "\r\n" + actionMsg; setMessage(msg, WARNING); 179 strb.append(_VerificationResult.isFeatureVerification()? 180 UpdateUIMessages.JarVerificationDialog_KnownCertificate_Feature: 181 UpdateUIMessages.JarVerificationDialog_KnownCertificate_File); 182 strb.append("\r\n"); strb.append(_VerificationResult.isFeatureVerification()? 184 UpdateUIMessages.JarVerificationDialog_ProviderKnown_Feature: 185 UpdateUIMessages.JarVerificationDialog_ProviderKnown_File); 186 strb.append("\r\n"); 188 labelInformation.setText(strb.toString()); 189 190 break; 192 } 193 } 194 195 196 199 private void createInformationArea(Composite compositeClient) { 200 201 Composite compositeInformation = new Composite(compositeClient, SWT.NULL); 204 GridLayout layout = new GridLayout(); 205 layout.numColumns = 2; 206 layout.marginWidth = layout.marginHeight = 0; 207 compositeInformation.setLayout(layout); 208 compositeInformation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 209 210 FontRegistry fregistry = JFaceResources.getFontRegistry(); 212 Font boldFont = fregistry.getBold(JFaceResources.DIALOG_FONT); 213 214 Label keyLabel = null; 217 CLabel valueLabel = null; 218 if (_strFeatureName != null && _strFeatureName.length() > 0) { 219 keyLabel = new Label(compositeInformation, SWT.NULL); 220 keyLabel.setText( 221 UpdateUIMessages.JarVerificationDialog_FeatureName); 222 223 valueLabel = new CLabel(compositeInformation, SWT.NULL); 224 valueLabel.setFont(boldFont); 225 valueLabel.setText(_strFeatureName); 226 valueLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 227 } 228 if (_strId != null && _strId.length() > 0) { 231 keyLabel = new Label(compositeInformation, SWT.NULL); 232 keyLabel.setText( 233 UpdateUIMessages.JarVerificationDialog_FeatureIdentifier); 234 235 valueLabel = new CLabel(compositeInformation, SWT.NULL); 236 valueLabel.setFont(boldFont); 237 valueLabel.setText(_strId); 238 valueLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 239 } 240 if (_strProviderName != null && _strProviderName.length() > 0) { 243 keyLabel = new Label(compositeInformation, SWT.NULL); 244 keyLabel.setText( 245 UpdateUIMessages.JarVerificationDialog_Provider); 246 247 valueLabel = new CLabel(compositeInformation, SWT.NULL); 248 valueLabel.setFont(boldFont); 249 valueLabel.setText(_strProviderName); 250 valueLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 251 } 252 keyLabel = new Label(compositeInformation, SWT.NULL); 255 keyLabel.setText( 256 UpdateUIMessages.JarVerificationDialog_FileName); 257 258 valueLabel = new CLabel(compositeInformation, SWT.NULL); 259 valueLabel.setFont(boldFont); 260 valueLabel.setText(_fileName); 261 valueLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 262 } 263 264 267 private void createCertificateArea(Composite compositeClient) { 268 269 if (_VerificationResult.getVerificationCode() 270 == IVerificationResult.TYPE_ENTRY_SIGNED_UNRECOGNIZED 271 || _VerificationResult.getVerificationCode() 272 == IVerificationResult.TYPE_ENTRY_SIGNED_RECOGNIZED) { 273 Group group = new Group(compositeClient, SWT.SHADOW_ETCHED_IN); 276 GridLayout layout = new GridLayout(); 277 layout.numColumns = 2; 278 layout.marginWidth = layout.marginHeight = 0; 279 group.setLayout(layout); 280 group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 281 group.setText(UpdateUIMessages.JarVerificationDialog_CertificateInfo); 282 283 Label keyLabel = null; 286 Text valueText = null; 287 if (_VerificationResult.getSignerInfo() != null) { 291 keyLabel = new Label(group, SWT.NULL); 292 keyLabel.setText(UpdateUIMessages.JarVerificationDialog_SubjectCA); 293 keyLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); 294 295 valueText = new Text(group, SWT.MULTI|SWT.BORDER|SWT.WRAP|SWT.V_SCROLL); 296 valueText.setText(_VerificationResult.getSignerInfo()); 297 valueText.setEditable(false); 298 valueText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 299 } 300 301 if (_VerificationResult.getVerifierInfo() != null) { 304 keyLabel = new Label(group, SWT.NULL); 305 keyLabel.setText(UpdateUIMessages.JarVerificationDialog_RootCA); 306 keyLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); 307 308 valueText = new Text(group, SWT.MULTI|SWT.BORDER|SWT.WRAP|SWT.V_SCROLL); 309 valueText.setText(_VerificationResult.getVerifierInfo()); 310 valueText.setEditable(false); 311 valueText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 312 } 313 } 314 } 315 316 319 public void setTitleAreaDialog(TitleAreaDialog dialog) { 320 _Dialog = dialog; 321 } 322 323 326 public void setMessage(String newMessage, int newType) { 327 super.setMessage(newMessage, newType); 328 if (_Dialog != null) { 329 _Dialog.setMessage(newMessage, newType); 330 } 331 } 332 333 } 334 | Popular Tags |