Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-12-13 23:24:57 +0000
committerslewis2007-12-13 23:24:57 +0000
commitc54f3e9c3369ce917f6df187095b2975dd51beec (patch)
treee40719a01352a7343740b620a91e0f21333b973c /framework/bundles
parent4846f42b5a833c59a266f153c5abb56b3552f81c (diff)
downloadorg.eclipse.ecf-c54f3e9c3369ce917f6df187095b2975dd51beec.tar.gz
org.eclipse.ecf-c54f3e9c3369ce917f6df187095b2975dd51beec.tar.xz
org.eclipse.ecf-c54f3e9c3369ce917f6df187095b2975dd51beec.zip
Added further callback types
Diffstat (limited to 'framework/bundles')
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ConnectContextFactory.java12
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/PassphraseCallback.java115
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/PasswordCallback.java115
3 files changed, 242 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ConnectContextFactory.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ConnectContextFactory.java
index 6fe827840..18a469ed6 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ConnectContextFactory.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/ConnectContextFactory.java
@@ -48,6 +48,12 @@ public class ConnectContextFactory {
} else if (callbacks[i] instanceof ObjectCallback) {
ObjectCallback ocb = (ObjectCallback) callbacks[i];
ocb.setObject(password);
+ } else if (callbacks[i] instanceof PasswordCallback && password instanceof String) {
+ PasswordCallback pc = (PasswordCallback) callbacks[i];
+ pc.setPassword((String) password);
+ } else if (callbacks[i] instanceof PassphraseCallback && password instanceof String) {
+ PassphraseCallback pc = (PassphraseCallback) callbacks[i];
+ pc.setPassphrase((String) password);
}
}
}
@@ -80,6 +86,12 @@ public class ConnectContextFactory {
if (callbacks[i] instanceof ObjectCallback) {
ObjectCallback ocb = (ObjectCallback) callbacks[i];
ocb.setObject(password);
+ } else if (callbacks[i] instanceof PasswordCallback) {
+ PasswordCallback pc = (PasswordCallback) callbacks[i];
+ pc.setPassword(password);
+ } else if (callbacks[i] instanceof PassphraseCallback) {
+ PassphraseCallback pc = (PassphraseCallback) callbacks[i];
+ pc.setPassphrase(password);
}
}
}
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/PassphraseCallback.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/PassphraseCallback.java
new file mode 100644
index 000000000..8f1435817
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/PassphraseCallback.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, Inc. 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.security;
+
+import org.eclipse.ecf.internal.core.Messages;
+
+/**
+ * Callback that handles passphrases
+ *
+ */
+public class PassphraseCallback implements Callback, java.io.Serializable {
+
+ private static final long serialVersionUID = -6036907502015127266L;
+
+ private String prompt;
+
+ private String defaultPassphrase;
+
+ private String inputPassphrase;
+
+ /**
+ * Construct a <code>PassphraseCallback</code> with a prompt.
+ *
+ * @param prompt
+ * the prompt used to request the passphrase.
+ *
+ * @exception IllegalArgumentException
+ * if <code>prompt</code> is null.
+ */
+ public PassphraseCallback(String prompt) {
+ if (prompt == null)
+ throw new IllegalArgumentException(Messages.BooleanCallback_EXCEPTION_INVALID_BOOLEAN_ARGUMENT);
+ this.prompt = prompt;
+ }
+
+ /**
+ * Construct a <code>PassphraseCallback</code> with a prompt and default passphrase.
+ *
+ * <p>
+ *
+ * @param prompt
+ * the prompt used to request the information.
+ * <p>
+ *
+ * @param defaultPassphrase
+ * the name to be used as the default name displayed with the
+ * prompt.
+ *
+ * @exception IllegalArgumentException
+ * if <code>prompt</code> is null.
+ */
+ public PassphraseCallback(String prompt, String defaultPassphrase) {
+ if (prompt == null)
+ throw new IllegalArgumentException(Messages.BooleanCallback_EXCEPTION_INVALID_BOOLEAN_ARGUMENT);
+ this.prompt = prompt;
+ this.defaultPassphrase = defaultPassphrase;
+ }
+
+ /**
+ * Get the prompt.
+ *
+ * <p>
+ *
+ * @return the prompt.
+ */
+ public String getPrompt() {
+ return prompt;
+ }
+
+ /**
+ * Get the default passphrase.
+ *
+ * <p>
+ *
+ * @return the default passphrase, or <code>null</code> if this <code>PassphraseCallback</code> was
+ * not instantiated with a <code>defaultPassphrase</code>.
+ */
+ public String getDefaultPassphrase() {
+ return defaultPassphrase;
+ }
+
+ /**
+ * Set the retrieved passphrase.
+ *
+ * <p>
+ *
+ * @param pw
+ * the passphrase (which may be null).
+ *
+ * @see #getPassphrase
+ */
+ public void setPassphrase(String pw) {
+ this.inputPassphrase = pw;
+ }
+
+ /**
+ * Get the retrieved passphrase.
+ *
+ * <p>
+ *
+ * @return the retrieved passphrase (which may be null)
+ *
+ * @see #setPassphrase
+ */
+ public String getPassphrase() {
+ return inputPassphrase;
+ }
+
+}
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/PasswordCallback.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/PasswordCallback.java
new file mode 100644
index 000000000..d8fb35fc8
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/security/PasswordCallback.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Composent, Inc. 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: Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.core.security;
+
+import org.eclipse.ecf.internal.core.Messages;
+
+/**
+ * Callback that handles passwords
+ *
+ */
+public class PasswordCallback implements Callback, java.io.Serializable {
+
+ private static final long serialVersionUID = 6940002988125290335L;
+
+ private String prompt;
+
+ private String defaultPassword;
+
+ private String inputPassword;
+
+ /**
+ * Construct a <code>PasswordCallback</code> with a prompt.
+ *
+ * @param prompt
+ * the prompt used to request the name.
+ *
+ * @exception IllegalArgumentException
+ * if <code>prompt</code> is null.
+ */
+ public PasswordCallback(String prompt) {
+ if (prompt == null)
+ throw new IllegalArgumentException(Messages.BooleanCallback_EXCEPTION_INVALID_BOOLEAN_ARGUMENT);
+ this.prompt = prompt;
+ }
+
+ /**
+ * Construct a <code>PasswordCallback</code> with a prompt and default password.
+ *
+ * <p>
+ *
+ * @param prompt
+ * the prompt used to request the information.
+ * <p>
+ *
+ * @param defaultPassword
+ * the name to be used as the default name displayed with the
+ * prompt.
+ *
+ * @exception IllegalArgumentException
+ * if <code>prompt</code> is null.
+ */
+ public PasswordCallback(String prompt, String defaultPassword) {
+ if (prompt == null)
+ throw new IllegalArgumentException(Messages.BooleanCallback_EXCEPTION_INVALID_BOOLEAN_ARGUMENT);
+ this.prompt = prompt;
+ this.defaultPassword = defaultPassword;
+ }
+
+ /**
+ * Get the prompt.
+ *
+ * <p>
+ *
+ * @return the prompt.
+ */
+ public String getPrompt() {
+ return prompt;
+ }
+
+ /**
+ * Get the default password.
+ *
+ * <p>
+ *
+ * @return the default password, or <code>null</code> if this <code>PasswordCallback</code> was
+ * not instantiated with a <code>defaultPassword</code>.
+ */
+ public String getDefaultPassword() {
+ return defaultPassword;
+ }
+
+ /**
+ * Set the retrieved password.
+ *
+ * <p>
+ *
+ * @param pw
+ * the password (which may be null).
+ *
+ * @see #getPassword
+ */
+ public void setPassword(String pw) {
+ this.inputPassword = pw;
+ }
+
+ /**
+ * Get the retrieved password.
+ *
+ * <p>
+ *
+ * @return the retrieved password (which may be null)
+ *
+ * @see #setPassword
+ */
+ public String getPassword() {
+ return inputPassword;
+ }
+
+}

Back to the top