From e8ff7ffe8e8c25195c64950b61c6c5754bbcd3ba Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Sun, 19 Feb 2017 00:25:42 +0000 Subject: Add grpc signer --- proto/signer.pb.go | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++ proto/signer.proto | 17 ++++++ 2 files changed, 189 insertions(+) create mode 100644 proto/signer.pb.go create mode 100644 proto/signer.proto (limited to 'proto') diff --git a/proto/signer.pb.go b/proto/signer.pb.go new file mode 100644 index 0000000..f3a0eb2 --- /dev/null +++ b/proto/signer.pb.go @@ -0,0 +1,172 @@ +// Code generated by protoc-gen-go. +// source: proto/signer.proto +// DO NOT EDIT! + +/* +Package proto is a generated protocol buffer package. + +It is generated from these files: + proto/signer.proto + +It has these top-level messages: + SignRequest + SignResponse +*/ +package proto + +import proto1 "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import google_protobuf "github.com/golang/protobuf/ptypes/timestamp" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto1.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package + +type SignRequest struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + ValidUntil *google_protobuf.Timestamp `protobuf:"bytes,2,opt,name=valid_until,json=validUntil" json:"valid_until,omitempty"` +} + +func (m *SignRequest) Reset() { *m = SignRequest{} } +func (m *SignRequest) String() string { return proto1.CompactTextString(m) } +func (*SignRequest) ProtoMessage() {} +func (*SignRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *SignRequest) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *SignRequest) GetValidUntil() *google_protobuf.Timestamp { + if m != nil { + return m.ValidUntil + } + return nil +} + +type SignResponse struct { + Cert []byte `protobuf:"bytes,1,opt,name=cert,proto3" json:"cert,omitempty"` +} + +func (m *SignResponse) Reset() { *m = SignResponse{} } +func (m *SignResponse) String() string { return proto1.CompactTextString(m) } +func (*SignResponse) ProtoMessage() {} +func (*SignResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *SignResponse) GetCert() []byte { + if m != nil { + return m.Cert + } + return nil +} + +func init() { + proto1.RegisterType((*SignRequest)(nil), "proto.SignRequest") + proto1.RegisterType((*SignResponse)(nil), "proto.SignResponse") +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// Client API for Signer service + +type SignerClient interface { + Sign(ctx context.Context, in *SignRequest, opts ...grpc.CallOption) (*SignResponse, error) +} + +type signerClient struct { + cc *grpc.ClientConn +} + +func NewSignerClient(cc *grpc.ClientConn) SignerClient { + return &signerClient{cc} +} + +func (c *signerClient) Sign(ctx context.Context, in *SignRequest, opts ...grpc.CallOption) (*SignResponse, error) { + out := new(SignResponse) + err := grpc.Invoke(ctx, "/proto.Signer/Sign", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for Signer service + +type SignerServer interface { + Sign(context.Context, *SignRequest) (*SignResponse, error) +} + +func RegisterSignerServer(s *grpc.Server, srv SignerServer) { + s.RegisterService(&_Signer_serviceDesc, srv) +} + +func _Signer_Sign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SignRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SignerServer).Sign(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Signer/Sign", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SignerServer).Sign(ctx, req.(*SignRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Signer_serviceDesc = grpc.ServiceDesc{ + ServiceName: "proto.Signer", + HandlerType: (*SignerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Sign", + Handler: _Signer_Sign_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/signer.proto", +} + +func init() { proto1.RegisterFile("proto/signer.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 197 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0xce, 0xb1, 0x6e, 0x83, 0x30, + 0x10, 0x06, 0xe0, 0xd2, 0x52, 0x86, 0x83, 0xa1, 0xba, 0x2e, 0x88, 0xa5, 0xc8, 0x13, 0x93, 0x51, + 0xe9, 0xc8, 0x5b, 0x40, 0xbb, 0x55, 0x8a, 0x20, 0xb9, 0x58, 0x56, 0xc0, 0x26, 0xd8, 0x44, 0xca, + 0xdb, 0x47, 0xd8, 0x41, 0x4a, 0xa6, 0xfb, 0xef, 0xf4, 0xeb, 0xd3, 0x01, 0x4e, 0xb3, 0xb6, 0xba, + 0x34, 0x52, 0x28, 0x9a, 0xb9, 0x5b, 0xf0, 0xdd, 0x8d, 0xec, 0x4b, 0x68, 0x2d, 0x06, 0x2a, 0xdd, + 0xd6, 0x2f, 0xc7, 0xd2, 0xca, 0x91, 0x8c, 0xed, 0xc6, 0xc9, 0xf7, 0xd8, 0x3f, 0xc4, 0xad, 0x14, + 0xaa, 0xa1, 0xf3, 0x42, 0xc6, 0xe2, 0x07, 0xbc, 0x9d, 0xe8, 0x9a, 0x06, 0x79, 0x50, 0x24, 0xcd, + 0x1a, 0xb1, 0x86, 0xf8, 0xd2, 0x0d, 0xf2, 0xb0, 0x5b, 0x94, 0x95, 0x43, 0xfa, 0x9a, 0x07, 0x45, + 0x5c, 0x65, 0xdc, 0xbb, 0x7c, 0x73, 0xf9, 0xef, 0xe6, 0x36, 0xe0, 0xea, 0x7f, 0x6b, 0x9b, 0x31, + 0x48, 0xbc, 0x6e, 0x26, 0xad, 0x0c, 0x21, 0x42, 0xb8, 0xa7, 0xd9, 0xde, 0x7d, 0x97, 0xab, 0x1a, + 0xa2, 0xd6, 0x7d, 0x8e, 0xdf, 0x10, 0xae, 0x09, 0xd1, 0xb3, 0xfc, 0xe1, 0xb1, 0xec, 0xf3, 0xe9, + 0xe6, 0x39, 0xf6, 0xd2, 0x47, 0xee, 0xfa, 0x73, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x30, 0x72, + 0x63, 0x03, 0x01, 0x00, 0x00, +} diff --git a/proto/signer.proto b/proto/signer.proto new file mode 100644 index 0000000..83f180d --- /dev/null +++ b/proto/signer.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package proto; + +import "google/protobuf/timestamp.proto"; + +message SignRequest { + bytes key = 1; + google.protobuf.Timestamp valid_until = 2; +} + +message SignResponse { + bytes cert = 1; +} + +service Signer { + rpc Sign(SignRequest) returns (SignResponse) {} +} -- cgit v1.2.3