on 07-07-2004 4:50 PM
I'm trying you use code from example in the manual to read Cookie from HttpRequest but it has and error, CallbackHandler is an interface. How can I get reference to CallbackHandler?
Thanks,
Andrei.
HttpGetterCallback getterCallback = new HttpGetterCallback ();
getterCallback.setTypeHttpGetterCallback.COOKIE);
getterCallback.setName("ticket");
<b>// the string below is not right CallbackHandler is an interface
</b> CallbackHandler.handle(new Callback[] getterCallback});
// Gets the ticket that is in the cookies
Object value = getterCallback.getValue();
Hi Andrei,
Each implementation of LoginModule interface has an initialize method. This method is called by the LoginContext in order to initialize the LoginModule with the relevant information. One of the parameters passed to this method is the CallbackHandler. What you can do is to use this handler. For example:
private CallbackHandler callbackHandler = null;
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
.
this.callbackHandler = callbackHandler;
.
}
And afterwards you can use callbackHandler like you wish:
HttpGetterCallback getterCallback = new HttpGetterCallback();
getterCallback.setType(HttpGetterCallback.COOKIE);
getterCallback.setName("ticket");
try{
callbackHandler.handle(new Callback[]
getterCallback});
} catch (Exception e) {
e.printStackTrace();
throw new LoginException("Callbacks invokation failed! " + e);
}
Object value = getterCallback.getValue();
Best regards,
Diyan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.