加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 如何在Intoserver上以编程方式在Geoserver上设置用户名

发布时间:2020-12-16 01:57:38 所属栏目:安全 来源:网络整理
导读:我正在编写一个bash脚本来按照此处列出的步骤 Install Instructions安装Geoserver.我正在尝试使用CURL发布自定义数据存储配置文件.但我有一个身份验证错误. * upload completely sent off: 42out of 42 bytes HTTP/1.1 401 Unauthorized Server: Apache-Coyo
我正在编写一个bash脚本来按照此处列出的步骤 Install Instructions安装Geoserver.我正在尝试使用CURL发布自定义数据存储配置文件.但我有一个身份验证错误.

* upload completely sent off: 42out of 42 bytes
    < HTTP/1.1 401 Unauthorized
    < Server: Apache-Coyote/1.1
    < Set-Cookie: SPRING_SECURITY_REMEMBER_ME_COOKIE=""; Expires=Thu,01-Jan-1970 00:00:10 GMT; Path=/geoserver
    * Authentication problem. Ignoring this.
    < WWW-Authenticate: Basic realm="GeoServer Realm"
    < Content-Type: text/html;charset=utf-8
    < Content-Length: 1299
    < Date: Thu,31 Jan 2013 05:16:17 GMT

我相信它是因为我没有为Geoserver设置用户名和密码.我似乎找到的唯一方法是通过Web管理界面来完成.我想通过我的bash脚本设置它.

有没有办法实现这个目标?

Bash脚本部分在这里

echo 'Downdloading geoserver'
    wget http://downloads.sourceforge.net/project/geoserver/GeoServer/2.2.4/geoserver-2.2.4-war.zip

    unzip geoserver-2.2.4-war.zip
    sudo cp geoserver.war /var/lib/tomcat7/webapps/

    sleep 120

    echo 'setting up geoserver'

    curl -u $U_NAME:$PASSWORD -v -XPOST -H 'Content-type: text/xml' 
       -d '<workspace><name>catami</name></workspace>' 
       http://localhost:8080/geoserver/rest/workspaces ;

    curl -u $U_NAME:$PASSWORD -XPOST -T datastore-config.xml -H 'Content-type: text/xml' 
      http://localhost:8080/geoserver/rest/workspaces/catami/datastores ;

    curl -u $U_NAME:$PASSWORD -XPOST -H 'Content-type: text/xml' 
      -d '<featureType><name>Force_image</name></featureType>' 
      http://localhost:8080/geoserver/rest/workspaces/catami/datastores/CatamiImagePoints/featuretypes ;

    curl -u $U_NAME:$PASSWORD -XPOST -H 'Content-type: application/vnd.ogc.sld+xml' 
      -d @catami-colour-by-depth.sld http://localhost:8080/geoserver/rest/styles ;

    curl -u $U_NAME:$PASSWORD -XPUT -H 'Content-type: text/xml' 
      -d '<layer><defaultStyle><name>catami-colour-by-depth</name></defaultStyle><enabled>true</enabled></layer>' 
      http://localhost:8080/geoserver/rest/layers/catami:Force_image

解决方法

显然,您可以编辑GeoServer数据目录中的用户名和密码.你可以阅读更多关于它 here.

在您找到要更改内容的文件之后,您只需根据自己的喜好调整数据.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读