1.
http://192.168.1.220:6080/arcgis/admin/login?redirect=

Request URL: http://192.168.1.220:6080/arcgis/admin/login?redirect=
Request Method: POST
Status Code: 302 Found
Remote Address: 192.168.1.220:6080
Referrer Policy: no-referrer-when-downgrade

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: max-age=0
Connection: keep-alive
Content-Length: 290
Content-Type: application/x-www-form-urlencoded
Host: 192.168.1.220:6080
Origin: http://192.168.1.220:6080
Referer: http://192.168.1.220:6080/arcgis/admin/login
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36

password: 7a138ea2a5a0612e2f4418bc80dc0b7188f26d86abbeebd24b9448f5fcd4fa6f28644f150317f493decb8d8c14b121be40fc6dbbd072cd72b15302bd4349fc91
username: 6393efc202b63592a688d9dc3722676f5b08d39bf844e30f94351ae527592e076f78424f28f85ffbaef89c2f4bb5d34b4a591cebf9ffbaca5bd9753e5cb4a36a
encrypted: true

----------------------------------

Content-Length: 0
Date: Sat, 08 Dec 2018 08:03:55 GMT
Location: http://192.168.1.220:6080/arcgis/admin/
Server:
Set-Cookie: AGS_ADMIN_TOKEN="AZ7rFFN477VEpmJFE-p6oy5zDie7gT7ra-HgydqVf3LnSFuPqhBC15cfE6aYx7Hp,AZ7rFFN477VEpmJFE-p6o9m-1pBqmpRtHWAl5-x4GO32g-SaSt78UH1ZktLfjOQHPZdJ1WhX2Jor0YLhQuCvSB8BAKiq9csAZEimJZ9J47A."; Version=1; HttpOnly
Set-Cookie: AGS_PRIVILEGE_TOKEN=jV6AxlQ-vteRvEcY7CKHsJlUjjr3owLQ-kAb6ySF0rJ5O3zTeHkQxyyv37PMnaPtvCfgfd-WoaZvfr4ilnZPrg..; HttpOnly
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

2.
http://192.168.1.220:6080/arcgis/admin/

Request URL: http://192.168.1.220:6080/arcgis/admin/
Request Method: GET
Status Code: 200 OK
Remote Address: 192.168.1.220:6080
Referrer Policy: no-referrer-when-downgrade

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: max-age=0
Connection: keep-alive
Cookie: AGS_ADMIN_TOKEN="AZ7rFFN477VEpmJFE-p6oy5zDie7gT7ra-HgydqVf3LnSFuPqhBC15cfE6aYx7Hp,AZ7rFFN477VEpmJFE-p6o9m-1pBqmpRtHWAl5-x4GO32g-SaSt78UH1ZktLfjOQHPZdJ1WhX2Jor0YLhQuCvSB8BAKiq9csAZEimJZ9J47A."; AGS_PRIVILEGE_TOKEN=jV6AxlQ-vteRvEcY7CKHsJlUjjr3owLQ-kAb6ySF0rJ5O3zTeHkQxyyv37PMnaPtvCfgfd-WoaZvfr4ilnZPrg..
Host: 192.168.1.220:6080
Referer: http://192.168.1.220:6080/arcgis/admin/login
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36

----------------------------------

Content-Length: 4246
Content-Type: text/html;charset=utf-8
Date: Sat, 08 Dec 2018 08:03:55 GMT
Server:
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

3.
http://192.168.1.220:6080/arcgis/admin/machines

Request URL: http://192.168.1.220:6080/arcgis/admin/machines
Request Method: GET
Status Code: 200 OK
Remote Address: 192.168.1.220:6080
Referrer Policy: no-referrer-when-downgrade

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: keep-alive
Cookie: AGS_ADMIN_TOKEN="AZ7rFFN477VEpmJFE-p6o1ZRCoo5aZoVNEGRr9HMX1IS7eFUMLoa-LpZKnqH2hEh,AZ7rFFN477VEpmJFE-p6o5VBUs_C5VWdtXxT865HRc_Nmkq7gSm82hl7SI3zs0JF3cWGgFyWN2Z9XYeT-QvjABYKP3fk42Q8mWQ2CIqh-T4."; AGS_PRIVILEGE_TOKEN=bGan0Kz6aO88LXMZsAEkfOow92lIXG3-Hur-7bYa5FZAjeOv_Kn6V2WqIgQxv10-4K0LwDACPDNx8ojUFnF75w..
Host: 192.168.1.220:6080
Referer: http://192.168.1.220:6080/arcgis/admin/
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36

-----------------------------------

Content-Length: 2566
Content-Type: text/html;charset=utf-8
Date: Sat, 08 Dec 2018 09:25:32 GMT
Server:
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block

4.获取认证

public List<String> getNewAdminToken(ServerCredentialsInfo serverCredentialsInfo, String url) throws IOException {        String token = "";List<String> cookieTokenList = new LinkedList<String>();HttpPost httpPost = null;try {HttpClient httpClient = HttpClients.createDefault();   //HttpClientBuilder.create().   // new DefaultHttpClient();      String tokenServiceUri = serverCredentialsInfo.getTokenServiceUri();httpPost = new HttpPost(tokenServiceUri);// 构造消息头       //httpPost.setHeader("Referer", "*");httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");////
            List<NameValuePair> param = new ArrayList<NameValuePair>();param.add(new BasicNameValuePair("username",serverCredentialsInfo.getUsername()));param.add(new BasicNameValuePair("password",serverCredentialsInfo.getPassword()));param.add(new BasicNameValuePair("encrypted","false"));param.add(new BasicNameValuePair("f","json"));            UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(param, "UTF-8");httpPost.setEntity(postEntity);            //
            HttpResponse response = httpClient.execute(httpPost);// 检验返回码int statusCode = response.getStatusLine().getStatusCode();if(statusCode != HttpStatus.SC_OK){System.out.println("请求出错: "+statusCode);                }else{System.out.println("---------------------------------------------------------------");for(Header header : response.getAllHeaders()){System.out.println("Key : " + header.getName() + " ,Value : " + header.getValue());if(header.getName().equals("Set-Cookie")){String cookieValue = header.getValue();cookieTokenList.add(cookieValue.split(";")[0]);}}System.out.println("---------------------------------------------------------------");String content = EntityUtils.toString(response.getEntity());System.out.println(content);                }} catch (Exception e) {e.printStackTrace();}finally{if(httpPost != null){try {httpPost.releaseConnection();Thread.sleep(500);} catch (InterruptedException e) {e.printStackTrace();}}}return cookieTokenList;}

5.获取服务器信息

public static String httpRequest(String url, Map<String, String> headerMap, Map<String, String> cookieMap,Map<String, String> parameterMap) throws IOException {String content = null;/** HttpPost httpPost = null; try { HttpClient httpClient =* HttpClients.createDefault(); httpPost = new HttpPost(url); // 构造消息头* //httpPost.setHeader("Referer", "*"); List<Header> headerList =* getHeader(headerMap); headerList.add(new BasicHeader("Content-Type",* "application/x-www-form-urlencoded")); Header[]* headers=headerList.toArray(new Header[headerList.size()]);* httpPost.setHeaders(headers); // // List<NameValuePair> param =* getParam(parameterMap); param.add(new BasicNameValuePair("f","json"));* UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(param, "UTF-8");* httpPost.setEntity(postEntity); // HttpResponse response =* httpClient.execute(httpPost);* * // 检验返回码 int statusCode = response.getStatusLine().getStatusCode();* if(statusCode != HttpStatus.SC_OK){ System.out.println("请求出错: "+statusCode);* }else{ System.out.println(* "---------------------------------------------------------------");* for(Header header : response.getAllHeaders()){ System.out.println("Key : " +* header.getName() + " ,Value : " + header.getValue()); } System.out.println(* "---------------------------------------------------------------"); content =* EntityUtils.toString(response.getEntity()); System.out.println(content); } }* catch (Exception e) { e.printStackTrace(); }finally{ if(httpPost != null){* try { httpPost.releaseConnection(); Thread.sleep(500); } catch* (InterruptedException e) { e.printStackTrace(); } } }*/URL urlObj = new URL(url);HttpURLConnection httpURLConnection = (HttpURLConnection) urlObj.openConnection();try {if (httpURLConnection instanceof HttpsURLConnection) {HttpsURLConnection httpsURLConnection = (HttpsURLConnection) httpURLConnection;SSLContext sc = SSLContext.getInstance("SSL");sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());httpsURLConnection.setSSLSocketFactory(sc.getSocketFactory());httpsURLConnection.setHostnameVerifier(new TrustAnyHostnameVerifier());}} catch (NoSuchAlgorithmException | KeyManagementException e) {e.printStackTrace();}httpURLConnection.setConnectTimeout(5000);httpURLConnection.setReadTimeout(10000);httpURLConnection.setRequestMethod("POST");//
        Iterator<Entry<String, String>> it = headerMap.entrySet().iterator();while (it.hasNext()) {Entry<String, String> parmEntry = it.next();httpURLConnection.setRequestProperty(parmEntry.getKey(), parmEntry.getValue());}//
        String formData = "f=json";it = parameterMap.entrySet().iterator();while (it.hasNext()) {Entry<String, String> parmEntry = it.next();formData += "&" + parmEntry.getKey() + "=" + URLEncoder.encode(parmEntry.getValue(), "UTF-8");}byte[] bytes = formData.getBytes("UTF-8");// if it is a POST request
httpURLConnection.setRequestMethod("POST");httpURLConnection.setDoOutput(true);OutputStream outputStream = httpURLConnection.getOutputStream();outputStream.write(bytes);//
InputStream inputStream = httpURLConnection.getInputStream();Reader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));StringBuilder contentStringBuilder = new StringBuilder();char[] buffer = new char[5000];int n;while ((n = reader.read(buffer)) != -1) {contentStringBuilder.append(buffer, 0, n);}reader.close();content = contentStringBuilder.toString();return content;}

6.前端接口

@PostMapping(path = "/generateAdminToken")// @ResponseBodypublic ResultInfo generateAdminToken(@RequestParam String id) {ResultInfo resultInfo = new ResultInfo();try {                        GisServer gisServer = gisServerService.getById(id);TokenUtil tokenUtil = new TokenUtil();ServerCredentialsInfo serverCredentialsInfo = new ServerCredentialsInfo(gisServer.getUrl());serverCredentialsInfo.setUsername(gisServer.getUsername());serverCredentialsInfo.setPassword(gisServer.getPassword());serverCredentialsInfo.setTokenServiceUri(gisServer.getUrl()+"/admin/login");List<String> token = tokenUtil.getNewAdminToken(serverCredentialsInfo, gisServer.getUrl()+"/admin/login");            resultInfo.setStatus(token == null ? "fail" : "success");resultInfo.setData(token);
//            if (result) {
//
//            }} catch (Exception e) {e.printStackTrace();resultInfo.setStatus("fail");resultInfo.setInfo(ExceptionUtil.getStackMsg(e));}return resultInfo;}@PostMapping(path = "/machines")// @ResponseBodypublic ResultInfo getMachines(@RequestParam String id) {ResultInfo resultInfo = new ResultInfo();try {                        GisServer gisServer = gisServerService.getById(id);TokenUtil tokenUtil = new TokenUtil();ServerCredentialsInfo serverCredentialsInfo = new ServerCredentialsInfo(gisServer.getUrl());serverCredentialsInfo.setUsername(gisServer.getUsername());serverCredentialsInfo.setPassword(gisServer.getPassword());serverCredentialsInfo.setTokenServiceUri(gisServer.getUrl()+"/admin/login");List<String> tokens = tokenUtil.getNewAdminToken(serverCredentialsInfo, gisServer.getUrl()+"/admin/login");    //
            Map<String, String> headerMap = new HashMap<String, String>();headerMap.put("Cookie", StringUtils.join(tokens, ";"));
//            for(String token : tokens) {
//
//            }Map<String, String> cookieMap = new HashMap<String, String>();Map<String, String> parameterMap = new HashMap<String, String>();headerMap.put("f", "json");String content = ProxyUtil.httpRequest(gisServer.getUrl()+"/admin/machines", headerMap,  cookieMap, parameterMap);    resultInfo.setStatus(content == null ? "fail" : "success");resultInfo.setData(content);
//            if (result) {
//
//            }} catch (Exception e) {e.printStackTrace();resultInfo.setStatus("fail");resultInfo.setInfo(ExceptionUtil.getStackMsg(e));}return resultInfo;}

转载于:https://www.cnblogs.com/gispathfinder/p/10087259.html

ArcGIS Server Rest 认证过程分析相关推荐

  1. ArcGIS Server 部署与配置

    一.ArcGIS Server安装概述 ArcGIS Server安装过程包括两个部分:安装(installation)和安装后(post installation)设置.为了完成ArcGIS Ser ...

  2. 【转】ArcGIS.Server.9.2.DotNet的ADF的Toolbar工作过程分析

    目的: 1.ArcGIS.Server.9.2.DotNet的ADF的Toolbar工作过程原理. 开始: Toolbar工作过程: 一.初始化过程(在页面生成的时候Toolbar控件会生成和它相关的 ...

  3. arcgis server认证失败

    提示 Failed to create the site. The machine does not have a valid license. Please authorize ArcGIS Ser ...

  4. arcgis server mysql_ArcGIS Server 10.1发布要素服务时遇到的数据库注册问题总结 (二)...

    在上一篇文章中: 说到应用该博文方法. 最后发布失败.今天有琢磨了半天,终于成功了. 解决方法: 1.删除ArcGIS Server Account账户,重新Postinstall. 2.删除SQL ...

  5. 教你发布Silverlight Bussiness Application(SQL Server 登录,局域网访问,以及使用ArcGIS Server服务需要注意的问题)...

    教你发布Silverlight Bussiness Application(SQL Server 登录,局域网访问,以及使用ArcGIS Server服务需要注意的问题) 原文:教你发布Silverl ...

  6. ArcGIS Server 9.3 安装步骤及相关注意事项

    ArcGIS Server 9.3 安装步骤及相关注意事项 2010年08月02日 Made By QCPassed 题目:ArcGIS Server 9.3(.net)安装步骤及相关注意事项 平台: ...

  7. 【转】 IEEE 802.1X-PEAP认证过程分析(抓包)

    转自:https://blog.csdn.net/u012503786/article/details/79296522 IEEE 802.1X-PEAP认证过程分析(抓包)  本文介绍IEEE802 ...

  8. IEEE 802.1X-PEAP认证过程分析(抓包)

    IEEE 802.1X-PEAP认证过程分析(抓包) 本文介绍IEEE802.1X认证的PEAP认证方式,是带有radius服务器的EAP中继认证. IEEE802.1X认证是使用EAP报文格式在申请 ...

  9. ArcGIS Server集群部署基于Windows系统

    ArcGIS Server集群部署 1 几个重要的概念 1.1 服务.池化.实例 使用ArcGIS Server发布一个地图服务,发布服务的同时会要求定义池化的类型.最小最大实例数.用户请求一个ser ...

最新文章

  1. python大作业外星人入侵_【python3小白上路系列】外星人入侵——开始
  2. JQuery控制只能输入带二位小数的数字
  3. 关于专注,关于最近的一些事情
  4. c语言的简单程序设计实验报告,工程学院C语言程序设计实验报告
  5. echart的x轴换行
  6. 优品景象 进销存系统推荐_初步了解WMS(仓库管理系统)
  7. excel去重_提高数据处理效率的10个excel小技巧
  8. destoon短信接口更换成和其他运营商通道并存
  9. 前端实战——实现购物车功能
  10. Fiddler对安卓模拟器里的APP抓包(步骤详细,各种抓包工具总结)
  11. 软件测试方法(单元测试、集成测试、系统测试、确认测试)
  12. 一台服务器​最大并发 tcp 连接数多少?65535?
  13. android 更新相册,Android 图片存入系统相册更新显示实例详解
  14. P1903 数颜色 (带修莫队)
  15. 图片内容巴特勒 (隐藏文字到图片)
  16. ant弹窗_【React】急:请问ant modal(弹出框)怎么修改样式?
  17. 数仓建模—实时数仓架构发展史
  18. 360修复IE时候的注册表动作记录
  19. 我的世界服务器怎么使用无限附魔bug,我的世界惊现全新无限刷物品bug 服主大大都要注意了...
  20. 轨迹时空数据存储对比分析

热门文章

  1. 企业WAP建站的10个理由
  2. android adb:电池与电量
  3. 初设大蟒蛇之Python函数篇
  4. 坐在电脑前是高一点好还是低一点好
  5. 央妈是怎么印钱的(1)--资产负债表
  6. 递归解决汉罗塔问题到底多么简单
  7. [zz][ZOJ Monthly]October 2008解题报告
  8. net开发过程中,错误集锦
  9. UE5黑客帝国3d print假室内的一些使用记录
  10. C语言打印倒三角形代码