This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(security): add ReplicaSession interceptor (#135)
- Loading branch information
Showing
12 changed files
with
183 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.xiaomi.infra.pegasus.rpc.interceptor; | ||
|
||
import com.xiaomi.infra.pegasus.rpc.async.ReplicaSession; | ||
|
||
public interface ReplicaSessionInterceptor { | ||
// The behavior when a rpc session is connected. | ||
void onConnected(ReplicaSession session); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/xiaomi/infra/pegasus/rpc/interceptor/ReplicaSessionInterceptorManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.xiaomi.infra.pegasus.rpc.interceptor; | ||
|
||
import com.xiaomi.infra.pegasus.client.ClientOptions; | ||
import com.xiaomi.infra.pegasus.rpc.async.ReplicaSession; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ReplicaSessionInterceptorManager { | ||
private List<ReplicaSessionInterceptor> interceptors = new ArrayList<>(); | ||
|
||
public ReplicaSessionInterceptorManager(ClientOptions options) { | ||
if (options.isEnableAuth()) { | ||
ReplicaSessionInterceptor securityInterceptor = | ||
new SecurityReplicaSessionInterceptor(options.getServiceName(), options.getServiceFQDN()); | ||
interceptors.add(securityInterceptor); | ||
} | ||
} | ||
|
||
public void onConnected(ReplicaSession session) { | ||
for (ReplicaSessionInterceptor interceptor : interceptors) { | ||
interceptor.onConnected(session); | ||
} | ||
} | ||
} |
Oops, something went wrong.