use of com.zimbra.cs.ephemeral.EphemeralKey in project zm-mailbox by Zimbra.
the class Entry method purgeEphemeralAttr.
public void purgeEphemeralAttr(String key) throws ServiceException {
EphemeralLocation location = new LdapEntryLocation(this);
EphemeralStore store = EphemeralStore.getFactory().getStore();
store.purgeExpired(new EphemeralKey(key), location);
}
use of com.zimbra.cs.ephemeral.EphemeralKey in project zm-mailbox by Zimbra.
the class CsrfTokenConverter method convert.
@Override
public EphemeralInput convert(String attrName, Object ldapValue) {
String ldapValueStr = (String) ldapValue;
String[] parts = ldapValueStr.split(":");
if (parts.length != 3) {
ZimbraLog.ephemeral.warn("CSRF auth token %s cannot be parsed", ldapValueStr);
return null;
}
String data = parts[0];
String crumb = parts[1];
Long expirationMillis;
try {
expirationMillis = Long.parseLong(parts[2]);
} catch (NumberFormatException e) {
ZimbraLog.ephemeral.warn("CSRF auth token %s does not have a valid expiration value", ldapValueStr);
return null;
}
EphemeralKey key = new EphemeralKey(attrName, crumb);
EphemeralInput input = new EphemeralInput(key, data);
Expiration expiration = new AbsoluteExpiration(expirationMillis);
input.setExpiration(expiration);
return input;
}
use of com.zimbra.cs.ephemeral.EphemeralKey in project zm-mailbox by Zimbra.
the class MigrateAttributesTest method testAttributeMigration.
/*
* Test end-to-end AttributeMigration
*/
@Test
public void testAttributeMigration() throws Exception {
EphemeralStore destination = EphemeralStore.getFactory().getStore();
EntrySource source = new DummyEntrySource(acct);
List<String> attrsToMigrate = Arrays.asList(new String[] { Provisioning.A_zimbraAuthTokens, Provisioning.A_zimbraCsrfTokenData, Provisioning.A_zimbraLastLogonTimestamp });
// DummyMigrationCallback will store attributes in InMemoryEphemeralStore, and track deletions in deletedAttrs map
MigrationCallback callback = new DummyMigrationCallback(destination);
AttributeMigration.setCallback(callback);
AttributeMigration migration = new AttributeMigration("testAttributeMigration", attrsToMigrate, source, null);
MigrationInfo info = MigrationInfo.getFactory().getInfo();
// disable running in separate thread
// run migration
migration.migrateAllAccounts();
EphemeralLocation location = new LdapEntryLocation(acct);
EphemeralResult result = destination.get(new EphemeralKey(Provisioning.A_zimbraAuthTokens, "1234"), location);
assertEquals("server_1", result.getValue());
result = destination.get(new EphemeralKey(Provisioning.A_zimbraAuthTokens, "5678"), location);
assertEquals("server_2", result.getValue());
result = destination.get(new EphemeralKey(Provisioning.A_zimbraCsrfTokenData, "crumb1"), location);
assertEquals("data1", result.getValue());
result = destination.get(new EphemeralKey(Provisioning.A_zimbraCsrfTokenData, "crumb2"), location);
assertEquals("data2", result.getValue());
result = destination.get(new EphemeralKey(Provisioning.A_zimbraLastLogonTimestamp), location);
assertEquals("currentdate", result.getValue());
assertTrue(info.getStatus() == Status.COMPLETED);
}
use of com.zimbra.cs.ephemeral.EphemeralKey in project zm-mailbox by Zimbra.
the class MigrateAttributesTest method verifyCsrfTokenEphemeralInput.
private void verifyCsrfTokenEphemeralInput(EphemeralInput input, String crumb, String data, Long expiration) {
EphemeralKey key = input.getEphemeralKey();
assertEquals(Provisioning.A_zimbraCsrfTokenData, key.getKey());
assertEquals(crumb, key.getDynamicComponent());
assertEquals(data, input.getValue());
assertEquals(expiration, input.getExpiration());
}
use of com.zimbra.cs.ephemeral.EphemeralKey in project zm-mailbox by Zimbra.
the class MigrateAttributesTest method verifyAuthTokenEphemeralInput.
private void verifyAuthTokenEphemeralInput(EphemeralInput input, String token, String serverVersion, Long expiration) {
EphemeralKey key = input.getEphemeralKey();
assertEquals(Provisioning.A_zimbraAuthTokens, key.getKey());
assertEquals(token, key.getDynamicComponent());
assertEquals(serverVersion, input.getValue());
assertEquals(expiration, input.getExpiration());
}
Aggregations