javax.security.auth.callback.UnsupportedCallbackException Java Examples
The following examples show how to use
javax.security.auth.callback.UnsupportedCallbackException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JAASMemoryLoginModule.java From Tomcat8-Source-Read with MIT License | 6 votes |
private String getCatalinaBase() { // Have to get this via a callback as that is the only link we have back // to the defining Realm. Can't use the system property as that may not // be set/correct in an embedded scenario if (callbackHandler == null) { return null; } Callback callbacks[] = new Callback[1]; callbacks[0] = new TextInputCallback("catalinaBase"); String result = null; try { callbackHandler.handle(callbacks); result = ((TextInputCallback) callbacks[0]).getText(); } catch (IOException | UnsupportedCallbackException e) { return null; } return result; }
Example #2
Source File: SecureAxisServiceClient.java From micro-integrator with Apache License 2.0 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[0]; String id = pwcb.getIdentifer(); int usage = pwcb.getUsage(); if (usage == WSPasswordCallback.SIGNATURE || usage == WSPasswordCallback.DECRYPT) { // Logic to get the private key password for signture or decryption if ("client".equals(id)) { pwcb.setPassword("automation"); } else if ("service".equals(id)) { pwcb.setPassword("automation"); } else if ("wso2carbon".equals(id)) { pwcb.setPassword("wso2carbon"); } else if ("alice".equals(id)) { pwcb.setPassword("password"); } else if ("bob".equals(id)) { pwcb.setPassword("password"); } } }
Example #3
Source File: SecurityServiceImpl.java From sql-layer with GNU Affero General Public License v3.0 | 6 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { ((NameCallback)callback).setName(name); } else if (callback instanceof PasswordCallback) { ((PasswordCallback)callback).setPassword(password.toCharArray()); } else if (jettyCallback(callback)) { try { jettySetObjectMethod.invoke(callback, password); } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } else { throw new UnsupportedCallbackException(callback); } } }
Example #4
Source File: DefaultCallbackHandler.java From Bats with Apache License 2.0 | 6 votes |
protected void processCallback(Callback callback) throws IOException, UnsupportedCallbackException { if (callback instanceof NameCallback) { NameCallback namecb = (NameCallback)callback; namecb.setName(context.getValue(SecurityContext.USER_NAME)); } else if (callback instanceof PasswordCallback) { PasswordCallback passcb = (PasswordCallback)callback; passcb.setPassword(context.getValue(SecurityContext.PASSWORD)); } else if (callback instanceof RealmCallback) { RealmCallback realmcb = (RealmCallback)callback; realmcb.setText(context.getValue(SecurityContext.REALM)); } else if (callback instanceof TextOutputCallback) { TextOutputCallback textcb = (TextOutputCallback)callback; if (textcb.getMessageType() == TextOutputCallback.INFORMATION) { logger.info(textcb.getMessage()); } else if (textcb.getMessageType() == TextOutputCallback.WARNING) { logger.warn(textcb.getMessage()); } else if (textcb.getMessageType() == TextOutputCallback.ERROR) { logger.error(textcb.getMessage()); } else { logger.debug("Auth message type {}, message {}", textcb.getMessageType(), textcb.getMessage()); } } else { throw new UnsupportedCallbackException(callback); } }
Example #5
Source File: UsernamePasswordCallback.java From cxf with Apache License 2.0 | 6 votes |
/** * Here, we attempt to get the password from the private alias/passwords map. */ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pc = (WSPasswordCallback)callbacks[i]; // System.out.println("**************** Server checking id: "+pc.getIdentifer()); String pass = passwords.get(pc.getIdentifier()); if (pass != null) { pc.setPassword(pass); return; } } // // Password not found // throw new IOException(); }
Example #6
Source File: NegotiateCallbackHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void handle(Callback[] callbacks) throws UnsupportedCallbackException, IOException { for (int i=0; i<callbacks.length; i++) { Callback callBack = callbacks[i]; if (callBack instanceof NameCallback) { getAnswer(); ((NameCallback)callBack).setName(username); } else if (callBack instanceof PasswordCallback) { getAnswer(); ((PasswordCallback)callBack).setPassword(password); if (password != null) Arrays.fill(password, ' '); } else { throw new UnsupportedCallbackException(callBack, "Call back not supported"); } } }
Example #7
Source File: DynamicConfigurationTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { NameCallback nc = (NameCallback) callback; nc.setName(userName); } else if (callback instanceof PasswordCallback) { PasswordCallback pc = (PasswordCallback) callback; pc.setPassword(password); } else { throw new UnsupportedCallbackException(callback, "Unrecognized Callback"); } } }
Example #8
Source File: DynamicConfigurationTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { NameCallback nc = (NameCallback) callback; nc.setName(userName); } else if (callback instanceof PasswordCallback) { PasswordCallback pc = (PasswordCallback) callback; pc.setPassword(password); } else { throw new UnsupportedCallbackException(callback, "Unrecognized Callback"); } } }
Example #9
Source File: Authentication.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback current : callbacks) { if (current instanceof NameCallback) { NameCallback ncb = (NameCallback) current; ncb.setName(username); } else if (current instanceof PasswordCallback) { PasswordCallback pcb = (PasswordCallback) current; pcb.setPassword(password.toCharArray()); } else if (current instanceof RealmCallback) { RealmCallback rcb = (RealmCallback) current; rcb.setText(rcb.getDefaultText()); } else { throw new UnsupportedCallbackException(current); } } }
Example #10
Source File: AtlasAuthenticationKerberosFilterTest.java From incubator-atlas with Apache License 2.0 | 6 votes |
protected Subject loginTestUser() throws LoginException, IOException { LoginContext lc = new LoginContext(TEST_USER_JAAS_SECTION, new CallbackHandler() { @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback) callback; passwordCallback.setPassword(TESTPASS.toCharArray()); } if (callback instanceof NameCallback) { NameCallback nameCallback = (NameCallback) callback; nameCallback.setName(TESTUSER); } } } }); // attempt authentication lc.login(); return lc.getSubject(); }
Example #11
Source File: TestUserPasswordLoginModule.java From cxf with Apache License 2.0 | 6 votes |
@Override public boolean login() throws LoginException { NameCallback nameCallback = new NameCallback("User"); PasswordCallback passwordCallback = new PasswordCallback("Password", false); Callback[] callbacks = new Callback[] {nameCallback, passwordCallback}; try { this.callbackHandler.handle(callbacks); } catch (IOException | UnsupportedCallbackException e) { throw new LoginException(e.getMessage()); } String userName = nameCallback.getName(); String password = new String(passwordCallback.getPassword()); if (!TESTUSER.equals(userName)) { throw new LoginException("wrong username"); } if (!TESTPASS.equals(password)) { throw new LoginException("wrong password"); } subject.getPrincipals().add(new SimplePrincipal(userName)); subject.getPrincipals().add(new SimpleGroup(TESTGROUP)); return true; }
Example #12
Source File: ClaimsProcessorTest.java From cxf-fediz with Apache License 2.0 | 6 votes |
private String createSamlToken(SamlAssertionWrapper assertion, String alias, boolean sign, String rstr) throws IOException, UnsupportedCallbackException, WSSecurityException, SAXException, ParserConfigurationException { WSPasswordCallback[] cb = { new WSPasswordCallback(alias, WSPasswordCallback.SIGNATURE) }; cbPasswordHandler.handle(cb); String password = cb[0].getPassword(); if (sign) { assertion.signAssertion(alias, password, crypto, false); } Document doc = STSUtil.toSOAPPart(rstr); Element token = assertion.toDOM(doc); Element e = XMLUtils.findElement(doc, "RequestedSecurityToken", FederationConstants.WS_TRUST_13_NS); if (e == null) { e = XMLUtils.findElement(doc, "RequestedSecurityToken", FederationConstants.WS_TRUST_2005_02_NS); } e.appendChild(token); return DOM2Writer.nodeToString(doc); }
Example #13
Source File: SAML1CallbackHandler.java From steady with Apache License 2.0 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof SAMLCallback) { SAMLCallback callback = (SAMLCallback) callbacks[i]; callback.setSamlVersion(SAMLVersion.VERSION_11); SubjectBean subjectBean = new SubjectBean( subjectName, subjectQualifier, confirmationMethod ); if (SAML1Constants.CONF_HOLDER_KEY.equals(confirmationMethod)) { try { KeyInfoBean keyInfo = createKeyInfo(); subjectBean.setKeyInfo(keyInfo); } catch (Exception ex) { throw new IOException("Problem creating KeyInfo: " + ex.getMessage()); } } createAndSetStatement(subjectBean, callback); } else { throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); } } }
Example #14
Source File: WSSUsernameCallbackHandler.java From steady with Apache License 2.0 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof DelegationCallback) { DelegationCallback callback = (DelegationCallback) callbacks[i]; Message message = callback.getCurrentMessage(); String username = (String)message.getContextualProperty(SecurityConstants.USERNAME); if (username != null) { Node contentNode = message.getContent(Node.class); Document doc = null; if (contentNode != null) { doc = contentNode.getOwnerDocument(); } else { doc = DOMUtils.createDocument(); } UsernameToken usernameToken = createWSSEUsernameToken(username, doc); callback.setToken(usernameToken.getElement()); } } else { throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); } } }
Example #15
Source File: Authentication.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback current : callbacks) { if (current instanceof NameCallback) { NameCallback ncb = (NameCallback) current; ncb.setName(username); } else if (current instanceof PasswordCallback) { PasswordCallback pcb = (PasswordCallback) current; pcb.setPassword(password.toCharArray()); } else if (current instanceof RealmCallback) { RealmCallback rcb = (RealmCallback) current; rcb.setText(rcb.getDefaultText()); } else { throw new UnsupportedCallbackException(current); } } }
Example #16
Source File: LoginHintHomeRealmDiscovery.java From cxf-fediz with Apache License 2.0 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof HomeRealmCallback) { HomeRealmCallback callback = (HomeRealmCallback) callbacks[i]; final String loginHint = (String)callback.getRequest().getParameter("login_hint"); if (loginHint == null || loginHint.isEmpty()) { LOG.debug("No login_hint found in request to set home realm"); } else { String[] homeRealm = loginHint.split("@"); if (homeRealm.length == 2) { LOG.debug("Home realm '{}' found in request", StringEscapeUtils.escapeHtml4(homeRealm[1])); callback.setHomeRealm(homeRealm[1]); } else { LOG.warn("login_hint is not an email address: {}", StringEscapeUtils.escapeHtml4(loginHint)); } } } else { LOG.warn("Callback is not an instance of HomeRealmCallback: {}", callbacks[i]); } } }
Example #17
Source File: SAML1CallbackHandler.java From steady with Apache License 2.0 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof SAMLCallback) { SAMLCallback callback = (SAMLCallback) callbacks[i]; callback.setSamlVersion(SAMLVersion.VERSION_11); SubjectBean subjectBean = new SubjectBean( subjectName, subjectQualifier, confirmationMethod ); if (SAML1Constants.CONF_HOLDER_KEY.equals(confirmationMethod)) { try { KeyInfoBean keyInfo = createKeyInfo(); subjectBean.setKeyInfo(keyInfo); } catch (Exception ex) { throw new IOException("Problem creating KeyInfo: " + ex.getMessage()); } } createAndSetStatement(subjectBean, callback); } else { throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); } } }
Example #18
Source File: CustomPasswordHandler.java From tomee with Apache License 2.0 | 6 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) { // TODO get the password from the users.properties if possible pc.setPassword("waterfall"); } else if (pc.getUsage() == WSPasswordCallback.DECRYPT) { pc.setPassword("serverPassword"); } else if (pc.getUsage() == WSPasswordCallback.SIGNATURE) { pc.setPassword("serverPassword"); } }
Example #19
Source File: SAML2CallbackHandler.java From steady with Apache License 2.0 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof SAMLCallback) { SAMLCallback callback = (SAMLCallback) callbacks[i]; callback.setSamlVersion(SAMLVersion.VERSION_20); SubjectBean subjectBean = new SubjectBean( subjectName, subjectQualifier, confirmationMethod ); if (SAML2Constants.CONF_HOLDER_KEY.equals(confirmationMethod)) { try { KeyInfoBean keyInfo = createKeyInfo(); subjectBean.setKeyInfo(keyInfo); } catch (Exception ex) { throw new IOException("Problem creating KeyInfo: " + ex.getMessage()); } } callback.setSubject(subjectBean); createAndSetStatement(null, callback); } else { throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); } } }
Example #20
Source File: KeystorePasswordCallback.java From cxf with Apache License 2.0 | 6 votes |
/** * It attempts to get the password from the private * alias/passwords map. */ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pc = (WSPasswordCallback)callbacks[i]; if (pc.getUsage() == WSPasswordCallback.PASSWORD_ENCRYPTOR_PASSWORD) { pc.setPassword("this-is-a-secret"); } else { String pass = passwords.get(pc.getIdentifier()); if (pass != null) { pc.setPassword(pass); return; } pc.setPassword("password"); } } }
Example #21
Source File: KerberosAuthenticateModule.java From unitime with Apache License 2.0 | 5 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { iHandler.handle(callbacks); if (iRealm != null) for (Callback callback : callbacks) { if (callback instanceof NameCallback) { NameCallback nc = (NameCallback) callback; if (nc.getName() != null && !nc.getName().contains("@")) nc.setName(nc.getName() + "@" + iRealm); } } }
Example #22
Source File: UTPasswordCallback.java From cxf with Apache License 2.0 | 5 votes |
/** * Here, we attempt to get the password from the private * alias/passwords map. */ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pc = (WSPasswordCallback)callbacks[i]; String pass = passwords.get(pc.getIdentifier()); if (pass != null) { pc.setPassword(pass); return; } } }
Example #23
Source File: TestPwdCallback.java From steady with Apache License 2.0 | 5 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pc = (WSPasswordCallback)callbacks[i]; String pass = passwords.get(pc.getIdentifier()); if (pass != null) { pc.setPassword(pass); } } }
Example #24
Source File: AuthHandler.java From java-dcp-client with Apache License 2.0 | 5 votes |
/** * Handles the SASL defined callbacks to set user and password (the {@link CallbackHandler} interface). */ @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { ((NameCallback) callback).setName(username); } else if (callback instanceof PasswordCallback) { ((PasswordCallback) callback).setPassword(password.toCharArray()); } else { throw new AuthenticationException("SASLClient requested unsupported callback: " + callback); } } }
Example #25
Source File: KerberosAuth.java From Bats with Apache License 2.0 | 5 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { NameCallback nameCallback = (NameCallback)callback; nameCallback.setName(principal); } else if (callback instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback)callback; passwordCallback.setPassword(password); } } }
Example #26
Source File: NullCallbackHandler.java From sakai with Educational Community License v2.0 | 5 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback: callbacks) { throw new UnsupportedCallbackException(callback, "Can't handle any callbacks"); } }
Example #27
Source File: ConsoleCallbackHandler.java From peer-os with Apache License 2.0 | 5 votes |
/** * Handles the callbacks. * * @param callbacks The callbacks to handle * * @throws UnsupportedCallbackException If the console is not available or other than PasswordCallback is supplied */ @Override public void handle( Callback[] callbacks ) throws IOException, UnsupportedCallbackException { Console cons = System.console(); if ( cons == null && password == null ) { throw new UnsupportedCallbackException( callbacks[0], "Console is not available" ); } for ( int i = 0; i < callbacks.length; i++ ) { if ( callbacks[i] instanceof PasswordCallback ) { if ( password == null ) { //It is used instead of cons.readPassword(prompt), because the prompt may contain '%' characters ( ( PasswordCallback ) callbacks[i] ).setPassword( cons.readPassword( "%s", ( ( PasswordCallback ) callbacks[i] ).getPrompt() ) ); } else { ( ( PasswordCallback ) callbacks[i] ).setPassword( password ); } } else { throw new UnsupportedCallbackException( callbacks[i] ); } } }
Example #28
Source File: OpenEJBJaasPasswordAuthenticator.java From tomee with Apache License 2.0 | 5 votes |
@Override public boolean authenticate(final String username, final String password, final ServerSession session) { try { final Subject subject = new Subject(); final LoginContext loginContext = new LoginContext(getDomain(), subject, new CallbackHandler() { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (final Callback callback : callbacks) { if (callback instanceof NameCallback) { ((NameCallback) callback).setName(username); } else if (callback instanceof PasswordCallback) { ((PasswordCallback) callback).setPassword(password.toCharArray()); } else { throw new UnsupportedCallbackException(callback); } } } }); loginContext.login(); session.setAttribute(USERNAME_KEY, username); session.setAttribute(LOGIN_CONTEXT_KEY, loginContext); return true; } catch (Exception e) { LOGGER.debug("can't log using username '" + username + "'", e); return false; } }
Example #29
Source File: JaasAuthenticationHandler.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
public void handle(final Callback[] callbacks) throws UnsupportedCallbackException { for (final Callback callback : callbacks) { if (callback.getClass().equals(NameCallback.class)) { ((NameCallback) callback).setName(this.userName); } else if (callback.getClass().equals(PasswordCallback.class)) { ((PasswordCallback) callback).setPassword(this.password .toCharArray()); } else { throw new UnsupportedCallbackException(callback, "Unrecognized Callback"); } } }
Example #30
Source File: P11KeyStore.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { if (!(callbacks[0] instanceof PasswordCallback)) { throw new UnsupportedCallbackException(callbacks[0]); } PasswordCallback pc = (PasswordCallback)callbacks[0]; pc.setPassword(password); // this clones the password if not null }