org.apache.ws.security.WSPasswordCallback Java Examples
The following examples show how to use
org.apache.ws.security.WSPasswordCallback.
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: UsernameTokenInterceptor.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, UsernameToken info, int type, SoapMessage message) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallback(message); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available", message); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e, message); } //get the password return cb[0].getPassword(); }
Example #2
Source File: AbstractBindingBuilder.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, Assertion info, int type) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallbackHandler(); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available"); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e); } //get the password return cb[0].getPassword(); }
Example #3
Source File: UsernameTokenInterceptor.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, UsernameToken info, int type, SoapMessage message) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallback(message); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available", message); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e, message); } //get the password return cb[0].getPassword(); }
Example #4
Source File: SamlTokenInterceptor.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, SamlToken info, int type, SoapMessage message) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallback(message); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available", message); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e, message); } //get the password return cb[0].getPassword(); }
Example #5
Source File: SamlTokenInterceptor.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, SamlToken info, int type, SoapMessage message) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallback(message); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available", message); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e, message); } //get the password return cb[0].getPassword(); }
Example #6
Source File: UsernameTokenInterceptor.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, UsernameToken info, int type, SoapMessage message) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallback(message); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available", message); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e, message); } //get the password return cb[0].getPassword(); }
Example #7
Source File: AbstractBindingBuilder.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, Assertion info, int type) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallbackHandler(); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available"); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e); } //get the password return cb[0].getPassword(); }
Example #8
Source File: AbstractBindingBuilder.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, Assertion info, int type) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallbackHandler(); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available"); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e); } //get the password return cb[0].getPassword(); }
Example #9
Source File: ClientCredentialsHolder.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof WSPasswordCallback) { WSPasswordCallback pc = (WSPasswordCallback) callbacks[i]; // We need the password to fill in, so the usage code must // match the WSPasswordCallback.USERNAME_TOKEN value // i.e. "2" if (pc.getUsage() != WSPasswordCallback.USERNAME_TOKEN) { throw new UnsupportedCallbackException(callbacks[i], "Usage code was not USERNAME_TOKEN - value was " + pc.getUsage()); } pc.setPassword(password); } else { throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); } } }
Example #10
Source File: ClientPasswordCallback.java From document-management-system with GNU General Public License v2.0 | 6 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { log.info("handle({})", callbacks); WSPasswordCallback pwdCallback = (WSPasswordCallback) callbacks[0]; log.debug("identifier: " + pwdCallback.getIdentifier()); log.debug("usage: " + pwdCallback.getUsage()); int usage = pwdCallback.getUsage(); if (usage == WSPasswordCallback.USERNAME_TOKEN) { String password = pwdCallback.getPassword(); Authentication authentication = new UsernamePasswordAuthenticationToken(pwdCallback.getIdentifier(), password); authentication = authenticationManager.authenticate(authentication); SecurityContextHolder.getContext().setAuthentication(authentication); // Return the password to the caller pwdCallback.setPassword(password); } }
Example #11
Source File: SamlTokenInterceptor.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, SamlToken info, int type, SoapMessage message) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallback(message); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available", message); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e, message); } //get the password return cb[0].getPassword(); }
Example #12
Source File: UsernameTokenInterceptor.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, UsernameToken info, int type, SoapMessage message) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallback(message); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available", message); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e, message); } //get the password return cb[0].getPassword(); }
Example #13
Source File: SecurityWithServiceDescriptorTest.java From product-ei with Apache License 2.0 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[0]; String id = pwcb.getIdentifier(); int usage = pwcb.getUsage(); if (usage == WSPasswordCallback.USERNAME_TOKEN) { if ("admin".equals(id)) { pwcb.setPassword("admin"); } else if ("[email protected]".equals(id)) { pwcb.setPassword("admin123"); } } else if (usage == WSPasswordCallback.SIGNATURE || usage == WSPasswordCallback.DECRYPT) { if ("wso2carbon".equals(id)) { pwcb.setPassword("wso2carbon"); } } }
Example #14
Source File: SecureAxisServiceClient.java From product-ei 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 #15
Source File: PWCBHandler.java From product-ei with Apache License 2.0 | 6 votes |
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { //When the server side need to authenticate the user WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i]; if (pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) { if(pwcb.getIdentifer().equals("alice") && pwcb.getPassword().equals("bobPW")) { return; } else { throw new UnsupportedCallbackException(callbacks[i], "check failed"); } } //When the client requests for the password to be added in to the //UT element pwcb.setPassword("bobPW"); } }
Example #16
Source File: AbstractBindingBuilder.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, Assertion info, int type) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallbackHandler(); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available"); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e); } //get the password return cb[0].getPassword(); }
Example #17
Source File: InMemoryPasswordCallbackHandler.java From carbon-identity 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 WSPasswordCallback) { WSPasswordCallback pc = (WSPasswordCallback) callbacks[i]; String id = pc.getIdentifier(); if (keystorePassword.get(id) != null) { pc.setPassword(keystorePassword.get(id)); } else { throw new UnsupportedCallbackException(callbacks[i], "no password found for " + id); } } } }
Example #18
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 #19
Source File: SamlTokenInterceptor.java From steady with Apache License 2.0 | 6 votes |
public String getPassword(String userName, SamlToken info, int type, SoapMessage message) { //Then try to get the password from the given callback handler CallbackHandler handler = getCallback(message); if (handler == null) { policyNotAsserted(info, "No callback handler and no password available", message); return null; } WSPasswordCallback[] cb = {new WSPasswordCallback(userName, type)}; try { handler.handle(cb); } catch (Exception e) { policyNotAsserted(info, e, message); } //get the password return cb[0].getPassword(); }
Example #20
Source File: KeystorePasswordCallback.java From steady with Apache License 2.0 | 5 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]; String pass = passwords.get(pc.getIdentifier()); if (pass != null) { pc.setPassword(pass); return; } } }
Example #21
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 #22
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 #23
Source File: ClientUserPasswordCallbackHandler.java From carbon-identity with Apache License 2.0 | 5 votes |
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof WSPasswordCallback) { WSPasswordCallback passwordCallback = (WSPasswordCallback) callbacks[i]; passwordCallback.setPassword(this.password); } else { throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); } } }
Example #24
Source File: AbstractBindingBuilder.java From steady with Apache License 2.0 | 5 votes |
protected WSSecUsernameToken addDKUsernameToken(UsernameToken token, boolean useMac) { AssertionInfo info = null; Collection<AssertionInfo> ais = aim.getAssertionInfo(token.getName()); for (AssertionInfo ai : ais) { if (ai.getAssertion() == token) { info = ai; if (!isRequestor()) { info.setAsserted(true); return null; } } } String userName = (String)message.getContextualProperty(SecurityConstants.USERNAME); if (!StringUtils.isEmpty(userName)) { WSSecUsernameToken utBuilder = new WSSecUsernameToken(wssConfig); String password = (String)message.getContextualProperty(SecurityConstants.PASSWORD); if (StringUtils.isEmpty(password)) { password = getPassword(userName, token, WSPasswordCallback.USERNAME_TOKEN); } if (!StringUtils.isEmpty(password)) { // If the password is available then build the token utBuilder.setUserInfo(userName, password); utBuilder.addDerivedKey(useMac, null, 1000); utBuilder.prepare(saaj.getSOAPPart()); } else { policyNotAsserted(token, "No password available"); return null; } info.setAsserted(true); return utBuilder; } else { policyNotAsserted(token, "No username available"); return null; } }
Example #25
Source File: KeystorePasswordCallback.java From cxf with Apache License 2.0 | 5 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]; String pass = passwords.get(pc.getIdentifier()); if (pass != null) { pc.setPassword(pass); return; } } }
Example #26
Source File: KeystorePasswordCallback.java From steady with Apache License 2.0 | 5 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]; String pass = passwords.get(pc.getIdentifier()); if (pass != null) { pc.setPassword(pass); return; } } }
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: AbstractBindingBuilder.java From steady with Apache License 2.0 | 5 votes |
protected WSSecUsernameToken addDKUsernameToken(UsernameToken token, boolean useMac) { AssertionInfo info = null; Collection<AssertionInfo> ais = aim.getAssertionInfo(token.getName()); for (AssertionInfo ai : ais) { if (ai.getAssertion() == token) { info = ai; if (!isRequestor()) { info.setAsserted(true); return null; } } } String userName = (String)message.getContextualProperty(SecurityConstants.USERNAME); if (!StringUtils.isEmpty(userName)) { WSSecUsernameToken utBuilder = new WSSecUsernameToken(wssConfig); String password = (String)message.getContextualProperty(SecurityConstants.PASSWORD); if (StringUtils.isEmpty(password)) { password = getPassword(userName, token, WSPasswordCallback.USERNAME_TOKEN); } if (!StringUtils.isEmpty(password)) { // If the password is available then build the token utBuilder.setUserInfo(userName, password); utBuilder.addDerivedKey(useMac, null, 1000); utBuilder.prepare(saaj.getSOAPPart()); } else { policyNotAsserted(token, "No password available"); return null; } info.setAsserted(true); return utBuilder; } else { policyNotAsserted(token, "No username available"); return null; } }
Example #29
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 #30
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); } } }