设为首页 收藏本站
查看: 1727|回复: 0

[经验分享] 伪架构师

[复制链接]

尚未签到

发表于 2017-2-19 10:33:33 | 显示全部楼层 |阅读模式
CAS (8) —— Mac下配置CAS到JBoss EAP 6.4(6.x)的Standalone模式(服务端)
  jboss版本: jboss-eap-6.4-CVE-2015-7501
  jdk版本: 1.7.0_79
  cas版本: cas4.1.3
  参考来源:
  JBoss7.1.1版本和CAS3的集成(未完)
  CAS 4.1.1 - JDBC authentication, failed to deploy
  Securing JBoss EAP 6 - Implementing SSL
  JBoss eap 6.4 mutual (two way) ssl configuration
  Tomcat (1) —— Mac下配置Tomcat Https/SSL

准备工作
  配置cas server到jboss eap 6.4需要做以下准备:


  • 一个cas-server-webapp
  • 一个jboss eap服务
  • 配置jboss SSL
cas-server-webapp
  可以参照下面两篇文章,进行准备和配置:


  •   CAS (1) —— Mac下配置CAS到Tomcat(服务端)

  •   CAS 4.x (7) —— Mac下配置CAS集群及JPATicketRegistry(服务端)

jboss eap 6.4
  配置jboss eap比较简单,直接去官网注册后就能下载了。
  下载后也无需编译,如果再Mac或linux下可以直接运行命令启动jboss eap
  Standalone模式:
  

:node6-a Richard$ ./bin/standalone.sh  

  Domain模式:
  

:node6-a Richard$ ./bin/domain.sh  

  新的EAP提供了两种部署方式,官方推荐产品上使用Domain模式,关于Domain模式和Standalone模式有何区别,再次不赘述,weblogic也有类似特性,可以去官网上查找。
  如果能正常启动,最后几行的console输出可能是:
  

09:05:34,206 INFO  [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 69)  
FrameworkServlet 'cas': initialization completed in 820 ms
  
09:05:34,251 INFO  [org.jboss.as.server] (Controller Boot Thread)
  
JBAS015859: 已部署的 "cas.war"(runtime-name: "cas.war")
  
09:05:34,256 INFO  [org.jboss.as] (Controller Boot Thread)
  
JBAS015961: 侦听 http://127.0.0.1:9990/management 的 HTTP 管理接口
  
09:05:34,257 INFO  [org.jboss.as] (Controller Boot Thread)
  
JBAS015951: 管理控制台侦听于 http://127.0.0.1:9990
  
09:05:34,257 INFO  [org.jboss.as] (Controller Boot Thread)
  
JBAS015874: JBoss EAP 6.4.0.GA (AS 7.5.0.Final-redhat-21) started in 9651ms - Started 551 of 588 services (60 services are lazy, passive or on-demand)
  

  默认情况下,本地后台服务管理的入口是http://127.0.0.1:9990/console。
DSC0000.png



*注意以下的测试都是基于Standalone模式


配置jboss SSL
  这个版本的SSL的配置过程与Tomcat有些许差异,主要是因为jboss eap提供了Standalone与Domain两种模式以及对配置文件范式的修改。至于从哪个版本起做的改变,在此不考证。
  SSL密钥和证书生成过程与Tomcat SSL一致,在此不赘述。
  standalone.xml里面有关键配置(Line 295~):
  

<subsystem xmlns=&quot;urn:jboss:domain:web:2.2&quot; default-virtual-server=&quot;default-host&quot; native=&quot;false&quot;>  <connector name=&quot;http&quot; protocol=&quot;HTTP/1.1&quot; scheme=&quot;http&quot; socket-binding=&quot;http&quot;/>
  <connector name=&quot;https&quot; protocol=&quot;HTTP/1.1&quot; scheme=&quot;https&quot; socket-binding=&quot;https&quot; secure=&quot;true&quot;>
  <ssl name=&quot;https&quot; password=&quot;Hoau123&quot; certificate-key-file=&quot;/Users/Richard/Documents/Dev/servers/cluster/keys/hoaukey&quot;/>
  </connector>
  <virtual-server name=&quot;default-host&quot; enable-welcome-root=&quot;true&quot;>
  <alias name=&quot;localhost&quot;/>
  <alias name=&quot;sso.hoau.com&quot;/>
  </virtual-server>
  </subsystem>
  

  为subsystem添加了https connector以及为ssl指定certificate-key-file的路径。

安装cas.war
  通过后台console界面来部署比较方便
  (1)选择“Create Deployment”
DSC0001.png

  (2)选择“Add”
DSC0002.png

  (3)点击“Browse”并选择编译好的war
DSC0003.png


错误
  部署后可能会出现错误:
DSC0004.png

  查看server.log(../servers/cluster/jboss/node6-a/standalone/log)
  

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name  'supportsTrustStoreSslSocketFactoryHttpClient': FactoryBean threw exception on object creation; nested exception is java.lang.NoSuchMethodError:   
  org.apache.http.impl.client.HttpClientBuilder.setSSLHostnameVerifier(Ljavax/net/ssl/HostnameVerifier;)L
  org/apache/http/impl/client/HttpClientBuilder;
  at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
  at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:127)
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1523)
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:314)
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
  at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
  ... 64 more
  

解决办法
  此处怀疑jboss容器自带的库可能和Tomcat(8.x)有所差异,此处报错的“org.apache.http.impl.client.HttpClientBuilder”属于httpclient包下。
  查看文件module.xml (路径“../servers/cluster/jboss/node6-a/modules/system/layers/base/org/apache/httpcomponents/main”),发现jboss这个版本的jar是依赖与redhat自己打包的&quot;httpclient-4.3.6.redhat-1.jar&quot;和“httpcore-4.3.3.redhat-1.jar”。
  暂且不考虑影响和更好的解决方案,一个可行方案是修改这个配置,将这两个jar替换成httpclient的更高版本(此处为4.4.1)
  maven
  

<dependency>  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.4.1</version>
  
</dependency>
  

  module.xml
  

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>  

  
<module xmlns=&quot;urn:jboss:module:1.1&quot; name=&quot;org.apache.httpcomponents&quot;>
  <properties>
  <property name=&quot;jboss.api&quot; value=&quot;private&quot;/>
  </properties>
  

  <resources>
  <!-- redhat original -->
  <!--   <resource-root path=&quot;httpclient-4.3.6.redhat-1.jar&quot;/>
  <resource-root path=&quot;httpcore-4.3.3.redhat-1.jar&quot;/>
  <resource-root path=&quot;httpmime-4.3.6.redhat-1.jar&quot;/> -->
  <!-- redhat original -->
  <!-- Richard Modify -->
  <resource-root path=&quot;httpclient-4.4.1.jar&quot;/>
  <resource-root path=&quot;httpcore-4.4.1.jar&quot;/>
  <resource-root path=&quot;httpmime-4.3.6.redhat-1.jar&quot;/>
  <!-- Richard Modify -->
  <!-- Insert resources here -->
  </resources>
  

  <dependencies>
  <module name=&quot;javax.api&quot;/>
  <module name=&quot;org.apache.commons.codec&quot;/>
  <module name=&quot;org.apache.commons.logging&quot;/>
  <module name=&quot;org.apache.james.mime4j&quot;/>
  </dependencies>
  
</module>
  

测试
  尝试访问
  

https://sso.hoau.com:8453/cas  

DSC0005.png

  并使用我们在数据库里面预埋的数据&quot;casuser/Mellon&quot;登陆

*扩展
  参照数据库用户验证和JpaTicketRegistry的方式,重新发布cas.war。这时可能会遇到另一个错误:
DSC0006.png

  查看server.log
  

10:28:09,762 ERROR [org.springframework.web.context.ContextLoader]  
(ServerService Thread Pool -- 216) Context initialization failed:
  
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring-configuration/ticketRegistry.xml]:
  
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:
  
javax.persistence.Table.indexes()[Ljavax/persistence/Index;
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1572)        
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)   
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
  [spring-beans-4.1.8.RELEASE.jar:4.1.8.RELEASE]
  

  这主要还是因为jboss EAP 6.4这个版本自带jar包的问题。

解决方案
  修改hibernate-jpa-api的jar包版本,路径:
  

/Users/Richard/Documents/Dev/servers/cluster/jboss/node6-a/modules/system/layers/base/javax/persistence/api/main  

  module.xml
  

<module xmlns=&quot;urn:jboss:module:1.1&quot; name=&quot;javax.persistence.api&quot;>  <dependencies>
  <!-- PersistenceUnitInfo needs javax.sql.DataSource -->
  <module name=&quot;javax.api&quot; export=&quot;true&quot;/>
  </dependencies>
  

  <resources>
  <!-- original -->
  <!-- <resource-root path=&quot;hibernate-jpa-2.0-api-1.0.1.Final-redhat-3.jar&quot;/> -->
  <!-- orginal -->
  <!-- Richard modify -->
  <resource-root path=&quot;hibernate-jpa-2.1-api-1.0.0.Final.jar&quot;/>
  <!-- Richard modify -->
  <!-- Insert resources here -->
  </resources>
  
</module>
  

DSC0007.png


结束

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-344144-1-1.html 上篇帖子: 500G JAVA视频网盘分享 (Jeecg社区) 下篇帖子: 一步一步理解 Java 企业级应用的可扩展性
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表