Asim Shankar | 6107179 | 2014-07-22 13:03:18 -0700 | [diff] [blame^] | 1 | // This file was auto-generated by the veyron vdl tool. |
| 2 | // Source: identity.vdl |
| 3 | |
| 4 | // Package identity defines services for identity providers in the veyron ecosystem. |
| 5 | package identity |
| 6 | |
| 7 | import ( |
| 8 | // The non-user imports are prefixed with "_gen_" to prevent collisions. |
| 9 | _gen_veyron2 "veyron2" |
| 10 | _gen_context "veyron2/context" |
| 11 | _gen_ipc "veyron2/ipc" |
| 12 | _gen_naming "veyron2/naming" |
| 13 | _gen_rt "veyron2/rt" |
| 14 | _gen_vdlutil "veyron2/vdl/vdlutil" |
| 15 | _gen_wiretype "veyron2/wiretype" |
| 16 | ) |
| 17 | |
| 18 | // OAuthBlesser exchanges the provided authorization code for an email addres |
| 19 | // from an OAuth-based identity provider and uses the email address as the |
| 20 | // name to bless the client with. |
| 21 | // |
| 22 | // The redirect URL used to obtain the authorization code must also be |
| 23 | // provided in order to ensure a successful exchange. |
| 24 | // OAuthBlesser is the interface the client binds and uses. |
| 25 | // OAuthBlesser_ExcludingUniversal is the interface without internal framework-added methods |
| 26 | // to enable embedding without method collisions. Not to be used directly by clients. |
| 27 | type OAuthBlesser_ExcludingUniversal interface { |
| 28 | // TODO(ashankar,toddw): Once the "OneOf" type becomes available in VDL, |
| 29 | // then the "any" should be replaced by: |
| 30 | // OneOf<wire.ChainPublicID, []wire.ChainPublicID> |
| 31 | // where wire is from: |
| 32 | // import "veyron2/security/wire" |
| 33 | Bless(ctx _gen_context.T, authcode string, redirecturl string, opts ..._gen_ipc.CallOpt) (reply _gen_vdlutil.Any, err error) |
| 34 | } |
| 35 | type OAuthBlesser interface { |
| 36 | _gen_ipc.UniversalServiceMethods |
| 37 | OAuthBlesser_ExcludingUniversal |
| 38 | } |
| 39 | |
| 40 | // OAuthBlesserService is the interface the server implements. |
| 41 | type OAuthBlesserService interface { |
| 42 | |
| 43 | // TODO(ashankar,toddw): Once the "OneOf" type becomes available in VDL, |
| 44 | // then the "any" should be replaced by: |
| 45 | // OneOf<wire.ChainPublicID, []wire.ChainPublicID> |
| 46 | // where wire is from: |
| 47 | // import "veyron2/security/wire" |
| 48 | Bless(context _gen_ipc.ServerContext, authcode string, redirecturl string) (reply _gen_vdlutil.Any, err error) |
| 49 | } |
| 50 | |
| 51 | // BindOAuthBlesser returns the client stub implementing the OAuthBlesser |
| 52 | // interface. |
| 53 | // |
| 54 | // If no _gen_ipc.Client is specified, the default _gen_ipc.Client in the |
| 55 | // global Runtime is used. |
| 56 | func BindOAuthBlesser(name string, opts ..._gen_ipc.BindOpt) (OAuthBlesser, error) { |
| 57 | var client _gen_ipc.Client |
| 58 | switch len(opts) { |
| 59 | case 0: |
| 60 | client = _gen_rt.R().Client() |
| 61 | case 1: |
| 62 | switch o := opts[0].(type) { |
| 63 | case _gen_veyron2.Runtime: |
| 64 | client = o.Client() |
| 65 | case _gen_ipc.Client: |
| 66 | client = o |
| 67 | default: |
| 68 | return nil, _gen_vdlutil.ErrUnrecognizedOption |
| 69 | } |
| 70 | default: |
| 71 | return nil, _gen_vdlutil.ErrTooManyOptionsToBind |
| 72 | } |
| 73 | stub := &clientStubOAuthBlesser{client: client, name: name} |
| 74 | |
| 75 | return stub, nil |
| 76 | } |
| 77 | |
| 78 | // NewServerOAuthBlesser creates a new server stub. |
| 79 | // |
| 80 | // It takes a regular server implementing the OAuthBlesserService |
| 81 | // interface, and returns a new server stub. |
| 82 | func NewServerOAuthBlesser(server OAuthBlesserService) interface{} { |
| 83 | return &ServerStubOAuthBlesser{ |
| 84 | service: server, |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // clientStubOAuthBlesser implements OAuthBlesser. |
| 89 | type clientStubOAuthBlesser struct { |
| 90 | client _gen_ipc.Client |
| 91 | name string |
| 92 | } |
| 93 | |
| 94 | func (__gen_c *clientStubOAuthBlesser) Bless(ctx _gen_context.T, authcode string, redirecturl string, opts ..._gen_ipc.CallOpt) (reply _gen_vdlutil.Any, err error) { |
| 95 | var call _gen_ipc.Call |
| 96 | if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Bless", []interface{}{authcode, redirecturl}, opts...); err != nil { |
| 97 | return |
| 98 | } |
| 99 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 100 | err = ierr |
| 101 | } |
| 102 | return |
| 103 | } |
| 104 | |
| 105 | func (__gen_c *clientStubOAuthBlesser) UnresolveStep(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply []string, err error) { |
| 106 | var call _gen_ipc.Call |
| 107 | if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "UnresolveStep", nil, opts...); err != nil { |
| 108 | return |
| 109 | } |
| 110 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 111 | err = ierr |
| 112 | } |
| 113 | return |
| 114 | } |
| 115 | |
| 116 | func (__gen_c *clientStubOAuthBlesser) Signature(ctx _gen_context.T, opts ..._gen_ipc.CallOpt) (reply _gen_ipc.ServiceSignature, err error) { |
| 117 | var call _gen_ipc.Call |
| 118 | if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "Signature", nil, opts...); err != nil { |
| 119 | return |
| 120 | } |
| 121 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 122 | err = ierr |
| 123 | } |
| 124 | return |
| 125 | } |
| 126 | |
| 127 | func (__gen_c *clientStubOAuthBlesser) GetMethodTags(ctx _gen_context.T, method string, opts ..._gen_ipc.CallOpt) (reply []interface{}, err error) { |
| 128 | var call _gen_ipc.Call |
| 129 | if call, err = __gen_c.client.StartCall(ctx, __gen_c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil { |
| 130 | return |
| 131 | } |
| 132 | if ierr := call.Finish(&reply, &err); ierr != nil { |
| 133 | err = ierr |
| 134 | } |
| 135 | return |
| 136 | } |
| 137 | |
| 138 | // ServerStubOAuthBlesser wraps a server that implements |
| 139 | // OAuthBlesserService and provides an object that satisfies |
| 140 | // the requirements of veyron2/ipc.ReflectInvoker. |
| 141 | type ServerStubOAuthBlesser struct { |
| 142 | service OAuthBlesserService |
| 143 | } |
| 144 | |
| 145 | func (__gen_s *ServerStubOAuthBlesser) GetMethodTags(call _gen_ipc.ServerCall, method string) ([]interface{}, error) { |
| 146 | // TODO(bprosnitz) GetMethodTags() will be replaces with Signature(). |
| 147 | // Note: This exhibits some weird behavior like returning a nil error if the method isn't found. |
| 148 | // This will change when it is replaced with Signature(). |
| 149 | switch method { |
| 150 | case "Bless": |
| 151 | return []interface{}{}, nil |
| 152 | default: |
| 153 | return nil, nil |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | func (__gen_s *ServerStubOAuthBlesser) Signature(call _gen_ipc.ServerCall) (_gen_ipc.ServiceSignature, error) { |
| 158 | result := _gen_ipc.ServiceSignature{Methods: make(map[string]_gen_ipc.MethodSignature)} |
| 159 | result.Methods["Bless"] = _gen_ipc.MethodSignature{ |
| 160 | InArgs: []_gen_ipc.MethodArgument{ |
| 161 | {Name: "authcode", Type: 3}, |
| 162 | {Name: "redirecturl", Type: 3}, |
| 163 | }, |
| 164 | OutArgs: []_gen_ipc.MethodArgument{ |
| 165 | {Name: "blessing", Type: 65}, |
| 166 | {Name: "err", Type: 66}, |
| 167 | }, |
| 168 | } |
| 169 | |
| 170 | result.TypeDefs = []_gen_vdlutil.Any{ |
| 171 | _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "anydata", Tags: []string(nil)}, _gen_wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}} |
| 172 | |
| 173 | return result, nil |
| 174 | } |
| 175 | |
| 176 | func (__gen_s *ServerStubOAuthBlesser) UnresolveStep(call _gen_ipc.ServerCall) (reply []string, err error) { |
| 177 | if unresolver, ok := __gen_s.service.(_gen_ipc.Unresolver); ok { |
| 178 | return unresolver.UnresolveStep(call) |
| 179 | } |
| 180 | if call.Server() == nil { |
| 181 | return |
| 182 | } |
| 183 | var published []string |
| 184 | if published, err = call.Server().Published(); err != nil || published == nil { |
| 185 | return |
| 186 | } |
| 187 | reply = make([]string, len(published)) |
| 188 | for i, p := range published { |
| 189 | reply[i] = _gen_naming.Join(p, call.Name()) |
| 190 | } |
| 191 | return |
| 192 | } |
| 193 | |
| 194 | func (__gen_s *ServerStubOAuthBlesser) Bless(call _gen_ipc.ServerCall, authcode string, redirecturl string) (reply _gen_vdlutil.Any, err error) { |
| 195 | reply, err = __gen_s.service.Bless(call, authcode, redirecturl) |
| 196 | return |
| 197 | } |