1 17 package org.apache.geronimo.security.jaas; 18 19 import javax.security.auth.callback.Callback ; 20 import javax.security.auth.callback.CallbackHandler ; 21 import javax.security.auth.callback.UnsupportedCallbackException ; 22 23 33 public class DecouplingCallbackHandler implements CallbackHandler { 34 private Callback [] source; 35 private boolean exploring = true; 36 37 public DecouplingCallbackHandler() { 38 } 39 40 public void handle(Callback [] callbacks) 41 throws IllegalArgumentException , UnsupportedCallbackException { 42 if (exploring) { 43 source = callbacks; 44 throw new UnsupportedCallbackException (callbacks != null && callbacks.length > 0 ? callbacks[0] : null, "DO NOT PROCEED WITH THIS LOGIN"); 45 } else { 46 if(callbacks.length != source.length) { 47 throw new IllegalArgumentException ("Mismatched callbacks"); 48 } 49 for (int i = 0; i < callbacks.length; i++) { 50 callbacks[i] = source[i]; 51 } 52 } 53 } 54 55 63 public void setClientResponse(Callback [] callbacks) throws IllegalArgumentException { 64 if(source == null && callbacks == null) { 65 return; } 67 if(callbacks.length != source.length) { 68 throw new IllegalArgumentException ("Mismatched callbacks"); 69 } 70 for (int i = 0; i < callbacks.length; i++) { 71 source[i] = callbacks[i]; 72 } 73 } 74 75 76 81 public void setExploring() { 82 exploring = true; 83 source = null; 84 } 85 86 89 public Callback [] finalizeCallbackList() { 90 exploring = false; 91 return source; 92 } 93 } 94 | Popular Tags |