Skip to Content
avatar image
Former Member

How to get a reference to CallbackHandler?

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();

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Jul 23, 2004 at 08:22 AM

    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

    Add comment
    10|10000 characters needed characters exceeded