|
definition: |
generateAuthorizations :: String -> [Entity] -> CurryProg
generateAuthorizations erdname entities = simpleCurryProg
enauthModName
[authorizationModule, sessionInfoModule, model erdname] -- imports
[] -- typedecls
-- functions
(map operationAllowed entities)
[] -- opdecls
where
operationAllowed (Entity entityName _) =
stCmtFunc
("Checks whether the application of an operation to a "++entityName++"\n"++
"entity is allowed.")
(enauthModName, lowerFirst entityName ++ "OperationAllowed")
1
Public
(applyTC (authorizationModule,"AccessType")
[baseType (model erdname, entityName)]
~> baseType (sessionInfoModule,"UserSessionInfo")
~> ioType (baseType (authorizationModule,"AccessResult")))
[simpleRule [CPVar (1,"at"), CPVar (2,"_")]
(CCase CRigid (CVar (1,"at"))
[cBranch (CPComb (authorizationModule,"ListEntities") []) allowed,
cBranch (CPComb (authorizationModule,"NewEntity") []) allowed,
cBranch (CPComb (authorizationModule,"ShowEntity") [CPVar (3,"_")])
allowed,
cBranch (CPComb (authorizationModule,"DeleteEntity") [CPVar (3,"_")])
allowed,
cBranch (CPComb (authorizationModule,"UpdateEntity") [CPVar (3,"_")])
allowed])]
-- Expression implemented access allowed
allowed = applyF (pre "return") [constF (authorizationModule,"AccessGranted")]
|
|
demand: |
no demanded arguments |
|
deterministic: |
deterministic operation |
|
documentation: |
--------------------------------------------------------------------- Generate all default authorizations. |
|
failfree: |
(_, _) |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,_) |-> {CurryProg}}
|
|
name: |
generateAuthorizations |
|
precedence: |
no precedence defined |
|
result-values: |
{CurryProg}
|
|
signature: |
String -> [Database.ERD.Entity] -> AbstractCurry.Types.CurryProg |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |