List of usage examples for javax.security.auth.callback ConfirmationCallback OK
int OK
To view the source code for javax.security.auth.callback ConfirmationCallback OK.
Click Source Link
From source file:it.cnr.icar.eric.client.xml.registry.jaas.ThinClientCallbackHandler.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> * *///from w w w.j av a2s . com public void handle(Callback[] callbacks) throws UnsupportedCallbackException { 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) { // For now hard-code the alias of the the RegistryOperator account NameCallback nc = (NameCallback) callbacks[i]; String alias = ProviderProperties.getInstance().getProperty("jaxr-ebxml.security.alias"); if (alias == null) { String message = "Error: the jaxr-ebxml.security.alias " + "property must be set"; log.error(message); System.err.println(message); alias = ""; } nc.setName(alias); } else if (callbacks[i] instanceof PasswordCallback) { // For now hard-code the password of the the RegistryOperator account PasswordCallback pc = (PasswordCallback) callbacks[i]; char[] password = null; if (handleStorePass) { String storepass = ProviderProperties.getInstance() .getProperty("jaxr-ebxml.security.storepass"); if (storepass == null) { storepass = "ebxmlrr"; } password = storepass.toCharArray(); handleStorePass = false; } else { String keypass = ProviderProperties.getInstance().getProperty("jaxr-ebxml.security.keypass"); if (keypass == null) { String message = "Error: the jaxr-ebxml.security.keypass " + "property must be set"; log.error(message); System.err.println(message); keypass = ""; } password = keypass.toCharArray(); } pc.setPassword(password); } else if (callbacks[i] instanceof ConfirmationCallback) { ConfirmationCallback cc = (ConfirmationCallback) callbacks[i]; cc.setSelectedIndex(ConfirmationCallback.OK); } else { throw new UnsupportedCallbackException(callbacks[i], JAXRResourceBundle.getInstance().getString("message.error.unrecognized.callback")); } } }
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> * *//*from w w w . j a v a 2s . 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")); } } }