01: /*
02: * Copyright 2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ws.soap.security.xwss.callback;
18:
19: import java.io.IOException;
20:
21: import javax.security.auth.callback.Callback;
22: import javax.security.auth.callback.CallbackHandler;
23: import javax.security.auth.callback.UnsupportedCallbackException;
24:
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27:
28: /**
29: * Abstract implementation of a <code>CallbackHandler</code>.
30: *
31: * @author Arjen Poutsma
32: */
33: public abstract class AbstractCallbackHandler implements
34: CallbackHandler {
35:
36: /**
37: * Logger available to subclasses.
38: */
39: protected final Log logger = LogFactory.getLog(getClass());
40:
41: protected AbstractCallbackHandler() {
42: }
43:
44: /**
45: * Iterates over the given callbacks, and calls <code>handleInternal</code> for each of them.
46: *
47: * @param callbacks the callbacks
48: * @see #handleInternal(javax.security.auth.callback.Callback)
49: */
50: public final void handle(Callback[] callbacks) throws IOException,
51: UnsupportedCallbackException {
52: for (int i = 0; i < callbacks.length; i++) {
53: handleInternal(callbacks[i]);
54: }
55: }
56:
57: /**
58: * Template method that should be implemented by subclasses.
59: */
60: protected abstract void handleInternal(Callback callback)
61: throws IOException, UnsupportedCallbackException;
62: }
|