1 17 package org.apache.geronimo.security.jaas.server; 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) throws IllegalArgumentException , UnsupportedCallbackException { 41 if (exploring) { 42 source = callbacks; 43 throw new UnsupportedCallbackException (callbacks != null && callbacks.length > 0 ? callbacks[0] : null, "DO NOT PROCEED WITH THIS LOGIN"); 44 } else { 45 if(callbacks.length != source.length) { 46 throw new IllegalArgumentException ("Mismatched callbacks"); 47 } 48 for (int i = 0; i < callbacks.length; i++) { 49 callbacks[i] = source[i]; 50 } 51 } 52 } 53 54 62 public void setClientResponse(Callback [] callbacks) throws IllegalArgumentException { 63 if(source == null && callbacks == null) { 64 return; } 66 if(callbacks.length != source.length) { 67 throw new IllegalArgumentException ("Mismatched callbacks"); 68 } 69 for (int i = 0; i < callbacks.length; i++) { 70 source[i] = callbacks[i]; 71 } 72 } 73 74 75 80 public void setExploring() { 81 exploring = true; 82 source = null; 83 } 84 85 88 public Callback [] finalizeCallbackList() { 89 exploring = false; 90 return source; 91 } 92 } 93 | Popular Tags |