Commit 363a2d23 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia

[OPENBUS-2668] (Lua) Adicionar suporte a chamadas legadas (OpenBus 2.0)

git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/sdk/lua/trunk@158348 ae0415b3-e90b-0410-900d-d0be9363c56b
parent 57990b2e
......@@ -109,6 +109,8 @@ local receiveBusReply = BaseInterceptor.receivereply
local receiveBusRequest = BaseInterceptor.receiverequest
local unmarshalCredential = BaseInterceptor.unmarshalCredential
local unmarshalSignedChain = BaseInterceptor.unmarshalSignedChain
local oldidl = require "openbus.core.legacy.idl"
local LegacyAccessControlRepId = oldidl.types.services.access_control.AccessControl
-- must be loaded after OiL is loaded because OiL is the one that installs
-- the cothread plug-in that supports the 'now' operation.
......@@ -116,6 +118,8 @@ cothread.plugin(require "cothread.plugin.sleep")
local delay = cothread.delay
local time = cothread.now
local IComponentRepId = "IDL:scs/core/IComponent:1.0"
do
local isNoPerm = is_NO_PERMISSION
function is_NO_PERMISSION(except, minor, completed)
......@@ -296,6 +300,20 @@ local function localLogin(self, AccessControl, busid, buskey, login, lease)
self.LoginRegistry = newLoginRegistryWrapper(LoginRegistry, buskey)
self.login = login
newRenewer(self, lease)
if self.legacy then
local legacy = getCoreFacet(self, "LegacySupport", IComponentRepId)
if legacy ~= nil then
legacy = legacy:getFacetByName("AccessControl")
if legacy ~= nil then
legacy = self.context.orb:narrow(legacy, LegacyAccessControlRepId)
else
log:exception(msg.LegacySupportMissing)
end
else
log:exception(msg.LegacySupportNotAvailable)
end
self.legacy = legacy
end
end
local function localLogout(self)
......@@ -370,7 +388,7 @@ end
local NullChain = {}
function Connection:signChainFor(target, chain)
if target == BusEntity then return chain end
if target == BusEntity then return chain, chain.islegacy end
local access = self.AccessControl
local cache = self.signedChainOf[chain or NullChain]
local joined = cache:get(target)
......@@ -715,6 +733,7 @@ function Context:connectByReference(bus, props)
orb = self.orb,
bus = bus,
prvkey = prvkey or self.prvkey,
legacy = not props.nolegacy,
}
end
......@@ -771,7 +790,7 @@ function Context:getOfferRegistry()
return getCoreFacet(conn, "OfferRegistry", OfferRegistryRepId)
end
function Context:makeChainFor(loginId)
function Context:makeChainFor(target)
local conn = self:getCurrentConnection()
if conn == nil or conn.login == nil then
NO_PERMISSION{
......@@ -779,7 +798,7 @@ function Context:makeChainFor(loginId)
minor = NoLoginCode,
}
end
local signed = conn:signChainFor(loginId, self:getJoinedChain())
local signed = conn:signChainFor(target, self:getJoinedChain())
local chain = unmarshalSignedChain(self, signed)
chain.busid = conn.busid
return chain
......
This diff is collapsed.
local _G = require "_G"
local ipairs = _G.ipairs
local array = require "table"
local unpack = array.unpack or _G.unpack
local debug = require "debug"
local traceback = debug.traceback
local makeaux = require "openbus.core.idl.makeaux"
local parsed = require "openbus.core.legacy.parsed"
local types, const, throw = {}, {}, {}
for _, parsed in ipairs(parsed) do
if parsed.name == "tecgraf" then
makeaux(parsed, types, const, throw)
end
end
local idl = {
types = types.tecgraf.openbus.core.v2_0,
const = const.tecgraf.openbus.core.v2_0,
throw = throw.tecgraf.openbus.core.v2_0,
}
local ServiceFailure
do
local failure = idl.throw.services.ServiceFailure
function ServiceFailure(fields)
fields.stacktrace = traceback()
return failure(fields)
end
idl.throw.services.ServiceFailure = ServiceFailure
end
function idl.serviceAssertion(ok, errmsg, ...)
if not ok then ServiceFailure{message = errmsg or "assertion failed"} end
return ok, errmsg, ...
end
function idl.loadto(orb)
orb.TypeRepository.registry:register(unpack(parsed))
end
return idl
local _G = require "_G"
local assert = _G.assert
local io = require "io"
local stderr = io.stderr
local luaidl = require "luaidl"
local parse = luaidl.parse
local idlspec = [[
#include "access_control.idl"
#include "offer_registry.idl"
#include "data_export.idl"
]]
local idlpath = os.getenv("OPENBUS_IDLPATH")
if idlpath == nil then
stderr:write("OPENBUS_IDLPATH is not defined! Using '.' as default.\n")
idlpath = "."
end
local Compiler = require "oil.corba.idl.Compiler"
local options = Compiler().defaults
options.incpath = {
idlpath.."/old",
idlpath.."/scs",
}
return { assert(parse(idlspec, options)) }
......@@ -6,8 +6,8 @@ local select = _G.select
local table = require "loop.table"
local memoize = table.memoize
local function create(weakmode)
return memoize(create, weakmode)
local function create()
return memoize(create)
end
local function remove(table, key, ...)
......
......@@ -5,6 +5,7 @@ SRC= $(PRELOAD_DIR)/$(LIBNAME).c
OPENBUSSCSIDL= ${SCS_IDL1_2_HOME}/src
OPENBUSNEWIDL= ${OPENBUS_IDL2_1_HOME}/src
OPENBUSOLDIDL= ${OPENBUS_IDL2_0_HOME}/src
OPENBUSLIBIDL= ${SDK_IDL_SOURCE_HOME}/src
LUADIR= ../lua
......@@ -15,6 +16,8 @@ LUASRC= \
$(LUADIR)/openbus/core/idl/makeaux.lua \
$(LUADIR)/openbus/core/idl/parsed.lua \
$(LUADIR)/openbus/core/idl.lua \
$(LUADIR)/openbus/core/legacy/idl.lua \
$(LUADIR)/openbus/core/legacy/parsed.lua \
$(LUADIR)/openbus/core/messages.lua \
$(LUADIR)/openbus/idl/parsed.lua \
$(LUADIR)/openbus/idl.lua \
......@@ -44,6 +47,16 @@ NEWDEPENDENTIDL= \
$(OPENBUSNEWIDL)/credential.idl \
$(OPENBUSSCSIDL)/scs.idl
OLDIDL= \
$(OPENBUSOLDIDL)/access_control.idl \
$(OPENBUSOLDIDL)/offer_registry.idl \
$(OPENBUSOLDIDL)/data_export.idl
OLDDEPENDENTIDL= \
$(OPENBUSOLDIDL)/core.idl \
$(OPENBUSOLDIDL)/credential.idl \
$(OPENBUSSCSIDL)/scs.idl
include ${OIL_HOME}/openbus/base.mak
$(LUADIR)/openbus/idl/parsed.lua: $(IDL2LUA) $(LIBIDL) $(NEWIDL) $(NEWDEPENDENTIDL) $(LIBDEPENDENTIDL)
......@@ -51,3 +64,6 @@ $(LUADIR)/openbus/idl/parsed.lua: $(IDL2LUA) $(LIBIDL) $(NEWIDL) $(NEWDEPENDENTI
$(LUADIR)/openbus/core/idl/parsed.lua: $(IDL2LUA) $(NEWIDL) $(NEWDEPENDENTIDL)
$(OILBIN) $(IDL2LUA) -I $(OPENBUSSCSIDL) -I $(OPENBUSNEWIDL) -o $@ $(NEWIDL)
$(LUADIR)/openbus/core/legacy/parsed.lua: $(IDL2LUA) $(OLDIDL) $(OLDDEPENDENTIDL)
$(OILBIN) $(IDL2LUA) -I $(OPENBUSSCSIDL) -I $(OPENBUSOLDIDL) -o $@ $(OLDIDL)
......@@ -109,7 +109,7 @@ end
do -- protocol data encoding functions
function calculateHash(secret, ticket, opname)
return sha256("\002\000"..encode(
return sha256("\002\001"..encode(
"<c0I4c0", -- '<' flag to set to little endian
secret, -- 'c0' sequence of all chars of a string
ticket, -- 'I4' unsigned integer with 4 bytes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment