⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 certificatetrustwindow.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   CertificateTrustWindow.java

package org.gudy.azureus2.ui.swt.auth;

import java.security.Principal;
import java.security.cert.X509Certificate;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.security.SECertificateListener;
import org.gudy.azureus2.core3.security.SESecurityManager;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.mainwindow.SWTThread;

public class CertificateTrustWindow
	implements SECertificateListener
{
	protected class trustDialog
	{

		protected Shell shell;
		protected boolean trusted;
		final CertificateTrustWindow this$0;

		protected void close(boolean ok)
		{
			trusted = ok;
			shell.dispose();
		}

		protected String extractCN(String dn)
		{
			int p1 = dn.indexOf("CN=");
			if (p1 == -1)
				return dn;
			int p2 = dn.indexOf(",", p1);
			if (p2 == -1)
				return dn.substring(p1 + 3).trim();
			else
				return dn.substring(p1 + 3, p2).trim();
		}

		public boolean getTrusted()
		{
			return trusted;
		}

		protected trustDialog(Display display, String resource, X509Certificate cert)
		{
			this$0 = CertificateTrustWindow.this;
			Object();
			if (display.isDisposed())
				return;
			shell = new Shell(display, 0x10860);
			Utils.setShellIcon(shell);
			shell.setText(MessageText.getString("security.certtruster.title"));
			GridLayout layout = new GridLayout();
			layout.numColumns = 3;
			shell.setLayout(layout);
			Label info_label = new Label(shell, 0);
			Messages.setLanguageText(info_label, "security.certtruster.intro");
			GridData gridData = new GridData(1808);
			gridData.horizontalSpan = 3;
			info_label.setLayoutData(gridData);
			Label resource_label = new Label(shell, 0);
			Messages.setLanguageText(resource_label, "security.certtruster.resource");
			gridData = new GridData(1808);
			gridData.horizontalSpan = 1;
			resource_label.setLayoutData(gridData);
			Label resource_value = new Label(shell, 0);
			resource_value.setText(resource.replaceAll("&", "&&"));
			gridData = new GridData(1808);
			gridData.horizontalSpan = 2;
			resource_value.setLayoutData(gridData);
			Label issued_by_label = new Label(shell, 0);
			Messages.setLanguageText(issued_by_label, "security.certtruster.issuedby");
			gridData = new GridData(1808);
			gridData.horizontalSpan = 1;
			issued_by_label.setLayoutData(gridData);
			Label issued_by_value = new Label(shell, 0);
			issued_by_value.setText(extractCN(cert.getIssuerDN().getName()).replaceAll("&", "&&"));
			gridData = new GridData(1808);
			gridData.horizontalSpan = 2;
			issued_by_value.setLayoutData(gridData);
			Label issued_to_label = new Label(shell, 0);
			Messages.setLanguageText(issued_to_label, "security.certtruster.issuedto");
			gridData = new GridData(1808);
			gridData.horizontalSpan = 1;
			issued_to_label.setLayoutData(gridData);
			Label issued_to_value = new Label(shell, 0);
			issued_to_value.setText(extractCN(cert.getSubjectDN().getName()).replaceAll("&", "&&"));
			gridData = new GridData(1808);
			gridData.horizontalSpan = 2;
			issued_to_value.setLayoutData(gridData);
			Label prompt_label = new Label(shell, 0);
			Messages.setLanguageText(prompt_label, "security.certtruster.prompt");
			gridData = new GridData(1808);
			gridData.horizontalSpan = 3;
			prompt_label.setLayoutData(gridData);
			Label labelSeparator = new Label(shell, 258);
			gridData = new GridData(768);
			gridData.horizontalSpan = 3;
			labelSeparator.setLayoutData(gridData);
			new Label(shell, 0);
			Composite comp = new Composite(shell, 0);
			gridData = new GridData(896);
			gridData.grabExcessHorizontalSpace = true;
			gridData.horizontalSpan = 2;
			comp.setLayoutData(gridData);
			GridLayout layoutButtons = new GridLayout();
			layoutButtons.numColumns = 2;
			comp.setLayout(layoutButtons);
			Button bYes = new Button(comp, 8);
			bYes.setText(MessageText.getString("security.certtruster.yes"));
			gridData = new GridData(896);
			gridData.grabExcessHorizontalSpace = true;
			gridData.widthHint = 70;
			bYes.setLayoutData(gridData);
			bYes.addListener(13, new Listener() {

				final CertificateTrustWindow val$this$0;
				final trustDialog this$1;

				public void handleEvent(Event e)
				{
					close(true);
				}


// JavaClassFileOutputException: Invalid index accessing method local variables table of <init>
			});
			Button bNo = new Button(comp, 8);
			bNo.setText(MessageText.getString("security.certtruster.no"));
			gridData = new GridData(128);
			gridData.grabExcessHorizontalSpace = false;
			gridData.widthHint = 70;
			bNo.setLayoutData(gridData);
			bNo.addListener(13, new Listener() {

				final CertificateTrustWindow val$this$0;
				final trustDialog this$1;

				public void handleEvent(Event e)
				{
					close(false);
				}


// JavaClassFileOutputException: Invalid index accessing method local variables table of <init>
			});
			shell.setDefaultButton(bYes);
			shell.addListener(31, new Listener() {

				final CertificateTrustWindow val$this$0;
				final trustDialog this$1;

				public void handleEvent(Event e)
				{
					if (e.character == '\033')
						close(false);
				}


// JavaClassFileOutputException: Invalid index accessing method local variables table of <init>
			});
			shell.pack();
			Utils.centreWindow(shell);
			shell.open();
			do
			{
				if (shell.isDisposed())
					break;
				if (!shell.getDisplay().readAndDispatch())
					shell.getDisplay().sleep();
			} while (true);
		}
	}


	public CertificateTrustWindow()
	{
		SESecurityManager.addCertificateListener(this);
	}

	public boolean trustCertificate(final String resource, final X509Certificate cert)
	{
		final Display display = SWTThread.getInstance().getDisplay();
		if (display.isDisposed())
			return false;
		final trustDialog dialog[] = new trustDialog[1];
		try
		{
			Utils.execSWTThread(new AERunnable() {

				final trustDialog val$dialog[];
				final Display val$display;
				final String val$resource;
				final X509Certificate val$cert;
				final CertificateTrustWindow this$0;

				public void runSupport()
				{
					dialog[0] = new trustDialog(display, resource, cert);
				}

			
			{
				this$0 = CertificateTrustWindow.this;
				dialog = atrustdialog;
				display = display1;
				resource = s;
				cert = x509certificate;
				AERunnable();
			}
			}, false);
		}
		catch (Throwable e)
		{
			Debug.printStackTrace(e);
			return false;
		}
		return dialog[0].getTrusted();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -