summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Campo2008-01-18 09:47:24 (EST)
committerChristian Campo2008-01-18 09:47:24 (EST)
commit17a09a11977314c9e0f11d09f4f43722d92b8875 (patch)
tree66727eca8158452c5727e6c28d8a5cb6a16d801e
parent24d40056a3f12b0cf3b5153df01f0dd9cb141d4c (diff)
downloadorg.eclipse.riena-17a09a11977314c9e0f11d09f4f43722d92b8875.zip
org.eclipse.riena-17a09a11977314c9e0f11d09f4f43722d92b8875.tar.gz
org.eclipse.riena-17a09a11977314c9e0f11d09f4f43722d92b8875.tar.bz2
rewritten handle method
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/MyCallbackHandler.java50
1 files changed, 19 insertions, 31 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/MyCallbackHandler.java b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/MyCallbackHandler.java
index c885af5..3aee19a 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/MyCallbackHandler.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/security/services/itest/MyCallbackHandler.java
@@ -10,14 +10,11 @@
*******************************************************************************/
package org.eclipse.riena.security.services.itest;
-import java.io.IOException;
-
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.TextOutputCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
public class MyCallbackHandler implements CallbackHandler {
@@ -29,47 +26,38 @@ public class MyCallbackHandler implements CallbackHandler {
this.password = password;
}
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ public void handle(Callback[] callbacks) {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof TextOutputCallback) {
-
- // display the message according to the specified type
TextOutputCallback toc = (TextOutputCallback) callbacks[i];
+ String typeAsString;
+ // detect textoutput message type and translate it to string
switch (toc.getMessageType()) {
case TextOutputCallback.INFORMATION:
- System.out.println(toc.getMessage());
+ typeAsString = "information";
break;
case TextOutputCallback.ERROR:
- System.out.println("ERROR: " + toc.getMessage());
+ typeAsString = "error";
break;
case TextOutputCallback.WARNING:
- System.out.println("WARNING: " + toc.getMessage());
+ typeAsString = "warning";
break;
default:
- throw new IOException("Unsupported message type: " + toc.getMessageType());
+ typeAsString = "unknown";
+ break;
+ }
+ System.out.println(typeAsString + " " + toc.getMessage());
+ } else {
+ if (callbacks[i] instanceof NameCallback) {
+ NameCallback nc = (NameCallback) callbacks[i];
+ nc.setName(name);
+ } else {
+ if (callbacks[i] instanceof PasswordCallback) {
+ PasswordCallback pc = (PasswordCallback) callbacks[i];
+ pc.setPassword(password.toCharArray());
+ }
}
-
- } else if (callbacks[i] instanceof NameCallback) {
- // prompt the user for a username
- NameCallback nc = (NameCallback) callbacks[i];
-
- // System.err.print(nc.getPrompt());
- // System.err.flush();
- // nc.setName((new BufferedReader(new
- // InputStreamReader(System.in))).readLine());
- nc.setName(name);
-
- } else if (callbacks[i] instanceof PasswordCallback) {
-
- // prompt the user for sensitive information
- PasswordCallback pc = (PasswordCallback) callbacks[i];
- // System.err.print(pc.getPrompt());
- // System.err.flush();
- // pc.setPassword((new BufferedReader(new
- // InputStreamReader(System.in))).readLine().toCharArray());
- pc.setPassword(password.toCharArray());
}
-
}
}
} \ No newline at end of file