use of org.talend.esb.security.saml.WSPasswordCallbackHandler in project tesb-rt-se by Talend.
the class WSPasswordCallbackHandlerTest method handleNotEncryptedPasswordTest.
@Test
public void handleNotEncryptedPasswordTest() throws Exception {
String username = "username";
String password = "password";
WSPasswordCallbackHandler h = new WSPasswordCallbackHandler(username, password);
Callback c = new WSPasswordCallback(username, 0);
List<Callback> cs = new ArrayList<Callback>();
cs.add(c);
h.handle(cs.toArray(new Callback[0]));
}
use of org.talend.esb.security.saml.WSPasswordCallbackHandler in project tesb-rt-se by Talend.
the class WSPasswordCallbackHandlerTest method handleEncryptedPasswordTest.
@Ignore
public void handleEncryptedPasswordTest() throws Exception {
String username = "username";
String password = PropertyValueEncryptionUtils.encrypt("password", getEncryptor());
WSPasswordCallbackHandler h = new WSPasswordCallbackHandler(username, password);
Callback c = new WSPasswordCallback(username, 0);
List<Callback> cs = new ArrayList<Callback>();
cs.add(c);
h.handle(cs.toArray(new Callback[0]));
}
use of org.talend.esb.security.saml.WSPasswordCallbackHandler in project tesb-rt-se by Talend.
the class WSPasswordCallbackHandlerTest method handleNoUserTest.
@Test
public void handleNoUserTest() throws Exception {
String username = null;
String password = "password";
WSPasswordCallbackHandler h = new WSPasswordCallbackHandler(username, password);
Callback c = new WSPasswordCallback(username, 0);
List<Callback> cs = new ArrayList<Callback>();
cs.add(c);
h.handle(cs.toArray(new Callback[0]));
}
use of org.talend.esb.security.saml.WSPasswordCallbackHandler in project tesb-rt-se by Talend.
the class SecurityArguments method buildClientConfig.
public Map<String, Object> buildClientConfig(final Bus bus, boolean useServiceRegistry, String encryptionUsername) {
Map<String, Object> clientConfig = new HashMap<String, Object>();
if (EsbSecurity.TOKEN == esbSecurity || useServiceRegistry) {
clientConfig.put(SecurityConstants.USERNAME, username);
clientConfig.put(SecurityConstants.PASSWORD, password);
}
if (EsbSecurity.SAML == esbSecurity || useServiceRegistry) {
final STSClient stsClient = configureSTSClient(bus);
clientConfig.put(SecurityConstants.STS_CLIENT, stsClient);
for (Map.Entry<String, String> entry : clientProperties.entrySet()) {
if (SecurityConstants.ALL_PROPERTIES.contains(entry.getKey())) {
clientConfig.put(entry.getKey(), processFileURI(entry.getValue()));
}
}
if (null == alias) {
String sigUser = clientProperties.get(SecurityConstants.SIGNATURE_USERNAME);
if (sigUser == null) {
sigUser = clientProperties.get("ws-" + SecurityConstants.SIGNATURE_USERNAME);
}
clientConfig.put(SecurityConstants.CALLBACK_HANDLER, new WSPasswordCallbackHandler(sigUser, clientProperties.get(SAMLRESTUtils.SIGNATURE_PASSWORD)));
} else {
clientConfig.put(SecurityConstants.SIGNATURE_USERNAME, alias);
clientConfig.put(SecurityConstants.CALLBACK_HANDLER, new WSPasswordCallbackHandler(alias, password));
}
if (null != cryptoProvider) {
clientConfig.put(SecurityConstants.ENCRYPT_CRYPTO, cryptoProvider);
Object encryptUsername = clientConfig.get(SecurityConstants.ENCRYPT_USERNAME);
if (encryptUsername == null) {
encryptUsername = clientProperties.get("ws-" + SecurityConstants.ENCRYPT_USERNAME);
}
if (encryptUsername == null || encryptUsername.toString().isEmpty()) {
clientConfig.put(SecurityConstants.ENCRYPT_USERNAME, encryptionUsername);
}
}
}
return clientConfig;
}
Aggregations