mirror of https://github.com/grpc/grpc-java.git
alts: add call credential security level attribute (#4657)
This commit is contained in:
parent
603d858186
commit
499f95d3ec
|
|
@ -20,7 +20,9 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.protobuf.Any;
|
import com.google.protobuf.Any;
|
||||||
import io.grpc.Attributes;
|
import io.grpc.Attributes;
|
||||||
|
import io.grpc.CallCredentials;
|
||||||
import io.grpc.Grpc;
|
import io.grpc.Grpc;
|
||||||
|
import io.grpc.SecurityLevel;
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
import io.grpc.alts.internal.RpcProtocolVersionsUtil.RpcVersionsCheckResult;
|
import io.grpc.alts.internal.RpcProtocolVersionsUtil.RpcVersionsCheckResult;
|
||||||
import io.grpc.alts.internal.TsiHandshakeHandler.TsiHandshakeCompletionEvent;
|
import io.grpc.alts.internal.TsiHandshakeHandler.TsiHandshakeCompletionEvent;
|
||||||
|
|
@ -122,6 +124,7 @@ public abstract class AltsProtocolNegotiator implements ProtocolNegotiator {
|
||||||
.set(TSI_PEER_KEY, altsEvt.peer())
|
.set(TSI_PEER_KEY, altsEvt.peer())
|
||||||
.set(ALTS_CONTEXT_KEY, altsContext)
|
.set(ALTS_CONTEXT_KEY, altsContext)
|
||||||
.set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress())
|
.set(Grpc.TRANSPORT_ATTR_REMOTE_ADDR, ctx.channel().remoteAddress())
|
||||||
|
.set(CallCredentials.ATTR_SECURITY_LEVEL, SecurityLevel.PRIVACY_AND_INTEGRITY)
|
||||||
.build(),
|
.build(),
|
||||||
new Security(new OtherSecurity("alts", Any.pack(altsContext.context))));
|
new Security(new OtherSecurity("alts", Any.pack(altsContext.context))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,9 @@ import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import io.grpc.Attributes;
|
import io.grpc.Attributes;
|
||||||
|
import io.grpc.CallCredentials;
|
||||||
import io.grpc.Grpc;
|
import io.grpc.Grpc;
|
||||||
|
import io.grpc.SecurityLevel;
|
||||||
import io.grpc.alts.internal.Handshaker.HandshakerResult;
|
import io.grpc.alts.internal.Handshaker.HandshakerResult;
|
||||||
import io.grpc.alts.internal.TsiFrameProtector.Consumer;
|
import io.grpc.alts.internal.TsiFrameProtector.Consumer;
|
||||||
import io.grpc.alts.internal.TsiPeer.Property;
|
import io.grpc.alts.internal.TsiPeer.Property;
|
||||||
|
|
@ -343,6 +345,8 @@ public class AltsProtocolNegotiatorTest {
|
||||||
.isEqualTo(mockedAltsContext);
|
.isEqualTo(mockedAltsContext);
|
||||||
assertThat(grpcHandler.attrs.get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR).toString())
|
assertThat(grpcHandler.attrs.get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR).toString())
|
||||||
.isEqualTo("embedded");
|
.isEqualTo("embedded");
|
||||||
|
assertThat(grpcHandler.attrs.get(CallCredentials.ATTR_SECURITY_LEVEL))
|
||||||
|
.isEqualTo(SecurityLevel.PRIVACY_AND_INTEGRITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doHandshake() throws Exception {
|
private void doHandshake() throws Exception {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue