@Test public void testNoObfuscationOfNonAuthStatement() { List<AuditOperation> queries = Arrays.asList( new SimpleAuditOperation("Authentication attempt"), new SimpleAuditOperation("select password from ks.tbl"), new SimpleAuditOperation("insert into ks.tbl (user, password) values ('foo', 'password')")); for (AuditOperation query : queries) { AuditEntry entry = AuditEntry.newBuilder() .operation(query) .permissions(Sets.immutableEnumSet(Permission.SELECT)) .resource(RoleResource.fromName("roles/olle")) .build(); AuditEntry obfuscated = myObfuscator.obfuscate(entry); assertThat(obfuscated.getOperation()).isSameAs(query); } }
@Override public AuditEntry obfuscate(final AuditEntry entry) { if (isRoleResource(entry.getResource()) && isPasswordPermission(entry.getPermissions())) { AuditEntry obfuscatedEntry = entry; String obfuscatedOperation = obfuscateOperation(entry.getOperation().getOperationString()); if (!entry.getOperation().getOperationString().equals(obfuscatedOperation)) { obfuscatedEntry = AuditEntry.newBuilder() .basedOn(entry) .operation(new SimpleAuditOperation(obfuscatedOperation)) .build(); } return obfuscatedEntry; } return entry; }
PasswordObfuscator implements AuditObfuscator { @Override public AuditEntry obfuscate(final AuditEntry entry) { if (isRoleResource(entry.getResource()) && isPasswordPermission(entry.getPermissions())) { AuditEntry obfuscatedEntry = entry; String obfuscatedOperation = obfuscateOperation(entry.getOperation().getOperationString()); if (!entry.getOperation().getOperationString().equals(obfuscatedOperation)) { obfuscatedEntry = AuditEntry.newBuilder() .basedOn(entry) .operation(new SimpleAuditOperation(obfuscatedOperation)) .build(); } return obfuscatedEntry; } return entry; } }
PasswordObfuscator implements AuditObfuscator { @Override public AuditEntry obfuscate(final AuditEntry entry) { if (isRoleResource(entry.getResource()) && isPasswordPermission(entry.getPermissions())) { AuditEntry obfuscatedEntry = entry; String obfuscatedOperation = obfuscateOperation(entry.getOperation().getOperationString()); if (!entry.getOperation().getOperationString().equals(obfuscatedOperation)) { obfuscatedEntry = AuditEntry.newBuilder() .basedOn(entry) .operation(new SimpleAuditOperation(obfuscatedOperation)) .build(); } return obfuscatedEntry; } return entry; }  }
PasswordObfuscator implements AuditObfuscator { @Override public AuditEntry obfuscate(final AuditEntry entry) { if (isRoleResource(entry.getResource()) && isPasswordPermission(entry.getPermissions())) { AuditEntry obfuscatedEntry = entry; String obfuscatedOperation = obfuscateOperation(entry.getOperation().getOperationString()); if (!entry.getOperation().getOperationString().equals(obfuscatedOperation)) { obfuscatedEntry = AuditEntry.newBuilder() .basedOn(entry) .operation(new SimpleAuditOperation(obfuscatedOperation)) .build(); } return obfuscatedEntry; } return entry; }  @Override AuditEntry obfuscate(final AuditEntry entry); }
PasswordObfuscator implements AuditObfuscator { @Override public AuditEntry obfuscate(final AuditEntry entry) { if (isRoleResource(entry.getResource()) && isPasswordPermission(entry.getPermissions())) { AuditEntry obfuscatedEntry = entry; String obfuscatedOperation = obfuscateOperation(entry.getOperation().getOperationString()); if (!entry.getOperation().getOperationString().equals(obfuscatedOperation)) { obfuscatedEntry = AuditEntry.newBuilder() .basedOn(entry) .operation(new SimpleAuditOperation(obfuscatedOperation)) .build(); } return obfuscatedEntry; } return entry; }  @Override AuditEntry obfuscate(final AuditEntry entry);  }