List of usage examples for javax.security.auth.callback ConfirmationCallback CANCEL
int CANCEL
To view the source code for javax.security.auth.callback ConfirmationCallback CANCEL.
Click Source Link
From source file:it.cnr.icar.eric.client.xml.registry.jaas.DialogAuthenticationCallbackHandler.java
/** Implementation of the handle method specified by * <code> javax.security.auth.callback.CallbackHandler </code> * @param callbacks <code>Array of javax.security.auth.callback.CallbackHandler</code> * */// w w w. j av a2 s. c o m public void handle(Callback[] callbacks) throws UnsupportedCallbackException { int result = showDialog(); for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof TextOutputCallback) { // Ignore this section for now. This will be used when a generic callback handler // is being implemented. In our current implementation, we are only expecting the //login type callback handler. } else if (callbacks[i] instanceof NameCallback) { // prompt the user for a username NameCallback nc = (NameCallback) callbacks[i]; String strPrompt = nc.getPrompt(); String strName = ""; // if (strPrompt.equals(authResBundle.getString("Keystore alias: "))) { if (strPrompt.equals(authResBundle.getString("Keystore.alias."))) { strName = txtAlias.getText(); } nc.setName(strName); } else if (callbacks[i] instanceof PasswordCallback) { // prompt the user for sensitive information PasswordCallback pc = (PasswordCallback) callbacks[i]; String strPrompt = pc.getPrompt(); char[] chrPass = new char[0]; // if (strPrompt.equals(authResBundle.getString("Keystore password: "))) { if (strPrompt.equals(authResBundle.getString("Keystore.password."))) { /* As of now hide the Keystore password part from the user and read directly from the properties file chrPass = txtStorepass.getPassword() ; */ chrPass = ProviderProperties.getInstance().getProperty("jaxr-ebxml.security.storepass") .toCharArray(); if ((chrPass == null) || (chrPass.length == 0)) { log.error("Property jaxr-ebxml.security.storepass is undefined"); } // } else if (strPrompt.equals(authResBundle.getString("Private key password (optional): "))) { } else if (strPrompt.equals(authResBundle.getString("Private.key.password.optional."))) { chrPass = txtKeypass.getPassword(); } pc.setPassword(chrPass); } else if (callbacks[i] instanceof ConfirmationCallback) { ConfirmationCallback cc = (ConfirmationCallback) callbacks[i]; if (result == OK) { cc.setSelectedIndex(ConfirmationCallback.OK); } else { cc.setSelectedIndex(ConfirmationCallback.CANCEL); } } else { throw new UnsupportedCallbackException(callbacks[i], JAXRResourceBundle.getInstance().getString("message.error.unrecognized.callback")); } } }