![]()
Authentication Manager
The authentication manager handles both proxy and Web authentication. It supports basic and digest authentication schemes. It provides a callback that you can use to request the name and password from the user. If the platform the module is run on does not have the java.security package, digest authentication is disabled.
To use the AuthenticationManager, add code similar to the following to your application:
import ice.net.AuthenticationEvent; import ice.net.AuthenticationListener; import ice.net.AuthenticationManager; import ice.net.HttpURLConnection; AuthenticationManager authenticationManager = new AuthenticationManager(); autenticationManager.addAuthenticationListener( new AuthenticationListener() { public void onAuthenticationEvent(AuthenticationEvent event) { new AuthenticationDialog( event.getAuthentication()).show(); } }); HttpURLConnection.setGlobalAuthenticationManager( authenticationManager);
You need to implement the AuthenticationDialog. For example, a dialog that implements ActionListener can contain the following code to support the authentication:public void actionPerformed(ActionEvent event) { Object source = event.getSource(); if (source == okButton) { authentication.setUserName( usernameTextField.getText()); authentication.setPassword( passwordTextField.getText()); setVisible(false); dispose(); } else if (source == cancelButton) { authentication.setGiveUp(true); setVisible(false); dispose(); } }For more information on the authentication manager, see the API documentation for ice.net.AuthenticationManager.
|
Copyright 2005. ICEsoft Technologies, Inc. http://www.icesoft.com |