Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion auth-api/src/main/java/tech/ydb/auth/AuthIdentity.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
package tech.ydb.auth;

/**
* Provides an authentication token for every request.
* Supplies authentication tokens for requests made by the YDB transport layer.
*
* <p>An identity may return a fixed token or obtain and refresh tokens as needed.
* The transport closes the identity when it no longer needs it.
*/
public interface AuthIdentity extends AutoCloseable {

/**
* Returns the authentication token to use for a request.
*
* <p>Implementations may obtain or refresh the token during this call.
*
* @return the authentication token, or {@code null} if no token should be sent
*/
String getToken();

/**
* Releases resources used by this identity.
*
* <p>The default implementation does nothing.
*/
@Override
default void close() {
}
Expand Down
16 changes: 13 additions & 3 deletions auth-api/src/main/java/tech/ydb/auth/AuthProvider.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package tech.ydb.auth;

/**
* Provides AuthIdentity instances for use in the operation of the YDB transport layer.
* Provides authentication identities without requiring a transport rpc.
*/
public interface AuthProvider extends AuthRpcProvider<Object> {
/**
* Create new instance of AuthIdentity
* @return new instance of AuthIdentity
* Returns an authentication identity for use by the transport.
*
* <p>Implementations may create an identity or reuse an existing one. The transport
* closes the returned identity when it no longer needs it.
*
* @return an authentication identity, or {@code null} for an anonymous connection
*/
AuthIdentity createAuthIdentity();

/**
* Returns an authentication identity by delegating to {@link #createAuthIdentity()}.
*
* @param rpc transport-provided helper; ignored by this implementation
* @return an authentication identity, or {@code null} for an anonymous connection
*/
@Override
default AuthIdentity createAuthIdentity(Object rpc) {
return createAuthIdentity();
Expand Down
15 changes: 10 additions & 5 deletions auth-api/src/main/java/tech/ydb/auth/AuthRpcProvider.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package tech.ydb.auth;

/**
* Provides AuthIdentity instances for use in the operation of the YDB transport layer.
* Provides authentication identities using a helper supplied by the YDB transport.
*
* @param <T> Optional type specification for a transport-provided helper.
* @param <T> the type of helper supplied by the transport
*/
public interface AuthRpcProvider<T> {
/**
* Create new instance of AuthIdentity
* @param rpc helper provided by a transport implementation
* @return new instance of AuthIdentity
* Returns an authentication identity for use by the transport.
*
* <p>The helper can be used to perform authentication requests. Implementations may
* create an identity or reuse an existing one. The transport closes the returned
* identity when it no longer needs it.
*
* @param rpc helper provided by the transport implementation
* @return an authentication identity, or {@code null} for an anonymous connection
*/
AuthIdentity createAuthIdentity(T rpc);
}
15 changes: 14 additions & 1 deletion auth-api/src/main/java/tech/ydb/auth/NopAuthProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@


/**
* Implementation of AuthProvider for anonymous connections
* Authentication provider for anonymous connections.
*
* <p>This provider returns no identity, so the transport sends no authentication token.
*/
public class NopAuthProvider implements AuthProvider {
/**
* Shared provider instance for anonymous connections.
*/
public static final NopAuthProvider INSTANCE = new NopAuthProvider();

/**
* Creates a provider for anonymous connections.
*/
protected NopAuthProvider() {
}

/**
* Returns no identity for an anonymous connection.
*
* @return {@code null}
*/
@Override
public AuthIdentity createAuthIdentity() {
return null;
Expand Down
16 changes: 15 additions & 1 deletion auth-api/src/main/java/tech/ydb/auth/TokenAuthProvider.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
package tech.ydb.auth;

/**
* Implementation of AuthProvider for connections with static token value
* Authentication provider that uses a fixed token value.
*
* <p>The token is returned unchanged and is never refreshed by this provider.
*/
public class TokenAuthProvider implements AuthProvider {
private final TokenIdentity identity;

/**
* Creates a provider that uses the supplied token for every request.
*
* @param token the authentication token, or {@code null} to send no token
*/
public TokenAuthProvider(String token) {
this.identity = new TokenIdentity(token);
}

/**
* Returns the identity holding this provider's fixed token.
*
* <p>Every call returns the same identity. Closing it has no effect.
*
* @return the shared identity holding the token supplied to the constructor
*/
@Override
public AuthIdentity createAuthIdentity() {
return identity;
Expand Down
10 changes: 0 additions & 10 deletions core/src/main/java/tech/ydb/core/auth/AuthIdentity.java

This file was deleted.

13 changes: 0 additions & 13 deletions core/src/main/java/tech/ydb/core/auth/AuthProvider.java

This file was deleted.

8 changes: 0 additions & 8 deletions core/src/main/java/tech/ydb/core/auth/AuthRpc.java

This file was deleted.

9 changes: 0 additions & 9 deletions core/src/main/java/tech/ydb/core/auth/NopAuthProvider.java

This file was deleted.

12 changes: 0 additions & 12 deletions core/src/main/java/tech/ydb/core/auth/TokenAuthProvider.java

This file was deleted.

10 changes: 5 additions & 5 deletions topic/src/main/java/tech/ydb/topic/write/WriteAck.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public static class Statistics {
/**
* Create the messages batch statistics object, for a single messages batch.
*
* @param persistingTime
* @param partitionQuotaWaitTime
* @param topicQuotaWaitTime
* @param maxQueueWaitTime
* @param minQueueWaitTime
* @param persistingTime time spent in persisting of data
* @param partitionQuotaWaitTime time spent awaiting for partition write quota.
* @param topicQuotaWaitTime time spent awaiting for topic write quota
* @param maxQueueWaitTime maximal time spent in queue before persisting
* @param minQueueWaitTime minimal time spent in queue before persisting
*/
public Statistics(Duration persistingTime,
Duration partitionQuotaWaitTime, Duration topicQuotaWaitTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -733,13 +733,13 @@ public void onMessages(DataReceivedEvent event) {
ReadEventHandler handler2 = new ReadEventHandler() {
@Override
public void onStartPartitionSession(StartPartitionSessionEvent event) {
events.add(event);
partitions2.countDown();
event.confirm();
}

@Override
public void onMessages(DataReceivedEvent event) {
int pid = (int) event.getPartitionSession().getPartitionId();
int pid = (int) event.getPartitionSession().getPartitionId();
for (Message msg : event.getMessages()) {
Assert.assertEquals(offsets[pid].getAndIncrement(), msg.getOffset());
read[pid].countDown();
Expand Down
Loading