Skip to content

Commit

Permalink
all namespace mapping test (no need in writable CACHELIB anymore)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Dec 11, 2015
1 parent bbb02b4 commit fa30992
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
74 changes: 45 additions & 29 deletions export/template.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Class name="%WebTerminal.Engine">
<Class name="WebTerminal.Engine">
<Description>
Cache WEB Terminal vX.X.X/*build.replace:pkg.version*/
This class is the core of web terminal application.</Description>
Expand Down Expand Up @@ -928,20 +928,23 @@ the client - it includes authorization key.</Description>
/*
* Find given CSPSessionCookie in WebTerminal auth global. If found, grant access.
*/
SET key = $ORDER(^WebTerminal.AuthUser(""))
SET key = $ORDER(^%WebTerminal.AuthUser(""))
WHILE (key '= "") {
set lb = $GET(^WebTerminal.AuthUser(key))
set lb = $GET(^%WebTerminal.AuthUser(key))
if ((lb '= "") && (key = authKey)) {
// setup privileges
set username = $LISTGET(lb, 1) // user name
set ns = $namespace
zn "%SYS"
do ##class(Security.Users).Get(username, .userProps)
zn ns
continue:($order(userProps("")) = "")
set namespace = $case(namespace, "":userProps("NameSpace"), :namespace)
set loginStatus = ##class(%SYSTEM.Security).Login(username) // login user
kill ^WebTerminal.AuthUser(key)
kill ^%WebTerminal.AuthUser(key)
set ok = loginStatus
Expand All @@ -950,10 +953,10 @@ the client - it includes authorization key.</Description>
// kill "old" auth tickets
set time = $LISTGET(lb, 2)
if (time '= "") && ($SYSTEM.SQL.DATEDIFF("s", time, $h) > 100) { // if older than 100 sec
kill ^WebTerminal.AuthUser(key)
kill ^%WebTerminal.AuthUser(key)
}
SET key = $ORDER(^WebTerminal.AuthUser(key))
SET key = $ORDER(^%WebTerminal.AuthUser(key))
}
if (namespace '= "") {
Expand Down Expand Up @@ -1102,15 +1105,16 @@ New connection established: require auth key, login and start client loop.</Desc
</Class>


<Class name="%WebTerminal.Installer">
<Class name="WebTerminal.Installer">
<Description>
Importing this class will install Cache WEB Terminal properly.</Description>
<CompileAfter>Engine,Router,StaticContent</CompileAfter>
<Super>%Projection.AbstractProjection</Super>
<TimeChanged>63898,2021.685611</TimeChanged>
<TimeCreated>63890,71053.144208</TimeCreated>

<Parameter name="DispatchClass">
<Default>%WebTerminal.Router</Default>
<Default>WebTerminal.Router</Default>
</Parameter>

<Projection name="Reference">
Expand All @@ -1128,7 +1132,7 @@ This method is invoked when a class is compiled.</Description>
zn:ns'="%SYS" "%SYS"
do ##class(Security.System).GetInstallationSecuritySetting(.security)
set cspProperties("AutheEnabled") = 32 // password by default, 64 for no password
set cspProperties("NameSpace") = "%SYS" // terminal works only in %SYS namespace, only in % package
set cspProperties("NameSpace") = ns // terminal works only in %SYS namespace, only in % package
set cspProperties("Description") = "A WEB application for Cache WEB Terminal."
set cspProperties("IsNameSpaceDefault") = 0
set cspProperties("DispatchClass") = ..#DispatchClass
Expand All @@ -1137,7 +1141,7 @@ This method is invoked when a class is compiled.</Description>
set tSC = ##class(Security.Applications).Create("/terminal", .cspProperties)
if $$$ISERR(tSC) throw ##class(%Installer.Exception).CreateFromStatus(tSC)
w !, "WEB application ""/terminal"" is created."
set ^SYS("Security", "CSP", "AllowClass", "/terminal/", ..#DispatchClass) = 1
//set ^SYS("Security", "CSP", "AllowClass", "/terminal/", ..#DispatchClass) = 1
} else {
do ##class(Security.Applications).Get("/terminal", .props)
if (props("DispatchClass") '= ..#DispatchClass) {
Expand All @@ -1148,7 +1152,6 @@ This method is invoked when a class is compiled.</Description>
w !, "WEB application ""/terminal"" already exists, so it is ready to use."
}
}
w !, "Mapping %WebTerminal package to %All namespace..."
set status = ##Class(Config.Namespaces).Get("%All")
if ($$$ISERR(status)) { // no namespace %All
w !, "Creating %All namespace..."
Expand All @@ -1163,20 +1166,22 @@ This method is invoked when a class is compiled.</Description>
do $SYSTEM.Status.DisplayError(status)
quit status
} else {
w !, "%All namespace created."
w !, "%All namespace is created."
}
}
w !, "Mapping %WebTerminal package into all namespaces:"
set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
set Properties("Database") = "CACHETEMP"
set status=##Class(Config.MapPackages).Create("%All", "%WebTerminal", .Properties)
if ($$$ISERR(status)) {
do $SYSTEM.Status.DisplayError(status)
}
set Properties("Database") = "CACHELIB"
set status=##Class(Config.MapPackages).Create("%SYS", "%WebTerminal", .Properties)
if ($$$ISERR(status)) {
do $SYSTEM.Status.DisplayError(status)
set ptr = 0
while $LISTNEXT(mapTo, ptr, value) {
w " ", value
set status = ##Class(Config.MapPackages).Create(value, "WebTerminal", .Properties)
if ($$$ISERR(status)) {
do $SYSTEM.Status.DisplayError(status)
}
}
w !, "%WebTerminal package successfully mapped into %All namespace."
w ".", !, "Mapping complete."
w !, "WebTerminal package successfully mapped into all namespaces."
zn:ns'="%SYS" ns
quit $$$OK
]]></Implementation>
Expand All @@ -1203,6 +1208,17 @@ This method is invoked when a class is 'uncompiled'.</Description>
w !, "WEB application ""/terminal"" was successfully removed."
}
}
w !, "Unmapping %WebTerminal package from all namespaces:"
set mapTo = $LISTBUILD("%All", "SAMPLES", "DOCBOOK")
set ptr = 0
while $LISTNEXT(mapTo, ptr, value) {
w " ", value
set status = ##Class(Config.MapPackages).Delete(value, "WebTerminal")
if ($$$ISERR(status)) {
do $SYSTEM.Status.DisplayError(status)
}
}
w ".", !, "Unmapping complete."
kill ^%WebTerminal.Autocomplete
zn:ns'="%SYS" ns
QUIT $$$OK
Expand All @@ -1211,7 +1227,7 @@ This method is invoked when a class is 'uncompiled'.</Description>
</Class>


<Class name="%WebTerminal.Router">
<Class name="WebTerminal.Router">
<Description>
The REST interface: class that routes HTTP requests</Description>
<Super>%CSP.REST</Super>
Expand Down Expand Up @@ -1311,7 +1327,7 @@ Method writes application HTML.</Description>
<Implementation><![CDATA[
set cookie = %session.CSPSessionCookie
// Put the name of authorized user in a global to authorize WebSocket WebTerminal connection
set ^WebTerminal.AuthUser(cookie) = $LB(
set ^%WebTerminal.AuthUser(cookie) = $LB(
$LISTGET(%session.SecurityContext, 1), // username
$horolog // granting ticket date
)
Expand All @@ -1322,7 +1338,7 @@ Method writes application HTML.</Description>
</Class>


<Class name="%WebTerminal.StaticContent">
<Class name="WebTerminal.StaticContent">
<Description>
This class holds whole application static content like scripts and styles.
Do not edit this file - use external tool to generate it.</Description>
Expand All @@ -1336,7 +1352,7 @@ Write the contents of xData tag</Description>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set Auth = $get(Auth, "")
set obj = ##class(%Dictionary.CompiledXData).%OpenId("%WebTerminal.StaticContent||"_Const)
set obj = ##class(%Dictionary.CompiledXData).%OpenId("WebTerminal.StaticContent||"_Const)
quit:(obj = "") $$$OK
set xdata = obj.Data
set status=##class(%XML.TextReader).ParseStream(xdata, .textreader)
Expand Down Expand Up @@ -1387,10 +1403,10 @@ Write the contents of xData tag</Description>

<Project name="WEBTerminal" LastModified="2015-12-06 12:10:07.906721">
<Items>
<ProjectItem name="%WebTerminal.Engine" type="CLS"></ProjectItem>
<ProjectItem name="%WebTerminal.Installer" type="CLS"></ProjectItem>
<ProjectItem name="%WebTerminal.Router" type="CLS"></ProjectItem>
<ProjectItem name="%WebTerminal.StaticContent" type="CLS"></ProjectItem>
<ProjectItem name="WebTerminal.Engine" type="CLS"></ProjectItem>
<ProjectItem name="WebTerminal.Installer" type="CLS"></ProjectItem>
<ProjectItem name="WebTerminal.Router" type="CLS"></ProjectItem>
<ProjectItem name="WebTerminal.StaticContent" type="CLS"></ProjectItem>
</Items>
</Project>
</Export>
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"title": "Cache WEB Terminal",
"description": "Web-based terminal emulator for Caché administering.",
"author": "ZitRo",
"version": "3.0.1",
"releaseNumber": 12,
"version": "3.1.0",
"releaseNumber": 13,
"repository": {
"type": "git",
"url": "https://github.com/intersystems-ru/webterminal.git"
Expand Down
2 changes: 1 addition & 1 deletion webSource/js/CacheWebTerminalServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var CacheWebTerminalServer = function (CONTROLLER, WS_PROTOCOL, IP, PORT) {
/**
* @type {string}
*/
this.CACHE_CLASS_NAME = "%WebTerminal.Engine.cls";
this.CACHE_CLASS_NAME = "WebTerminal.Engine.cls";

/**
* @type {string}
Expand Down

0 comments on commit fa30992

Please sign in to comment.