Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2008 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 package org.eclipse.equinox.internal.security.ui.storage;
 
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.events.*;
 import  org.eclipse.swt.graphics.Image;
 import  org.eclipse.swt.layout.GridData;
 import  org.eclipse.swt.layout.GridLayout;
 import  org.eclipse.swt.widgets.*;
 
 public class StorageLoginDialog extends TitleAreaDialog {
 
 	private static final String DIALOG_SETTINGS_SECTION_NEW = "StorageLoginDialogNew"//$NON-NLS-1$
 	private static final String DIALOG_SETTINGS_SECTION_OLD = "StorageLoginDialogOld"//$NON-NLS-1$
 
 	private static final String HELP_ID = . + ".StorageLoginDialog"//$NON-NLS-1$
 
 	private static final ImageDescriptor dlgImageDescriptor = ImageDescriptor.createFromFile(StorageLoginDialog.class"/icons/storage/login_wiz.png"); //$NON-NLS-1$
 
 	private static final String DIGEST_ALGORITHM = "MD5"//$NON-NLS-1$
 
 	protected Text password;
 	protected Text confirm;
 
 	protected Button showPassword;
 	protected Button okButton;
 
 
 	final protected boolean confirmPassword;
 	final protected boolean passwordChange;
 	final protected String location;
 
 	private Image dlgTitleImage = null;
 
 	public StorageLoginDialog(boolean confirmPasswordboolean passwordChangeString location) {
 		super(StorageUtils.getShell());
 		this. = confirmPassword;
 		this. = passwordChange;
 		this. = location;
 	}
 
 	}
 
 	protected void createButtonsForButtonBar(Composite parent) {
 		.setEnabled(false);
 	}
 
 		IDialogSettings settings = Activator.getDefault().getDialogSettings();
 		IDialogSettings section = settings.getSection(settingsID);
 		if (section == null)
 			section = settings.addNewSection(settingsID);
 		return section;
 	}
 
 	protected boolean isResizable() {
 		return true;
 	}
 
 	protected void configureShell(Shell shell) {
 		super.configureShell(shell);
 		PlatformUI.getWorkbench().getHelpSystem().setHelp(shell);
 	}
 
 	protected Control createContents(Composite parent) {
 		Control contents = super.createContents(parent);
 		return contents;
 	}
 
	protected Control createDialogArea(Composite parent) {
		Composite compositeTop = (Composite) super.createDialogArea(parent);
		String titleMsg;
		else if ()
		else
		setTitle(titleMsg);
		Composite composite = new Composite(compositeTop, SWT.NONE);
		new Label(composite, SWT.LEFT).setText(.);
		 = new Text(composite, SWT.LEFT | SWT.BORDER);
		.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent event) {
			}
		});
			new Label(composite, SWT.LEFT).setText(.);
			 = new Text(composite, SWT.LEFT | SWT.BORDER);
			.addModifyListener(new ModifyListener() {
				public void modifyText(ModifyEvent event) {
				}
			});
else
			 = null;
		new Label(composite, SWT.LEFT); // filler
		 = new Button(composite, SWT.CHECK | SWT.RIGHT);
		.addSelectionListener(new SelectionListener() {
			public void widgetSelected(SelectionEvent e) {
			}
			public void widgetDefaultSelected(SelectionEvent e) {
			}
		});
		.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, falsefalse));
		// by default don't display password as clear text
		.setSelection(false);
		if ( != null) {
			Group locationGroup = new Group(composite, SWT.NONE);
			locationGroup.setText(.);
			GridData groupData = new GridData(SWT.FILL, SWT.FILL, truetrue);
			groupData.horizontalSpan = 2;
			locationGroup.setLayoutData(groupData);
			locationGroup.setLayout(new GridLayout());
			Label locationLabel = new Label(locationGroup, SWT.WRAP);
			locationLabel.setText(new Path().toOSString());
		}
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, truetrue));
		GridLayoutFactory.swtDefaults().numColumns(2).generateLayout(composite);
		return compositeTop;
	}
	protected void passwordVisibility() {
		boolean selected = .getSelection();
		if (selected) {
			.setEchoChar('\0');
			if ( != null)
				.setEchoChar('\0');
else {
			.setEchoChar('*');
			if ( != null)
				.setEchoChar('*');
		}
	}
	protected boolean validatePassword() {
		String password1 = .getText();
		if ((password1 == null) || (password1.length() == 0)) {
			return false;
		}
		if ( != null) {
			String password2 = .getText();
			if (!password1.equals(password2)) {
				return false;
			}
		}
		setMessage("".); //$NON-NLS-1$
		return true;
	}
	protected void okPressed() {
		String internalPassword;
		try {
			// normally use digest of what was entered
			MessageDigest digest = MessageDigest.getInstance();
			byte[] digested = digest.digest(new String(.getText()).getBytes());
			internalPassword = EncodingUtils.encodeBase64(digested);
catch (NoSuchAlgorithmException e) {
			// just use the text as is
			internalPassword = .getText();
		}
		 = new PBEKeySpec(internalPassword.toCharArray());
		super.okPressed();
	}
New to GrepCode? Check out our FAQ X