My Keys |
SuperMap iPortal provides a kind of key, for short: Key, it is the application Key used in the online development, is the service's password identification, is a kind of mechanism to protect the safety of the user's registration and hosting service in the iPortal. Key is used after SuperMap iPortal starting the service agent, after iPortal starting the service proxy, for the service protected in the portal, users can only invoke the service by carrying the Key which is authorized to the service. The Key is composed of 24 bits of random letters + numbers.
The ordinary users and administrators in iPortal can add keys. After the iPortal enabling the service agent, at the portal home page, clicking on the "login" button, after the success of the login, in turn, clicking the "individual center" - > "my Key", selecting "add Key" (Adding the key for the first time, the page shows the "obtain key", clicking it), entering the page of adding Key, inputting the related parameters and selecting the the service the Key allows access to, clicking on the "ok" button to add a Key:
After clicking on the "ok" button, users can add a Key on my Key page, Key "application Key" column shows the Key parameters, and it is also the Key users use. A user can add multiple Keys, a service can also correspond to(or bind) multiple Keys.
The generated Key, is mainly used for online application development process, when accessing to the protected service, users do not need to provide user name and password, users only add the Key after the service address. For example: Service accessing address is following:
http://192.168.120.40:8195/iserver/services/map-HunanPopulationDensity/rest.rjson?key=v6ywlc7MJiAY6CQ0Ej4RXWD0
Among them, the part in front of the ? is the service address needs to be invoked, the followed by parts (key =...) is a key request parameter access needs, it can be accessed by sending requests by the url.
SuperMap iClient JavaScript encapsulates the use of the Key in js class library, users do not need to add "?Key =..." behind the access request of each service.and users can use the SuperMap. SecurityManager class for security verification.
Taking SuperMap iClient JavaScript as an example, realizing using the protected map services in iPortal in a web page
Step 1 : Download and unzip library file
Get the source code of SuperMap iClient for Javascript from any of the following open source community:
Step 2: Creating the HTML displayed page
Creating a new folder anywhere in local disk and customizing this folder. This sample is named "MyFirst"; In "MyFirst" folder, creating a new "demo.html" html page with text editing tools(such as notepad + +), pay attention to saving the html page as a UTF-8 format, and adding the following code:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> access the map with the key </title> <link rel="stylesheet" href="libs/leaflet/leaflet.css"> <script type="text/javascript" src="libs/leaflet/leaflet.js"></script> <script type="text/javascript" src="dist/iclient9-leaflet.min.js"></script> <style> .panel { margin-bottom: 0; } </style> </head> <body style=" margin: 0;overflow: auto;background: #fff;width: 100%;height:100%;position: absolute;top: 0;"> <!-- Please make sure that the id name is same --> <div id="iportal_map" style="margin:0 auto;width: 100%;height: 100%"></div> <script> // Specifying the key and service address var key = "2T6ftyeUO9Ak8oC8IuWSMKAd"; var mapUrl = "http://192.168.120.158:8195/iserver/services/map_world/rest/maps/world map Day"; //Calling associated permissions interface SuperMap.SecurityManager.registerKey(mapUrl, key); //Setting map parameters var map = L.map('iportal_map', { crs: L.CRS.EPSG4326, center: [0, 0], maxZoom: 18, zoom: 2 }); //Loading map L.supermap.tiledMapLayer(mapUrl, { serverType: SuperMap.ServerType.IPORTAL }).addTo(map); </script> </body> </html>
Of which:
Step 3: Referencing resource file
Copying the libs and theme folder obtained in the first step to "MyFirst" folder, users can also put it in other location, then users need to modify relative path of referenced script in the codes of the second step.
Step 4: Viewing by using the browser
Copy the "MyFirst" folder to %SuperMap iPortal_HOME%/webapps directory, start SuperMap iPortal, enter in the browser address bar: http://192.168.120.135:8090/MyFirst/demo.html, browsing the map data.
You can manage the Key added by yourself, in iPortal portal home page, click on the "login" button, after the success of the login, in turn, click the "individual center" - > "my Key, " it will display the list of all Keys the current users added in the development authorization page.