use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class IdentityBuilderTest method testMappedMetadataIdentityBuilder_ObjectMetadata.
@Test
public void testMappedMetadataIdentityBuilder_ObjectMetadata() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
String username = getName() + ThreadLocalRandom.current().nextInt();
String password = getName() + ThreadLocalRandom.current().nextInt();
String role = getName() + +ThreadLocalRandom.current().nextInt();
msg.getObjectHeaders().put(MAPPED_USER, username);
msg.getObjectHeaders().put(MAPPED_PASSWORD, password);
msg.getObjectHeaders().put(MAPPED_ROLE, role);
MappedMetadataIdentityBuilder builder = new MappedMetadataIdentityBuilder(MetadataSource.Object, new KeyValuePairList(Arrays.asList(new KeyValuePair[] { new KeyValuePair(MAPPED_USER, USER), new KeyValuePair(MAPPED_PASSWORD, PASSWORD), new KeyValuePair(MAPPED_ROLE, ROLE) })));
try {
BaseCase.start(builder);
Map<String, Object> identityMap = builder.build(msg);
assertTrue(identityMap.containsKey(ROLE));
assertTrue(identityMap.containsKey(USER));
assertTrue(identityMap.containsKey(PASSWORD));
assertEquals(username, identityMap.get(USER));
assertEquals(password, identityMap.get(PASSWORD));
assertEquals(role, identityMap.get(ROLE));
} finally {
BaseCase.stop(builder);
}
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class IdentityBuilderTest method testMappedMetadataIdentityBuilder.
@Test
public void testMappedMetadataIdentityBuilder() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
String username = getName() + ThreadLocalRandom.current().nextInt();
String password = getName() + ThreadLocalRandom.current().nextInt();
String role = getName() + +ThreadLocalRandom.current().nextInt();
msg.addMetadata(MAPPED_USER, username);
msg.addMetadata(MAPPED_PASSWORD, password);
msg.addMetadata(MAPPED_ROLE, role);
MappedMetadataIdentityBuilder builder = new MappedMetadataIdentityBuilder(new KeyValuePairList(Arrays.asList(new KeyValuePair[] { new KeyValuePair(MAPPED_USER, USER), new KeyValuePair(MAPPED_PASSWORD, PASSWORD), new KeyValuePair(MAPPED_ROLE, ROLE) })));
try {
BaseCase.start(builder);
Map<String, Object> identityMap = builder.build(msg);
assertTrue(identityMap.containsKey(ROLE));
assertTrue(identityMap.containsKey(USER));
assertTrue(identityMap.containsKey(PASSWORD));
assertEquals(username, identityMap.get(USER));
assertEquals(password, identityMap.get(PASSWORD));
assertEquals(role, identityMap.get(ROLE));
} finally {
BaseCase.stop(builder);
}
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class VerifyIdentityServiceTest method testMetadataVerification.
@Test
public void testMetadataVerification() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(USER, "user");
msg.addMetadata(PASSWORD, "password");
msg.addMetadata("dbUser", "user");
msg.addMetadata("dbPassword", "password");
MetadataIdentityVerifier verifier = new MetadataIdentityVerifier(new KeyValuePairSet(Arrays.asList(new KeyValuePair[] { new KeyValuePair(USER, "dbUser"), new KeyValuePair(PASSWORD, "dbPassword") })));
MetadataIdentityBuilder builder = new MetadataIdentityBuilder(MetadataSource.Standard, new ArrayList<String>(Arrays.asList(USER, PASSWORD)));
VerifyIdentityService service = new VerifyIdentityService(builder, verifier);
execute(service, msg);
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class XpathCacheValueTranslatorTest method createTranslator.
private XpathCacheValueTranslator createTranslator() {
XpathCacheValueTranslator translator = new XpathCacheValueTranslator();
KeyValuePairSet set = new KeyValuePairSet();
set.add(new KeyValuePair("test", "uri:test"));
translator.setNamespaceContext(set);
translator.setXpath("/test:root/test:element[@id='one']");
return translator;
}
use of com.adaptris.util.KeyValuePair in project interlok by adaptris.
the class JdbcServiceExample method applyDefaultConfig.
public static DatabaseConnection applyDefaultConfig(DatabaseConnection connection) {
connection.setConnectionAttempts(2);
connection.setUsername("my_db_username");
connection.setPassword("plain or encoded password");
connection.setConnectionRetryInterval(new TimeInterval(3L, "SECONDS"));
KeyValuePairSet connectionProps = new KeyValuePairSet();
connectionProps.add(new KeyValuePair("dontTrackOpenResources", "true"));
connectionProps.add(new KeyValuePair("autoReconnect", "true"));
connection.setConnectionProperties(connectionProps);
return connection;
}
Aggregations