Пример #1
0
        public AuthRoleRevokePermissionResponse RoleRevokePermission(ByteSequence role,
                                                                     ByteSequence key, ByteSequence rangeEnd)
        {
            Etcdserverpb.AuthRoleRevokePermissionRequest roleRevokePermissionRequest = new Etcdserverpb.AuthRoleRevokePermissionRequest();
            roleRevokePermissionRequest.Role     = role.ToString();
            roleRevokePermissionRequest.Key      = role.ToString();
            roleRevokePermissionRequest.RangeEnd = rangeEnd.ToString();
            var rsp = authClient.RoleRevokePermission(roleRevokePermissionRequest);
            AuthRoleRevokePermissionResponse response = new AuthRoleRevokePermissionResponse(rsp);

            return(response);
            //  return Util.ToCompletableFuture(
            //        this.stub.roleRevokePermission(roleRevokePermissionRequest),
            //     new FunctionResponse<Etcdserverpb.AuthRoleRevokePermissionRequest, AuthRoleRevokePermissionResponse>());
        }
Пример #2
0
        public AuthUserGetResponse UserGet(ByteSequence user)
        {
            Etcdserverpb.AuthUserGetRequest userGetRequest = new Etcdserverpb.AuthUserGetRequest();
            userGetRequest.Name = user.ToString();
            var rsp = authClient.UserGet(userGetRequest);
            AuthUserGetResponse response = new AuthUserGetResponse(rsp);

            return(response);
            //return Util.ToCompletableFuture(
            //    this.stub.userGet(userGetRequest),
            //    new FunctionResponse<Etcdserverpb.AuthUserGetRequest, AuthUserGetResponse>());
        }
Пример #3
0
        public AuthRoleDeleteResponse RoleDelete(ByteSequence role)
        {
            Etcdserverpb.AuthRoleDeleteRequest roleDeleteRequest = new Etcdserverpb.AuthRoleDeleteRequest();
            roleDeleteRequest.Role = role.ToString();
            var rsp = authClient.RoleDelete(roleDeleteRequest);
            AuthRoleDeleteResponse response = new AuthRoleDeleteResponse(rsp);

            return(response);
            //  return Util.ToCompletableFuture(
            //   this.stub.roleDelete(roleDeleteRequest),
            //   new FunctionResponse<Etcdserverpb.AuthRoleDeleteRequest, AuthRoleDeleteResponse>());
        }
        /**
         * get token from etcd with name and password.
         *
         * @param channel channel to etcd
         * @param username auth name
         * @param password auth password
         * @return authResp
         */
        private static AuthenticateResponse Authenticate(Channel channel, ByteSequence username, ByteSequence password)
        {
            AuthenticateRequest requet = new AuthenticateRequest();

            requet.Name     = username.ToString();
            requet.Password = password.ToString();
            Auth.AuthClient      authClient = new Auth.AuthClient(channel);
            var                  rsp        = authClient.Authenticate(requet);
            AuthenticateResponse response   = new AuthenticateResponse(rsp);

            return(response);
        }
Пример #5
0
        public AuthUserAddResponse UserAdd(ByteSequence user, ByteSequence password)
        {
            Etcdserverpb.AuthUserAddRequest addRequest = new Etcdserverpb.AuthUserAddRequest();
            addRequest.Name     = user.ToString();
            addRequest.Password = password.ToString();
            var rsp = authClient.UserAdd(addRequest);
            AuthUserAddResponse response = new AuthUserAddResponse(rsp);

            return(response);
            //return Util.ToCompletableFuture(
            //    this.stub.userAdd(addRequest),
            //   new FunctionResponse<Etcdserverpb.AuthUserAddRequest, AuthUserAddResponse>());
        }
Пример #6
0
        public AuthUserRevokeRoleResponse UserRevokeRole(ByteSequence user, ByteSequence role)
        {
            Etcdserverpb.AuthUserRevokeRoleRequest userRevokeRoleRequest = new Etcdserverpb.AuthUserRevokeRoleRequest();
            userRevokeRoleRequest.Name = user.ToString();
            userRevokeRoleRequest.Role = role.ToString();
            var rsp = authClient.UserRevokeRole(userRevokeRoleRequest);
            AuthUserRevokeRoleResponse response = new AuthUserRevokeRoleResponse(rsp);

            return(response);
            //return Util.ToCompletableFuture(
            //authClient.UserRevokeRole(userRevokeRoleRequest),
            //new FunctionResponse<Etcdserverpb.AuthUserRevokeRoleResponse, AuthUserRevokeRoleResponse>());
        }
Пример #7
0
        public AuthRoleGrantPermissionResponse RoleGrantPermission(ByteSequence role,
                                                                   ByteSequence key, ByteSequence rangeEnd, auth.Permission.Type permType)
        {
            Authpb.Permission.Types.Type type;
            switch (permType)
            {
            case Permission.Type.WRITE:
                type = Authpb.Permission.Types.Type.Write;
                break;

            case Permission.Type.READWRITE:
                type = Authpb.Permission.Types.Type.Readwrite;
                break;

            case Permission.Type.READ:
                type = Authpb.Permission.Types.Type.Read;
                break;

            default:
                type = Authpb.Permission.Types.Type.Readwrite;
                break;
            }
            Authpb.Permission perm = new Authpb.Permission();
            perm.Key      = key.GetByteString();
            perm.RangeEnd = rangeEnd.GetByteString();
            perm.PermType = type;
            Etcdserverpb.AuthRoleGrantPermissionRequest roleGrantPermissionRequest = new Etcdserverpb.AuthRoleGrantPermissionRequest();
            roleGrantPermissionRequest.Name = role.ToString();
            roleGrantPermissionRequest.Perm = perm;
            var rsp = authClient.RoleGrantPermission(roleGrantPermissionRequest);
            AuthRoleGrantPermissionResponse response = new AuthRoleGrantPermissionResponse(rsp);

            return(response);
            // return Util.ToCompletableFuture(
            // this.stub.roleGrantPermission(roleGrantPermissionRequest),
            //  new FunctionResponse<Etcdserverpb.AuthRoleGrantPermissionRequest, AuthRoleGrantPermissionResponse>());
        }
Пример #8
0
 /**
  * config etcd auth password.
  *
  * @param password etcd auth password
  * @return this builder
  * @throws NullPointerException if password is <code>null</code>
  */
 public ClientBuilder SetPassword(ByteSequence password)
 {
     this.password = password.ToString();
     return(this);
 }
Пример #9
0
 /**
  * config etcd auth user.
  *
  * @param user etcd auth user
  * @return this builder
  * @throws NullPointerException if user is <code>null</code>
  */
 public ClientBuilder SetUser(ByteSequence user)
 {
     this.user = user.ToString();
     return(this);
 }