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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #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: 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 #19
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 #20
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 #21
Source File: TMLoginModule.java From ontopia with Apache License 2.0 | 5 votes |
/** * Prompt the user for username and password, and verify those. */ @Override public boolean login() throws LoginException { log.debug("TMLoginModule: login"); if (callbackHandler == null) throw new LoginException("Error: no CallbackHandler available " + "to garner authentication information from the user"); // prompt for a user name and password NameCallback nameCallback = new NameCallback("user name: "); PasswordCallback passwordCallback = new PasswordCallback("password: ", false); try { callbackHandler.handle(new Callback[] {nameCallback, passwordCallback}); this.username = nameCallback.getName(); char[] charpassword = passwordCallback.getPassword(); password = (charpassword == null ? "" : new String(charpassword)); passwordCallback.clearPassword(); } catch (java.io.IOException ioe) { throw new LoginException(ioe.toString()); } catch (UnsupportedCallbackException uce) { throw new LoginException("Error: " + uce.getCallback() + " not available to garner authentication information " + "from the user"); } // verify the username/password loginSucceeded = verifyUsernamePassword(username, password); return loginSucceeded; }
Example #22
Source File: CommonCallbackHandler.java From cxf-fediz with Apache License 2.0 | 5 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof WSPasswordCallback) { // CXF WSPasswordCallback pc = (WSPasswordCallback) callbacks[i]; if ("ALICE".equals(pc.getIdentifier())) { pc.setPassword("ECILA"); break; } else if ("realmb".equals(pc.getIdentifier())) { pc.setPassword("realmb"); break; } } } }
Example #23
Source File: UnsupportedCallbackHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { int len$ = callbacks.length; int i$ = 0; if (i$ < len$) { Callback callback = callbacks[i$]; LOG.warn("Unable to handle callback: " + callback.getClass()); throw new UnsupportedCallbackException(callback, "Unable to handle callback: " + callback.getClass()); } }
Example #24
Source File: P11KeyStore.java From jdk8u_jdk 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 }
Example #25
Source File: SecurityContextCallbackHandler.java From lams with GNU General Public License v2.0 | 5 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for(Callback cb: callbacks) { if(cb instanceof SecurityContextCallback) { SecurityContextCallback scb = (SecurityContextCallback)cb; scb.setSecurityContext(securityContext); } else throw new UnsupportedCallbackException(cb); } }
Example #26
Source File: CrossRealm.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { ((NameCallback) callback).setName("dummy"); } if (callback instanceof PasswordCallback) { ((PasswordCallback) callback).setPassword("bogus".toCharArray()); } } }
Example #27
Source File: WSS4JInInterceptor.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 id = pc.getIdentifier(); if (SecurityTokenReference.ENC_KEY_SHA1_URI.equals(pc.getType()) || WSConstants.WSS_KRB_KI_VALUE_TYPE.equals(pc.getType())) { for (String tokenId : store.getTokenIdentifiers()) { SecurityToken token = store.getToken(tokenId); if (id.equals(token.getSHA1())) { pc.setKey(token.getSecret()); return; } } } else { SecurityToken tok = store.getToken(id); if (tok != null) { pc.setKey(tok.getSecret()); pc.setCustomToken(tok.getToken()); return; } } } if (internal != null) { internal.handle(callbacks); } }
Example #28
Source File: SecretKeyPasswordCallback.java From cxf 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]; if (pc.getUsage() == WSPasswordCallback.SECRET_KEY) { pc.setKey(KEY); } } }
Example #29
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 #30
Source File: SaslNettyServer.java From blazingcache with Apache License 2.0 | 5 votes |
public void handle(Callback[] callbacks) throws UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof NameCallback) { handleNameCallback((NameCallback) callback); } else if (callback instanceof PasswordCallback) { handlePasswordCallback((PasswordCallback) callback); } else if (callback instanceof RealmCallback) { handleRealmCallback((RealmCallback) callback); } else if (callback instanceof AuthorizeCallback) { handleAuthorizeCallback((AuthorizeCallback) callback); } } }