Repository: ant-ivyde Updated Branches: refs/heads/master 0d36b49d5 -> e5088bb1f
Add support for storing securely credentials (thanks to Alexander Blaas) Project: http://git-wip-us.apache.org/repos/asf/ant-ivyde/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivyde/commit/df5fead5 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivyde/tree/df5fead5 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivyde/diff/df5fead5 Branch: refs/heads/master Commit: df5fead546bd8a55126ebc12ad4dae1875f8cf99 Parents: 45d03ba Author: Nicolas LaleveÌe <nicolas.lale...@hibnet.org> Authored: Wed Jun 14 23:41:15 2017 +0200 Committer: Nicolas LaleveÌe <nicolas.lale...@hibnet.org> Committed: Sun Jul 2 12:16:47 2017 +0200 ---------------------------------------------------------------------- org.apache.ivyde.eclipse/META-INF/MANIFEST.MF | 7 +- org.apache.ivyde.eclipse/plugin.xml | 7 +- .../apache/ivyde/eclipse/GUIfactoryHelper.java | 85 +++++++ .../ivyde/eclipse/IvyDEsecurityHelper.java | 167 +++++++++++++ .../apache/ivyde/eclipse/cp/SecuritySetup.java | 183 ++++++++++++++ .../ivyde/internal/eclipse/IvyPlugin.java | 16 +- .../controller/SecuritySetupController.java | 247 +++++++++++++++++++ .../cpcontainer/SecuritySetupContainer.java | 55 +++++ .../eclipse/ui/SecuritySetupEditor.java | 128 ++++++++++ .../ui/components/CustomConfirmationDialog.java | 43 ++++ .../ui/components/SecuritySetupDialog.java | 225 +++++++++++++++++ .../SecuritySetupPreferencePage.java | 91 +++++++ .../eclipse/validator/BaseValidator.java | 58 +++++ .../eclipse/validator/IValidationReaction.java | 25 ++ .../eclipse/validator/impl/HostValidator.java | 43 ++++ .../eclipse/validator/impl/IdValidator.java | 80 ++++++ .../validator/impl/PasswordValidator.java | 36 +++ .../eclipse/validator/impl/RealmValidator.java | 43 ++++ .../validator/impl/UserNameValidator.java | 39 +++ .../reaction/GeneralValidationReaction.java | 60 +++++ .../reaction/NopValidationReaction.java | 34 +++ 21 files changed, 1666 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF b/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF index f354d8e..9113a35 100644 --- a/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF +++ b/org.apache.ivyde.eclipse/META-INF/MANIFEST.MF @@ -33,6 +33,11 @@ Require-Bundle: org.apache.xerces;bundle-version="[2.9.0,3.0.0)";resolution:=opt org.eclipse.debug.core;bundle-version="[3.4.0,4.0.0)", org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)", org.eclipse.debug.ui;bundle-version="[3.4.0,4.0.0)", - org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)" + org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)", + org.eclipse.equinox.security;bundle-version="[1.1.100,2.0.0)", + org.eclipse.core.databinding;bundle-version="[1.4.1,2.0.0)", + org.eclipse.core.databinding.property;bundle-version="[1.4.100,2.0.0)", + org.eclipse.core.databinding.beans;bundle-version="[1.2.200,2.0.0)", + org.eclipse.jface.databinding;bundle-version="[1.6.0,2.0.0)" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/plugin.xml ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/plugin.xml b/org.apache.ivyde.eclipse/plugin.xml index 0c08d7e..99903b1 100644 --- a/org.apache.ivyde.eclipse/plugin.xml +++ b/org.apache.ivyde.eclipse/plugin.xml @@ -144,6 +144,12 @@ id="org.apache.ivyde.eclipse.ui.preferences.AdvancedSetupPreferencePage" name="Advanced"> </page> + <page + category="org.apache.ivyde.eclipse.ui.preferences.IvyPreferencePage" + class="org.apache.ivyde.internal.eclipse.ui.preferences.SecuritySetupPreferencePage" + id="org.apache.ivyde.eclipse.ui.preferences.SecuritySetupPreferencePage" + name="Security"> + </page> </extension> <extension point="org.eclipse.core.runtime.preferences"> @@ -506,5 +512,4 @@ </describer> </content-type> </extension> - </plugin> http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/GUIfactoryHelper.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/GUIfactoryHelper.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/GUIfactoryHelper.java new file mode 100644 index 0000000..70fa1c3 --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/GUIfactoryHelper.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.eclipse; + +import org.apache.ivyde.eclipse.cp.SecuritySetup; +import org.apache.ivyde.internal.eclipse.ui.components.CustomConfirmationDialog; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + +public final class GUIfactoryHelper { + + private static final String SECRET = "******"; + + private GUIfactoryHelper() { + + } + + public static ColumnLabelProvider buildHostLabelProvider() { + return new ColumnLabelProvider() { + @Override + public String getText(Object element) { + return ((SecuritySetup) element).getHost(); + } + }; + } + + public static ColumnLabelProvider buildRealmLabelProvider() { + return new ColumnLabelProvider() { + @Override + public String getText(Object element) { + return ((SecuritySetup) element).getRealm(); + } + }; + } + + public static ColumnLabelProvider buildUsernameLabelProvider() { + return new ColumnLabelProvider() { + @Override + public String getText(Object element) { + return ((SecuritySetup) element).getUserName(); + } + }; + } + + public static ColumnLabelProvider buildPwdLabelProvider() { + return new ColumnLabelProvider() { + @Override + public String getText(Object element) { + return SECRET; + } + }; + } + + public static TableViewerColumn buildTableColumn(TableViewer viewer, int width, String header, + ColumnLabelProvider provider) { + TableViewerColumn col = new TableViewerColumn(viewer, SWT.NONE); + col.getColumn().setWidth(width); + col.getColumn().setText(header); + col.setLabelProvider(provider); + return col; + } + + public static CustomConfirmationDialog buildConfirmationDialog(Shell parentShell, + String dialogTitle, String dialogMessage) { + return new CustomConfirmationDialog(parentShell, dialogTitle, dialogMessage); + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEsecurityHelper.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEsecurityHelper.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEsecurityHelper.java new file mode 100644 index 0000000..b54ece7 --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDEsecurityHelper.java @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.eclipse; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.ivy.util.url.CredentialsStore; +import org.apache.ivyde.eclipse.cp.SecuritySetup; +import org.apache.ivyde.internal.eclipse.IvyPlugin; +import org.eclipse.equinox.security.storage.ISecurePreferences; +import org.eclipse.equinox.security.storage.SecurePreferencesFactory; +import org.eclipse.equinox.security.storage.StorageException; + +public final class IvyDEsecurityHelper { + + private static final String IVY_DE_CREDENTIALS_BASE_NODE = "org.apache.ivyde.credentials"; + + private static final String HOST_KEY = "host"; + + private static final String REALM_KEY = "realm"; + + private static final String USERNAME_KEY = "username"; + + private static final String PASSWORD_KEY = "pwd"; + + private IvyDEsecurityHelper() { + + } + + public static void addCredentialsToIvyCredentialStorage(SecuritySetup setup) { + CredentialsStore.INSTANCE.addCredentials(setup.getRealm(), setup.getHost(), + setup.getUserName(), setup.getPwd()); + IvyPlugin.logInfo("Credentials " + setup.toString() + " added to ivyDE credential store"); + } + + public static void cpyCredentialsFromSecureToIvyStorage() { + List<SecuritySetup> credentials = getCredentialsFromSecureStore(); + for (SecuritySetup entry : credentials) { + addCredentialsToIvyCredentialStorage(entry); + IvyPlugin.logInfo("Credentials " + entry.toString() + + " from eclipse secure storage copied to ivyDE credential store"); + } + } + + public static void addCredentialsToSecureStorage(SecuritySetup setup) { + ISecurePreferences preferences = SecurePreferencesFactory.getDefault(); + ISecurePreferences baseNode = preferences.node(IVY_DE_CREDENTIALS_BASE_NODE); + ISecurePreferences childNode = baseNode.node(setup.getHost()); + ISecurePreferences childChildNode = childNode.node(setup.getRealm()); + + try { + childChildNode.put(HOST_KEY, setup.getHost(), false); + childChildNode.put(REALM_KEY, setup.getRealm(), false); + childChildNode.put(USERNAME_KEY, setup.getUserName(), true); + childChildNode.put(PASSWORD_KEY, setup.getPwd(), true); + childChildNode.flush(); + IvyPlugin.logInfo( + "Credentials " + setup.toString() + " added to eclipse secure storage"); + } catch (StorageException e1) { + IvyPlugin.logError(e1.getMessage(), e1); + } catch (IOException e) { + IvyPlugin.logError(e.getMessage(), e); + } + } + + public static List<SecuritySetup> getCredentialsFromSecureStore() { + ISecurePreferences preferences = SecurePreferencesFactory.getDefault(); + List<SecuritySetup> setupValues = new ArrayList<SecuritySetup>(); + if (preferences.nodeExists(IVY_DE_CREDENTIALS_BASE_NODE)) { + ISecurePreferences node = preferences.node(IVY_DE_CREDENTIALS_BASE_NODE); + String[] childNames = node.childrenNames(); + for (String childName : childNames) { + ISecurePreferences childNode = node.node(childName); + String[] childChildNames = childNode.childrenNames(); + for (String childChildName : childChildNames) { + ISecurePreferences childChildNode = childNode.node(childChildName); + try { + SecuritySetup toAdd = new SecuritySetup( + childChildNode.get(HOST_KEY, "localhost"), + childChildNode.get(REALM_KEY, "basic"), + childChildNode.get(USERNAME_KEY, null), + childChildNode.get(PASSWORD_KEY, null)); + setupValues.add(toAdd); + IvyPlugin.logInfo("Credentials " + toAdd.toString() + + " loaded from eclipse secure storage"); + } catch (StorageException e1) { + IvyPlugin.logError(e1.getMessage(), e1); + } + } + } + } + Collections.sort(setupValues); + return setupValues; + } + + public static void removeCredentials(SecuritySetup setup) { + removeCredentialsFromSecureStore(setup); + invalidateIvyCredentials(setup); + } + + public static boolean hostExistsInSecureStorage(String host, String realm) { + ISecurePreferences preferences = SecurePreferencesFactory.getDefault(); + if (preferences.nodeExists(IVY_DE_CREDENTIALS_BASE_NODE)) { + ISecurePreferences node = preferences.node(IVY_DE_CREDENTIALS_BASE_NODE); + if (node.nodeExists(host)) { + ISecurePreferences childNode = node.node(host); + if (childNode.nodeExists(realm)) { + return true; + } + } + } + return false; + } + + private static void removeCredentialsFromSecureStore(SecuritySetup setup) { + String host = setup.getHost(); + String realm = setup.getRealm(); + ISecurePreferences preferences = SecurePreferencesFactory.getDefault(); + if (preferences.nodeExists(IVY_DE_CREDENTIALS_BASE_NODE)) { + ISecurePreferences node = preferences.node(IVY_DE_CREDENTIALS_BASE_NODE); + if (node.nodeExists(host)) { + ISecurePreferences childNode = node.node(host); + if (childNode.nodeExists(realm)) { + childNode.node(realm).removeNode(); + try { + node.flush(); + IvyPlugin.logInfo("Credentials " + setup.toString() + + "' removed from eclipse secure storage"); + } catch (IOException e) { + // TODO Auto-generated catch block + IvyPlugin.logError(e.getMessage(), e); + } + } + } + } + } + + private static void invalidateIvyCredentials(SecuritySetup setup) { + // need to invalidate => on credentialStore just add-ops allowed + CredentialsStore.INSTANCE.addCredentials(setup.getHost(), setup.getRealm(), null, null); + IvyPlugin.logInfo("Credentials " + setup + + " invalidated on ivyDE credential store: Removed on next eclipse startup."); + } + + public static boolean credentialsInSecureStorage() { + return SecurePreferencesFactory.getDefault().nodeExists(IVY_DE_CREDENTIALS_BASE_NODE); + } + +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SecuritySetup.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SecuritySetup.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SecuritySetup.java new file mode 100644 index 0000000..ae8f95b --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SecuritySetup.java @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.eclipse.cp; + +public class SecuritySetup implements Comparable<SecuritySetup> { + + private String id = ""; + + private String host = ""; + + private String realm = ""; + + private String userName = ""; + + private String pwd = ""; + + public SecuritySetup() { + + } + + /** + * @param host + * @param realm + * @param userName + * @param pwd + */ + public SecuritySetup(String host, String realm, String userName, String pwd) { + this.id = host + "@" + realm; + this.host = host; + this.realm = realm; + this.userName = userName; + this.pwd = pwd; + } + + public void setAllValues(SecuritySetup toSet) { + this.id = toSet.getHost() + "@" + toSet.getRealm(); + this.host = toSet.getHost(); + this.realm = toSet.getRealm(); + this.userName = toSet.getUserName(); + this.pwd = toSet.getPwd(); + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the host + */ + public String getHost() { + return host; + } + + /** + * @param host + * the host to set + */ + public void setHost(String host) { + this.host = host; + } + + /** + * @return the realm + */ + public String getRealm() { + return realm; + } + + /** + * @param realm + * the realm to set + */ + public void setRealm(String realm) { + this.realm = realm; + } + + /** + * @return the userName + */ + public String getUserName() { + return userName; + } + + /** + * @param userName + * the userName to set + */ + public void setUserName(String userName) { + this.userName = userName; + } + + /** + * @return the pwd + */ + public String getPwd() { + return pwd; + } + + /** + * @param pwd + * the pwd to set + */ + public void setPwd(String pwd) { + this.pwd = pwd; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((host == null) ? 0 : host.hashCode()); + result = prime * result + ((realm == null) ? 0 : realm.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SecuritySetup other = (SecuritySetup) obj; + if (host == null) { + if (other.host != null) + return false; + } else if (!host.equals(other.host)) + return false; + if (realm == null) { + if (other.realm != null) + return false; + } else if (!realm.equals(other.realm)) + return false; + return true; + } + + @Override + public String toString() { + return "[storageId: '" + this.host + "@" + this.realm + "', host='" + this.host + + "', realm='" + this.realm + "', user='" + this.userName + "', password='******']"; + } + + public int compareTo(SecuritySetup o) { + return this.host.compareTo(o.getHost()); + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java index 9ef70d7..3ae72c7 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java @@ -29,6 +29,7 @@ import java.util.regex.Pattern; import org.apache.ivy.Ivy; import org.apache.ivyde.common.ivyfile.IvyFileResourceListener; +import org.apache.ivyde.eclipse.IvyDEsecurityHelper; import org.apache.ivyde.eclipse.cp.IvyClasspathContainer; import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper; import org.apache.ivyde.internal.eclipse.cpcontainer.IvyAttachementManager; @@ -136,6 +137,13 @@ public class IvyPlugin extends AbstractUIPlugin { this.bundleContext = context; logInfo("starting IvyDE plugin"); + if (IvyDEsecurityHelper.credentialsInSecureStorage()) { + IvyDEsecurityHelper.cpyCredentialsFromSecureToIvyStorage(); + logInfo("Credentials loaded from secure storage"); + } else { + logInfo("No credentials stored in secure storage"); + } + Matcher matcher = IVY_VERSION_PATTERN.matcher(Ivy.getIvyVersion()); if (matcher.matches()) { ivyVersionMajor = Integer.parseInt(matcher.group(1)); @@ -198,8 +206,8 @@ public class IvyPlugin extends AbstractUIPlugin { ivyMarkerManager = new IvyMarkerManager(); File stateLocation = getStateLocation().toFile(); - ivyAttachementManager = new IvyAttachementManager(new File(stateLocation, - "attachements.properties")); + ivyAttachementManager = new IvyAttachementManager( + new File(stateLocation, "attachements.properties")); File containersStateDir = new File(stateLocation, "cpstates"); if (!containersStateDir.exists()) { containersStateDir.mkdirs(); @@ -211,8 +219,8 @@ public class IvyPlugin extends AbstractUIPlugin { Class.forName("org.apache.ivy.osgi.core.ManifestParser"); osgiAvailable = true; try { - Class.forName("org.apache.ivy.osgi.core.BundleInfo").getDeclaredMethod( - "getClasspath"); + Class.forName("org.apache.ivy.osgi.core.BundleInfo") + .getDeclaredMethod("getClasspath", new Class[] {}); osgiClasspathAvailable = true; } catch (Exception e) { osgiClasspathAvailable = false; http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/controller/SecuritySetupController.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/controller/SecuritySetupController.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/controller/SecuritySetupController.java new file mode 100644 index 0000000..21913dc --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/controller/SecuritySetupController.java @@ -0,0 +1,247 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.controller; + +import org.apache.ivyde.eclipse.GUIfactoryHelper; +import org.apache.ivyde.eclipse.IvyDEsecurityHelper; +import org.apache.ivyde.eclipse.cp.SecuritySetup; +import org.apache.ivyde.internal.eclipse.ui.SecuritySetupEditor; +import org.apache.ivyde.internal.eclipse.ui.components.SecuritySetupDialog; +import org.apache.ivyde.internal.eclipse.validator.BaseValidator; +import org.apache.ivyde.internal.eclipse.validator.IValidationReaction; +import org.apache.ivyde.internal.eclipse.validator.impl.HostValidator; +import org.apache.ivyde.internal.eclipse.validator.impl.IdValidator; +import org.apache.ivyde.internal.eclipse.validator.impl.PasswordValidator; +import org.apache.ivyde.internal.eclipse.validator.impl.RealmValidator; +import org.apache.ivyde.internal.eclipse.validator.impl.UserNameValidator; +import org.apache.ivyde.internal.eclipse.validator.reaction.GeneralValidationReaction; +import org.apache.ivyde.internal.eclipse.validator.reaction.NopValidationReaction; +import org.eclipse.core.databinding.AggregateValidationStatus; +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.UpdateValueStrategy; +import org.eclipse.core.databinding.ValidationStatusProvider; +import org.eclipse.core.databinding.beans.PojoProperties; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Widget; + +public class SecuritySetupController { + + private SecuritySetupEditor setupEditorGUI; + + private SecuritySetupDialog addDialog; + + private MessageDialog confirmationDialog; + + private SecuritySetup currentSelection = new SecuritySetup(); + + private SecuritySetup currentSelectionOldVal = new SecuritySetup(); + + private String selectionHost; + + private String selectionRealm; + + private String selectionUserName; + + private boolean addOperation = true; + + private DataBindingContext ctx = new DataBindingContext(); + + /** + * @param setupEditorGUI + * @param addDialog + */ + public SecuritySetupController(SecuritySetupEditor setupEditorGUI) { + this.setupEditorGUI = setupEditorGUI; + addDialog = new SecuritySetupDialog(setupEditorGUI.getShell()); + } + + public void addHandlers() { + setupEditorGUI.getAddBtn().addSelectionListener(this.createAddBtnSelectionAdapter()); + setupEditorGUI.getEditBtn().addSelectionListener(this.createEditBtnSelectionAdapter()); + setupEditorGUI.getDeleteBtn().addSelectionListener(this.createDelBtnSelectionAdapter()); + setupEditorGUI.getTableViewer() + .addSelectionChangedListener(this.createSelectionChangedListener()); + } + + private SelectionListener createAddBtnSelectionAdapter() { + return new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + addOperation = true; + currentSelection = new SecuritySetup(); + addDialog.create(); + initDialog(); + if (addDialog.open() == Window.OK) { + IvyDEsecurityHelper.addCredentialsToSecureStorage(currentSelection); + IvyDEsecurityHelper.addCredentialsToIvyCredentialStorage(currentSelection); + // TODO: using init to reload directly from secure storage or use an + // intermediate-container? + setupEditorGUI.init(IvyDEsecurityHelper.getCredentialsFromSecureStore()); + } else { + // TODO: do something? + } + addDialog.close(); + } + }; + } + + private SelectionListener createEditBtnSelectionAdapter() { + return new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + addOperation = false; + addDialog.create(); + initDialog(); + // initDialog(currentSelection); + if (addDialog.open() == Window.OK) { + IvyDEsecurityHelper.removeCredentials( + new SecuritySetup(selectionHost, selectionRealm, selectionUserName, "")); + IvyDEsecurityHelper.addCredentialsToSecureStorage(currentSelection); + IvyDEsecurityHelper.addCredentialsToIvyCredentialStorage(currentSelection); + // TODO: using init to reload directly from secure storage or use an + // intermediate-container? + setupEditorGUI.init(IvyDEsecurityHelper.getCredentialsFromSecureStore()); + setupEditorGUI.getEditBtn().setEnabled(false); + setupEditorGUI.getDeleteBtn().setEnabled(false); + } else { + currentSelection.setAllValues(currentSelectionOldVal); + } + addDialog.close(); + } + }; + } + + private SelectionListener createDelBtnSelectionAdapter() { + return new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + confirmationDialog = GUIfactoryHelper.buildConfirmationDialog( + setupEditorGUI.getShell(), "Confirmation", + "Remove selected credentials from secure storage?"); + if (confirmationDialog.open() == Window.OK) { + currentSelection.setHost(selectionHost); + currentSelection.setRealm(selectionRealm); + IvyDEsecurityHelper.removeCredentials( + new SecuritySetup(selectionHost, selectionRealm, selectionUserName, "")); + setupEditorGUI.init(IvyDEsecurityHelper.getCredentialsFromSecureStore()); + setupEditorGUI.getEditBtn().setEnabled(false); + setupEditorGUI.getDeleteBtn().setEnabled(false); + } + confirmationDialog.close(); + } + }; + } + + private ISelectionChangedListener createSelectionChangedListener() { + return new ISelectionChangedListener() { + @Override + public void selectionChanged(final SelectionChangedEvent event) { + IStructuredSelection selection = (IStructuredSelection) event.getSelection(); + currentSelection = (SecuritySetup) selection.getFirstElement(); + setupEditorGUI.getEditBtn().setEnabled(true); + setupEditorGUI.getDeleteBtn().setEnabled(true); + if (currentSelection != null) { + selectionHost = currentSelection.getHost(); + selectionRealm = currentSelection.getRealm(); + selectionUserName = currentSelection.getUserName(); + currentSelectionOldVal = new SecuritySetup(selectionHost, selectionRealm, + selectionUserName, currentSelection.getPwd()); + } else { + currentSelection = new SecuritySetup(); + } + } + }; + } + + private void createHostDataBinder(String selectedHost, String selectedRealm, + boolean isAddOperation) { + IValidationReaction generalValidationReaction = new GeneralValidationReaction( + this.addDialog.getOkButton(), this.addDialog.getErrorLabel(), + this.addDialog.getErrorIcon()); + IValidationReaction nopValidationReaction = new NopValidationReaction(); + + BaseValidator hostValidator = new HostValidator(generalValidationReaction); + BaseValidator realmValidator = new RealmValidator(generalValidationReaction); + BaseValidator idValidator = new IdValidator(generalValidationReaction, isAddOperation, + selectedHost, selectedRealm); + BaseValidator userNameValidator = new UserNameValidator(nopValidationReaction); + BaseValidator passwordValidator = new PasswordValidator(nopValidationReaction); + + this.addDataBinder(this.addDialog.getIdText(), idValidator, SecuritySetup.class, "id", + this.currentSelection, true); + this.addDataBinder(this.addDialog.getHostText(), hostValidator, SecuritySetup.class, "host", + this.currentSelection, true); + this.addDataBinder(this.addDialog.getRealmText(), realmValidator, SecuritySetup.class, + "realm", this.currentSelection, true); + this.addDataBinder(this.addDialog.getUserNameText(), userNameValidator, SecuritySetup.class, + "userName", this.currentSelection, true); + this.addDataBinder(this.addDialog.getPwdText(), passwordValidator, SecuritySetup.class, + "pwd", this.currentSelection, true); + } + + private void addDataBinder(Widget toObserve, IValidator validator, Class<?> observableClass, + String propertyName, Object observedProperty, boolean textDecorationEnabled) { + IObservableValue textObservable = WidgetProperties.text(SWT.Modify).observe(toObserve); + UpdateValueStrategy strategy = new UpdateValueStrategy(); + strategy.setBeforeSetValidator(validator); + + ValidationStatusProvider binding = this.ctx.bindValue(textObservable, + PojoProperties.value(observableClass, propertyName).observe(observedProperty), strategy, + null); + if (textDecorationEnabled) { + ControlDecorationSupport.create(binding, SWT.LEFT); + } + final IObservableValue errorObservable = WidgetProperties.text() + .observe(this.addDialog.getErrorLabel()); + + ctx.bindValue(errorObservable, new AggregateValidationStatus(ctx.getBindings(), + AggregateValidationStatus.MAX_SEVERITY), + null, null); + + } + + private void initDialog() { + this.createHostDataBinder(this.selectionHost, this.selectionRealm, this.addOperation); + + addDialog.getHostText().addModifyListener(createModifyListener()); + addDialog.getRealmText().addModifyListener(createModifyListener()); + } + + private ModifyListener createModifyListener() { + return new ModifyListener() { + public void modifyText(ModifyEvent e) { + addDialog.getIdText().setText( + addDialog.getHostText().getText() + "@" + addDialog.getRealmText().getText()); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/SecuritySetupContainer.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/SecuritySetupContainer.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/SecuritySetupContainer.java new file mode 100644 index 0000000..3ee3aac --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/SecuritySetupContainer.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.cpcontainer; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.ivyde.eclipse.cp.SecuritySetup; +@Deprecated +//TODO: really needed? +public final class SecuritySetupContainer { + + public static final SecuritySetupContainer INSTANCE = new SecuritySetupContainer(); + + private static List<SecuritySetup> credentials = new ArrayList<SecuritySetup>(); + + private SecuritySetupContainer() { + + } + + //test-data + static{ + credentials = new ArrayList<SecuritySetup>(); + credentials.add(new SecuritySetup("localhost","nexus","admin","secret")); + credentials.add(new SecuritySetup("arctis","nexus3","adminArctis","secret")); + credentials.add(new SecuritySetup("remote","nexus repo","adminRemote","secret")); + } + + public static void addEntry(SecuritySetup entry) { + credentials.add(entry); + } + + public static void removeEntry(SecuritySetup entry) { + credentials.remove(entry); + } + + public static List<SecuritySetup> getAllCredentials() { + return credentials; + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SecuritySetupEditor.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SecuritySetupEditor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SecuritySetupEditor.java new file mode 100644 index 0000000..c32b3c7 --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SecuritySetupEditor.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.ui; + +import java.util.List; + +import org.apache.ivyde.eclipse.GUIfactoryHelper; +import org.apache.ivyde.eclipse.cp.SecuritySetup; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Table; + +public class SecuritySetupEditor extends Composite { + + private TableViewer tableViewer; + private Group credentialsGroup; + private Button addBtn; + private Button editBtn; + private Button deleteBtn; + private Table table; + + public SecuritySetupEditor(Composite parent, int style) { + super(parent, style); + setLayout(new GridLayout()); + + credentialsGroup = new Group(this, style); + credentialsGroup.setText("Credentials"); + credentialsGroup.setLayout(new GridLayout(2, false)); + credentialsGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false,1,1)); + + tableViewer = new TableViewer(credentialsGroup, + SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); + + GUIfactoryHelper.buildTableColumn(tableViewer, 100, "Host", GUIfactoryHelper.buildHostLabelProvider()); + GUIfactoryHelper.buildTableColumn(tableViewer, 175, "Realm", GUIfactoryHelper.buildRealmLabelProvider()); + GUIfactoryHelper.buildTableColumn(tableViewer, 100, "Username", GUIfactoryHelper.buildUsernameLabelProvider()); + GUIfactoryHelper.buildTableColumn(tableViewer, 100, "Pwd", GUIfactoryHelper.buildPwdLabelProvider()); + + // make lines and header visible + table = tableViewer.getTable(); + table.setParent(credentialsGroup); + table.setHeaderVisible(true); + table.setLinesVisible(true); + + GridData tableGD = new GridData(GridData.FILL, GridData.FILL, true, false,1,3); + tableGD.heightHint=200; + table.setLayoutData(tableGD); + + addBtn = new Button(credentialsGroup, SWT.PUSH); + addBtn.setText("Add..."); + addBtn.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false,1,1)); + + editBtn = new Button(credentialsGroup, SWT.PUSH); + editBtn.setText("Edit..."); + editBtn.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false,1,1)); + editBtn.setEnabled(false); + + deleteBtn = new Button(credentialsGroup, SWT.PUSH); + deleteBtn.setText("Remove"); + deleteBtn.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false,1,1)); + deleteBtn.setEnabled(false); + } + + public void init(List<SecuritySetup> setup) { + this.tableViewer.setContentProvider(ArrayContentProvider.getInstance()); + this.tableViewer.setInput(setup); + } + + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + credentialsGroup.setEnabled(enabled); + addBtn.setEnabled(enabled); + editBtn.setEnabled(enabled); + deleteBtn.setEnabled(enabled); + table.setEnabled(enabled); + } + + /** + * @return the addBtn + */ + public Button getAddBtn() { + return addBtn; + } + + /** + * @return the editBtn + */ + public Button getEditBtn() { + return editBtn; + } + + /** + * @return the deleteBtn + */ + public Button getDeleteBtn() { + return deleteBtn; + } + + /** + * @return the tableViewer + */ + public TableViewer getTableViewer() { + return tableViewer; + } + + +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/components/CustomConfirmationDialog.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/components/CustomConfirmationDialog.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/components/CustomConfirmationDialog.java new file mode 100644 index 0000000..7189a79 --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/components/CustomConfirmationDialog.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.ui.components; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Shell; + +public class CustomConfirmationDialog extends MessageDialog { + + public CustomConfirmationDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, + String dialogMessage, int dialogImageType, int defaultIndex, + String[] dialogButtonLabels) { + super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, + dialogButtonLabels, defaultIndex); + } + + public CustomConfirmationDialog(Shell parentShell, String dialogTitle, String dialogMessage) { + super(parentShell, dialogTitle, null, dialogMessage, MessageDialog.CONFIRM, + new String[] {"Ok", "Cancel"}, 0); + } + + @Override + public Point getInitialSize() { + return new Point(400, 150); + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/components/SecuritySetupDialog.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/components/SecuritySetupDialog.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/components/SecuritySetupDialog.java new file mode 100644 index 0000000..50c4d4e --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/components/SecuritySetupDialog.java @@ -0,0 +1,225 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.ui.components; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +public class SecuritySetupDialog extends Dialog { + + public static final String TOOLTIP_HOST = "The host"; + + public static final String TOOLTIP_REALM = "The realm for authentication"; + + public static final String TOOLTIP_USERNAME = "The username"; + + public static final String TOOLTIP_PASSWORD = "The password"; + + private Text idText; + + private Text hostText; + + private Text realmText; + + private Text userNameText; + + private Text pwdText; + + private Label idLabel; + + private Label hostLabel; + + private Label realmLabel; + + private Label userNameLabel; + + private Label pwdLabel; + + private Label errorLabel; + + private Label errorIcon; + + public SecuritySetupDialog(Shell parentShell) { + super(parentShell); + } + + @Override + protected Control createDialogArea(Composite parent) { + + Composite errorContainer = (Composite) super.createDialogArea(parent); + GridLayout errorLayout = new GridLayout(2, false); + errorContainer.setLayout(errorLayout); + + errorIcon = new Label(errorContainer, SWT.NONE); + errorIcon.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); + // errorIcon.setLayoutData(new GridData(20,20)); + + errorLabel = new Label(errorContainer, SWT.NONE); + errorLabel.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false)); + + Label separator = new Label(errorContainer, SWT.HORIZONTAL | SWT.SEPARATOR); + separator.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 2, 1)); + + Composite container = (Composite) super.createDialogArea(parent); + GridLayout layout = new GridLayout(2, false); + // layout.marginRight = 5; + // layout.marginLeft = 10; + container.setLayout(layout); + + idLabel = new Label(container, SWT.NONE); + idLabel.setText("Id:"); + + idText = new Text(container, SWT.NONE); + idText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false)); + idText.setEditable(false); + idText.setEnabled(false); + + hostLabel = new Label(container, SWT.NONE); + hostLabel.setText("Host:"); + + hostText = new Text(container, SWT.SINGLE | SWT.BORDER); + hostText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false)); + hostText.setToolTipText(TOOLTIP_HOST); + + realmLabel = new Label(container, SWT.NONE); + realmLabel.setText("Realm:"); + + realmText = new Text(container, SWT.SINGLE | SWT.BORDER); + realmText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false)); + realmText.setToolTipText(TOOLTIP_REALM); + + userNameLabel = new Label(container, SWT.NONE); + userNameLabel.setText("Username:"); + + userNameText = new Text(container, SWT.SINGLE | SWT.BORDER); + userNameText.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false)); + userNameText.setToolTipText(TOOLTIP_USERNAME); + + pwdLabel = new Label(container, SWT.NONE); + pwdLabel.setText("Password:"); + + pwdText = new Text(container, SWT.PASSWORD | SWT.BORDER); + pwdText.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); + pwdText.setToolTipText(TOOLTIP_PASSWORD); + + return container; + } + + // overriding this methods allows you to set the + // title of the custom dialog + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + // newShell.setText("Add"); + } + + @Override + protected Point getInitialSize() { + return new Point(370, 280); + } + + public void setEnabled(boolean enabled) { + + // super.setEnabled(enabled); + idLabel.setEnabled(true); + idText.setEnabled(true); + hostLabel.setEnabled(enabled); + hostText.setEnabled(enabled); + realmLabel.setEnabled(enabled); + realmText.setEnabled(enabled); + userNameLabel.setEnabled(enabled); + userNameText.setEnabled(enabled); + pwdLabel.setEnabled(enabled); + pwdText.setEnabled(enabled); + + errorIcon.setEnabled(true); + errorLabel.setEnabled(true); + + } + + public Button getOkButton() { + return super.getButton(IDialogConstants.OK_ID); + } + + @Override + protected void okPressed() { + // TODO: Do something? + super.okPressed(); + } + + /** + * @return the hostText + */ + public Text getHostText() { + return hostText; + } + + /** + * @return the realmText + */ + public Text getRealmText() { + return realmText; + } + + /** + * @return the userNameText + */ + public Text getUserNameText() { + return userNameText; + } + + /** + * @return the pwdText + */ + public Text getPwdText() { + return pwdText; + } + + /** + * @return the idText + */ + public Text getIdText() { + return idText; + } + + /** + * @return the errorLabel + */ + public Label getErrorLabel() { + return errorLabel; + } + + /** + * @return the errorIcon + */ + public Label getErrorIcon() { + return errorIcon; + } + +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/SecuritySetupPreferencePage.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/SecuritySetupPreferencePage.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/SecuritySetupPreferencePage.java new file mode 100644 index 0000000..b37407b --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/SecuritySetupPreferencePage.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.ui.preferences; + +import org.apache.ivyde.eclipse.IvyDEsecurityHelper; +import org.apache.ivyde.eclipse.cp.SecuritySetup; +import org.apache.ivyde.internal.eclipse.IvyPlugin; +import org.apache.ivyde.internal.eclipse.controller.SecuritySetupController; +import org.apache.ivyde.internal.eclipse.ui.SecuritySetupEditor; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +public class SecuritySetupPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + /** the ID of the preference page */ + public static final String PEREFERENCE_PAGE_ID = "org.apache.ivyde.eclipse.ui.preferences.SecuritySetupPreferencePage"; + + private SecuritySetupEditor securitySetupComposite; + + private SecuritySetupController buttonController; + + public SecuritySetupPreferencePage() { + setPreferenceStore(IvyPlugin.getDefault().getPreferenceStore()); + } + + public void init(IWorkbench workbench) { + setPreferenceStore(IvyPlugin.getDefault().getPreferenceStore()); + } + + protected Control createContents(Composite parent) { + securitySetupComposite = new SecuritySetupEditor(parent, SWT.NONE); + securitySetupComposite + .setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); + + buttonController = new SecuritySetupController(securitySetupComposite); + buttonController.addHandlers(); + + securitySetupComposite.init(IvyDEsecurityHelper.getCredentialsFromSecureStore()); + + return securitySetupComposite; + } + + /* + * NOTE: The table containing the credentials is directly coupled with the eclipse + * secure-storage: + * - all operations are performed immediately on the secure-storage + * - performOk(), performApply() and performDefaults() won't have any additional effects: They just + * redo performed operations (for the sake of completeness) + */ + + @Override + public boolean performOk() { + // TODO: Do what? => directly coupled with secure-storage + IvyDEsecurityHelper.cpyCredentialsFromSecureToIvyStorage(); + return true; + } + + @Override + protected void performApply() { + // TODO: Do what? => directly coupled with secure-storage + IvyDEsecurityHelper.cpyCredentialsFromSecureToIvyStorage(); + super.performApply(); + } + + @Override + protected void performDefaults() { + // TODO: Do nothing? => directly coupled with secure-storage... + securitySetupComposite.init(IvyDEsecurityHelper.getCredentialsFromSecureStore()); + super.performDefaults(); + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/BaseValidator.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/BaseValidator.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/BaseValidator.java new file mode 100644 index 0000000..b1c87bd --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/BaseValidator.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.validator; + +import org.eclipse.core.databinding.validation.IValidator; +import org.eclipse.core.runtime.IStatus; + +public abstract class BaseValidator implements IValidator { + + private IValidationReaction reaction; + + private IStatus validationStatus; + + public static final String EMPTY_ERROR = "The property '$entry' cannot be empty"; + + public static final String EXISTING_ENTRY_ERROR = "An entry with that host and realm already exists"; + + public static final String VALID_MESSAGE = "Valid ivy credentials: Press 'OK' to save them"; + + public abstract boolean doValidation(Object validatedObject); + + @Override + public IStatus validate(Object value) { + if (doValidation(value)) { + this.reaction.ok(); + } else { + this.reaction.error(); + } + return this.validationStatus; + } + + /** + * @param exclusion + * @param reaction + */ + public BaseValidator(IValidationReaction reaction) { + this.reaction = reaction; + } + + public void setValidationStatus(IStatus validationStatus) { + this.validationStatus = validationStatus; + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/IValidationReaction.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/IValidationReaction.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/IValidationReaction.java new file mode 100644 index 0000000..94d2204 --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/IValidationReaction.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.validator; + +public interface IValidationReaction { + + public void ok(); + + public void error(); +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/HostValidator.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/HostValidator.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/HostValidator.java new file mode 100644 index 0000000..6d476d8 --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/HostValidator.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.validator.impl; + +import org.apache.ivyde.internal.eclipse.validator.BaseValidator; +import org.apache.ivyde.internal.eclipse.validator.IValidationReaction; +import org.eclipse.core.databinding.validation.ValidationStatus; +import org.eclipse.core.runtime.IStatus; + +public class HostValidator extends BaseValidator { + + /** + * @param reaction + */ + public HostValidator(IValidationReaction reaction) { + super(reaction); + } + + @Override + public boolean doValidation(Object validatedObject) { + String host = (String) validatedObject; + boolean valid = !host.equals(""); + IStatus validationStatus = valid ? ValidationStatus.ok() + : ValidationStatus.error(EMPTY_ERROR.replace("$entry", "Host")); + super.setValidationStatus(validationStatus); + return !host.equals(""); + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/IdValidator.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/IdValidator.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/IdValidator.java new file mode 100644 index 0000000..6a5cdf9 --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/IdValidator.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.validator.impl; + +import org.apache.ivyde.eclipse.IvyDEsecurityHelper; +import org.apache.ivyde.internal.eclipse.validator.BaseValidator; +import org.apache.ivyde.internal.eclipse.validator.IValidationReaction; +import org.eclipse.core.databinding.validation.ValidationStatus; +import org.eclipse.core.runtime.IStatus; + +public class IdValidator extends BaseValidator { + + private boolean isAddOperation; + + private String prevHostVal; + + private String prevRealmVal; + + /** + * @param reaction + * @param isAddOperation + * @param prevHostVal + * @param prevRealmVal + */ + public IdValidator(IValidationReaction reaction, boolean isAddOperation, String prevHostVal, + String prevRealmVal) { + super(reaction); + this.isAddOperation = isAddOperation; + this.prevHostVal = prevHostVal; + this.prevRealmVal = prevRealmVal; + } + + @Override + public boolean doValidation(Object validatedObject) { + String id = (String) validatedObject; + String[] hostRealm = id.split("@"); + boolean valid = true; + String message = VALID_MESSAGE; + IStatus validationStatus; + if (id.equals("") || id.equals("@")) { + message = "Properties 'Host' and 'Realm' cannot be empty"; + valid = false; + } else if (id.indexOf("@") == 0) { + message = EMPTY_ERROR.replace("$entry", "Host"); + valid = false; + } else if (id.indexOf("@") == id.length() - 1) { + message = EMPTY_ERROR.replace("$entry", "Realm"); + valid = false; + } else if (!isAddOperation && prevHostVal.equals(hostRealm[0]) + && prevRealmVal.equals(hostRealm[1])) { + valid = true; + } else if (IvyDEsecurityHelper.hostExistsInSecureStorage(hostRealm[0], hostRealm[1])) { + message = EXISTING_ENTRY_ERROR; + valid = false; + } + + if (valid) { + validationStatus = ValidationStatus.info(message); + } else { + validationStatus = ValidationStatus.error(message); + } + super.setValidationStatus(validationStatus); + return valid; + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/PasswordValidator.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/PasswordValidator.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/PasswordValidator.java new file mode 100644 index 0000000..88d18df --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/PasswordValidator.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.validator.impl; + +import org.apache.ivyde.internal.eclipse.validator.BaseValidator; +import org.apache.ivyde.internal.eclipse.validator.IValidationReaction; +import org.eclipse.core.databinding.validation.ValidationStatus; + +public class PasswordValidator extends BaseValidator { + + public PasswordValidator(IValidationReaction reaction) { + super(reaction); + } + + @Override + public boolean doValidation(Object validatedObject) { + // TODO Validation here? + super.setValidationStatus(ValidationStatus.ok()); + return true; + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/RealmValidator.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/RealmValidator.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/RealmValidator.java new file mode 100644 index 0000000..4dcfd67 --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/RealmValidator.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.validator.impl; + +import org.apache.ivyde.internal.eclipse.validator.BaseValidator; +import org.apache.ivyde.internal.eclipse.validator.IValidationReaction; +import org.eclipse.core.databinding.validation.ValidationStatus; +import org.eclipse.core.runtime.IStatus; + +public class RealmValidator extends BaseValidator { + + /** + * @param reaction + */ + public RealmValidator(IValidationReaction reaction) { + super(reaction); + } + + @Override + public boolean doValidation(Object validatedObject) { + String realm = (String) validatedObject; + boolean valid = !realm.equals(""); + IStatus validationStatus = valid ? ValidationStatus.ok() + : ValidationStatus.error(EMPTY_ERROR.replace("$entry", "Realm")); + super.setValidationStatus(validationStatus); + return !realm.equals(""); + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/UserNameValidator.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/UserNameValidator.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/UserNameValidator.java new file mode 100644 index 0000000..5d9c4c4 --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/impl/UserNameValidator.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.validator.impl; + +import org.apache.ivyde.internal.eclipse.validator.BaseValidator; +import org.apache.ivyde.internal.eclipse.validator.IValidationReaction; +import org.eclipse.core.databinding.validation.ValidationStatus; + +public class UserNameValidator extends BaseValidator { + + /** + * @param reaction + */ + public UserNameValidator(IValidationReaction reaction) { + super(reaction); + } + + @Override + public boolean doValidation(Object validatedObject) { + // TODO Validation here? + super.setValidationStatus(ValidationStatus.ok()); + return true; + } +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/reaction/GeneralValidationReaction.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/reaction/GeneralValidationReaction.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/reaction/GeneralValidationReaction.java new file mode 100644 index 0000000..0020bdf --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/reaction/GeneralValidationReaction.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.validator.reaction; + +import org.apache.ivyde.internal.eclipse.validator.IValidationReaction; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Label; + +public class GeneralValidationReaction implements IValidationReaction { + + private Button okButton; + + private Label errorLabel; + + private Label errorIcon; + + @Override + public void ok() { + this.okButton.setEnabled(true); + // this.errorIcon.setVisible(false); + // this.errorLabel.setVisible(false); + this.errorIcon.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO)); + } + + /** + * @param okButton + * @param errorLabel + * @param errorIcon + */ + public GeneralValidationReaction(Button okButton, Label errorLabel, Label errorIcon) { + this.okButton = okButton; + this.errorLabel = errorLabel; + this.errorIcon = errorIcon; + } + + @Override + public void error() { + this.okButton.setEnabled(false); + this.errorIcon.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); + // this.errorLabel.setText("Insert credentials"); + } + +} http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/df5fead5/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/reaction/NopValidationReaction.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/reaction/NopValidationReaction.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/reaction/NopValidationReaction.java new file mode 100644 index 0000000..9bf63af --- /dev/null +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/validator/reaction/NopValidationReaction.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivyde.internal.eclipse.validator.reaction; + +import org.apache.ivyde.internal.eclipse.validator.IValidationReaction; + +public class NopValidationReaction implements IValidationReaction { + + @Override + public void ok() { + // Do nothing ;-) + } + + @Override + public void error() { + // Do nothing ;-) + } + +}