Skip to content

Commit 0969442

Browse files
【fix】修复openlayers无法对接设置了安全认证的iPortal/iServer发布的矢量瓦片服务;删除serverType review by songym
1 parent e71532a commit 0969442

File tree

174 files changed

+751
-1396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+751
-1396
lines changed

src/classic/services/AddressMatchService.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export class AddressMatchService extends CommonServiceBase {
3535
proxy: me.proxy,
3636
withCredentials: me.withCredentials,
3737
crossOrigin: me.crossOrigin,
38-
serverType: me.serverType,
3938
eventListeners: {
4039
scope: me,
4140
processCompleted: callback,
@@ -58,7 +57,6 @@ export class AddressMatchService extends CommonServiceBase {
5857
proxy: me.proxy,
5958
withCredentials: me.withCredentials,
6059
crossOrigin: me.crossOrigin,
61-
serverType: me.serverType,
6260
eventListeners: {
6361
scope: me,
6462
processCompleted: callback,

src/classic/services/DatasetService.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export class DatasetService extends CommonServiceBase {
4545
withCredentials: me.withCredentials,
4646
crossOrigin: me.crossOrigin,
4747
headers: me.headers,
48-
serverType: me.serverType,
4948
eventListeners: {
5049
scope: me,
5150
processCompleted: callback,
@@ -76,7 +75,6 @@ export class DatasetService extends CommonServiceBase {
7675
withCredentials: me.withCredentials,
7776
crossOrigin: me.crossOrigin,
7877
headers: me.headers,
79-
serverType: me.serverType,
8078
eventListeners: {
8179
scope: me,
8280
processCompleted: callback,
@@ -122,7 +120,6 @@ export class DatasetService extends CommonServiceBase {
122120
withCredentials: me.withCredentials,
123121
crossOrigin: me.crossOrigin,
124122
headers: me.headers,
125-
serverType: me.serverType,
126123
eventListeners: {
127124
processCompleted: callback,
128125
processFailed: callback
@@ -150,7 +147,6 @@ export class DatasetService extends CommonServiceBase {
150147
withCredentials: me.withCredentials,
151148
crossOrigin: me.crossOrigin,
152149
headers: me.headers,
153-
serverType: me.serverType,
154150
eventListeners: {
155151
processCompleted: callback,
156152
processFailed: callback

src/classic/services/DatasourceService.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export class DatasourceService extends CommonServiceBase {
4040
withCredentials: me.withCredentials,
4141
crossOrigin: me.crossOrigin,
4242
headers: me.headers,
43-
serverType: me.serverType,
4443
eventListeners: {
4544
scope: me,
4645
processCompleted: callback,
@@ -70,7 +69,6 @@ export class DatasourceService extends CommonServiceBase {
7069
withCredentials: me.withCredentials,
7170
crossOrigin: me.crossOrigin,
7271
headers: me.headers,
73-
serverType: me.serverType,
7472
eventListeners: {
7573
scope: me,
7674
processCompleted: callback,
@@ -106,7 +104,6 @@ export class DatasourceService extends CommonServiceBase {
106104
withCredentials: me.withCredentials,
107105
crossOrigin: me.crossOrigin,
108106
headers: me.headers,
109-
serverType: me.serverType,
110107
eventListeners: {
111108
processCompleted: callback,
112109
processFailed: callback

src/classic/services/ProcessingService.js

Lines changed: 58 additions & 78 deletions
Large diffs are not rendered by default.

src/common/iPortal/iPortalServiceBase.js

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
* This program are made available under the terms of the Apache License, Version 2.0
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
44
import { SuperMap } from '../SuperMap';
5-
import { ServerType } from '../REST';
65
import { SecurityManager } from '../security/SecurityManager';
7-
import { Credential } from '../commontypes/Credential';
86
import { FetchRequest } from '../util/FetchRequest';
97

108
/**
@@ -22,7 +20,6 @@ export class IPortalServiceBase {
2220
constructor(url, options) {
2321
options = options || {};
2422
this.serviceUrl = url;
25-
this.serverType = ServerType.iPortal;
2623
this.CLASS_NAME = "SuperMap.iPortalServiceBase";
2724
this.withCredentials = options.withCredentials || false;
2825
this.crossOrigin = options.crossOrigin
@@ -40,67 +37,12 @@ export class IPortalServiceBase {
4037
*/
4138

4239
request(method, url, param, requestOptions = {headers: this.headers, crossOrigin: this.crossOrigin, withCredentials: this.withCredentials }) {
43-
url = this.createCredentialUrl(url);
40+
url = SecurityManager.appendCredential(url);
4441
return FetchRequest.commit(method, url, param, requestOptions).then(function (response) {
4542
return response.json();
4643
});
4744
}
48-
49-
50-
/**
51-
* @function SuperMap.iPortalServiceBase.prototype.createCredentialUrl
52-
* @description 追加授权信息。
53-
* @param {string} url - 创建证书 URL 地址。
54-
* @returns {string} 携带 token 或 key 的新地址。
55-
*/
56-
57-
createCredentialUrl(url) {
58-
var newUrl = url,
59-
credential = this.getCredential();
60-
61-
if (credential) {
62-
var endStr = newUrl.substring(newUrl.length - 1, newUrl.length);
63-
64-
if (newUrl.indexOf("?") > -1 && endStr === "?") {
65-
newUrl += credential.getUrlParameters();
66-
} else if (newUrl.indexOf("?") > -1 && endStr !== "?") {
67-
newUrl += "&" + credential.getUrlParameters();
68-
} else {
69-
newUrl += "?" + credential.getUrlParameters();
70-
}
71-
}
72-
return newUrl;
73-
}
74-
75-
76-
/**
77-
* @function SuperMap.iPortalServiceBase.prototype.getCredential
78-
* @description 获取 token。
79-
* @returns {string} 返回获取的 token。
80-
*
81-
*/
82-
83-
getCredential() {
84-
var credential,
85-
value = SecurityManager.getToken(this.serviceUrl);
86-
credential = value ? new Credential(value, "token") : null;
87-
if (!credential) {
88-
value = this.getKey();
89-
credential = value ? new Credential(value, "key") : null;
90-
}
91-
return credential;
92-
}
93-
94-
95-
/**
96-
* @function SuperMap.iPortalServiceBase.prototype.getKey
97-
* @description 其子类需要重写该方法,修改其中获取 key 的字段,存储 key 可能是服务 ID 字段,可能是 URL。
98-
*/
99-
getKey() {
100-
//return SuperMap.SecurityManager.getKey(this.id);
101-
//或
102-
//return SuperMap.SecurityManager.getKey(this.serviceUrl);
103-
}
45+
10446

10547
}
10648

src/common/iServer/ChartFeatureInfoSpecsService.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {CommonServiceBase} from './CommonServiceBase';
1818
* 发送请求格式类似于:"http://localhost:8090/iserver/services/map-ChartW/rest/maps/海图/chartFeatureInfoSpecs.json"。
1919
* @param {Object} options - 参数。
2020
* @param {Object} options.eventListeners - 事件监听器对象。有processCompleted属性可传入处理完成后的回调函数。processFailed属性传入处理失败后的回调函数。
21-
* @param {SuperMap.ServerType} [options.serverType=SuperMap.ServerType.ISERVER] - 服务器类型,ISERVER|IPORTAL|ONLINE。
2221
* @param {SuperMap.DataFormat} [options.format] - 查询结果返回格式,目前支持 iServerJSON 和 GeoJSON 两种格式,参数格式为"ISERVER","GEOJSON"。
2322
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
2423
* @param {Object} [options.headers] - 请求头。

src/common/iServer/ChartQueryService.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {GeoJSON} from '../format/GeoJSON';
2020
* @param {string} url - 地图查询服务访问地址。如:"http://localhost:8090/iserver/services/map-ChartW/rest/maps/海图"。
2121
* @param {Object} options - 参数。
2222
* @param {Object} options.eventListeners - 事件监听器对象。有processCompleted属性可传入处理完成后的回调函数。processFailed属性传入处理失败后的回调函数。
23-
* @param {SuperMap.ServerType} [options.serverType=SuperMap.ServerType.ISERVER] - 服务器类型,ISERVER|IPORTAL|ONLINE。
2423
* @param {SuperMap.DataFormat} [options.format] - 查询结果返回格式,目前支持 iServerJSON 和 GeoJSON 两种格式。参数格式为"ISERVER","GEOJSON"。
2524
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
2625
* @param {Object} [options.headers] - 请求头。

0 commit comments

Comments
 (0)