June 19, 2000 - WMLScript's Access Control Pragmas | WebReference

June 19, 2000 - WMLScript's Access Control Pragmas

Yehuda Shiran June 19, 2000
WMLScript's Access Control Pragmas
Tips: June 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

WMLScript is a compiled language and uses Compilation Units and Pragmas. A certain application may include separate scripts that were individually and independently compiled. A compilation unit can call functions that are defined in another compilation unit. WMLScript uses the access control pragma to specify the access control of the WMLScript deck. Every compilation unit can have only one access control pragma. The access control pragma specify which URLs can call the external functions in the access-controlled compilation unit. The syntax of access control pragma may be specified in any one of the following forms:

use access domain 
use access domain ;
use access path ;
use access domain  path ;

The referring compilation unit's URL must match the access control specification. A URL consists of a domain name and a path. The referring compilation unit's domain name is matched with the access domain specification, while the compilation unit's path is matched with the access path specification. The domain matching is guided by two principles. First, they are suffix matched, i.e. matching is done from right to left. Secondly, entire sub-domain elements mush match. Given the following access control for a compilation unit:

use access domain "webreference.com" path "/js";

The following URLs would be allowed to call the external function in the access-controlled compilation unit above:

http://webreference.com/js/tips.cgi
https://www.webreference.com/js/categories.wmlsc
http://www.webreference.com/js/tools/newtool.cgi?x=123<y=456

But the following URLs would not be allowed to call the external functions:

http://www.microsoft.com/javascript
http://www.webreference.com/dhtml/mytool.cgi

As you can notice, the access path is prefix-matched, i.e. from left to right. The same principles hold here as well, including that entire sub elements must be matched. The path /js will not match /j/mytools, for example. By default, access control is disabled, so all external functions have public access.

For more on WMLScript, go to WMLScript Primer.