<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Java 人生

    java (Java EE)&Linux

    BlogJava 首頁(yè) 新隨筆 聯(lián)系 聚合 管理
      15 Posts :: 2 Stories :: 5 Comments :: 0 Trackbacks

    JBOSS 配置

    1.??? 下載,在解壓縮

    2.??? 在“環(huán)境變量”的地方,新增一個(gè)變量名為“ JBOSS_HOME” ,值為

    ?? 解壓縮的路徑 tomcat 設(shè)置一樣

    3.??? 數(shù)據(jù)源配置

    首先在 JBOSS_HOME\docs\examples\jca 目錄下找到相對(duì)應(yīng)的配置文件如:

    MySQL- à mysql-ds.xml,oracle- à oracle-ds.xml;access- à msaccess-ds.xml

    我們介紹 ACCESS 的數(shù)據(jù)庫(kù)配置

    <?xml version="1.0" encoding="UTF-8"?>

    <datasources>

    ?

    ? <local-tx-datasource>

    ??? <jndi-name>MSAccessDS</jndi-name>

    ??? <!-- format of URL is "jdbc:odbc:DSNNAME" -->

    ??? <connection-url>jdbc:odbc:ejb</connection-url>

    ??? <driver-class>sun.jdbc.odbc.JdbcOdbcDriver</driver-class>

    ??? <user-name>Admin</user-name>

    ??? <password>123</password>

    ?

    ? </local-tx-datasource>

    ?

    </datasources>

    ?

    修改好後另存為 jboss-home\server\default\deploy 目錄下 就可以了

    ?

    4. 安全配置

    配置文件位於 …jboss install directory /server/ default/ conf / login-config.xml <policy></ policy> 之中加入 application-policy

    <application-policy Name=”dblogin”>

    ??? <authentication>

    ?????? <login-nodule code=”org.jobss.security.auth.spi.DatabaseServerLogin Module” flag=”Required”>

    ???????????? <module –option Name=”dsJndiName”>jave=/MSSQLXADS

    ???????????? </module –option>

    ???????????? <module –option Name=”principalsQuery”>select

    ? ????????????? password form users where user_id=?

    ????????????? </module –option>

    ????????????? <module –option Name=”RolesQuery”>select Role,

    ????????????? Role-group from Roles where user_id=?

    ?????????????? </ login-module>

    ????????? <authentication>

    ? ?????</ application-policy>

    1.????? jobss web 應(yīng)用中使 3 中配置的安全域 dbLogin

    web 應(yīng)用中的 jobss-web.xml <jobss-web> </ jobss-web> 之間加入如下標(biāo)志

    security-domain java:/jaas/dblogin</secureity-domain>

    2.????? 定義 signon 頁(yè)面與 error 頁(yè)面, signon 頁(yè)面中的以下三個(gè)元素是受限制的。

    ? <form name=”form1” method=”post” action=”j_security_check”>

    <input name=”j_username” type=”text” size=”30”>

    <input name=”j_password” type=”password” size=”30”>

    ?

    3.????? web 應(yīng)用中的 web.xml 中定義如下與驗(yàn)證方式

    login-lonfig

    ? <auth –method>Form</auth-method>

    ????? <form-login-page>/signon.jsp</form-login-page>

    ?? ???<form-error-page>/error.jsp</form-login-page>

    ??? </login-lonfig>

    4.????? web 中應(yīng)用的 web.xml 中定義如下角色,注意要與數(shù)據(jù)庫(kù)中角色相對(duì)應(yīng)用。

    security-Role

    ????? <Role-Name>preferred</Role –Name>

    ???? </secureity-Role>

    ???? <secureity-Role>

    ???????? <Role-Name>standard</Role-Name>

    ???? </secureity-Role>

    5.????? web.xml 中定義安全約束

    <stcurity-constraint>

    ?? <display-Name>scl</display-Name>

    ???? < web-resource-collection>

    ? ???????? <web-resource-name>wrc1</ web-resource-name>

    <url-pattern>/private1.jsp></url-pattern>

    <http-method>get</http-method>

    <http-method>post</http-method>

    ???? < web-resource-collection>

    ???? <auth-constraint>

    ????????????????? <role-name>standard</role-name>

    ???????? <role-name>sprefferred</role-name>

    ???? </auth-constraint>

    ?<security-constraint>

    jboss java mail:

    file:// D:\jboss\server\default\deploy\mail-serviece.xml

    <mbean code="org.jboss.mail.MailService"

    ???????? name="jboss:service=Mail">

    ??? <attribute name="JNDIName">java:/Mail</attribute >

    ??? <attribute name="User">jinhua </attribute>

    ??? <attribute name="Password">jinhua</attribute>

    ? ?? <attribute name="Configuration">

    ?????? <!-- Test -->

    ?????? <configuration>

    ????????? <!-- Change to your mail server prototocol -->

    ????????? <property name="mail.store.protocol" value="pop3"/>

    ????????? <property name="mail.transport.protocol" value="smtp"/>

    ?

    ????????? <!-- Change to the user who will receive mail? -->

    ????????? <property name="mail.user" value="nobody"/>

    ?

    ????????? <!-- Change to the mail server? -->

    ????????? <property name="mail.pop3.host" value="222.118.20.111"/>

    ?

    ????????? <!-- Change to the SMTP gateway server -->

    ????????? <property name="mail.smtp.host" value="222.118.20.111"/>

    ?

    ????????? <!-- Change to the address mail will be from? -->

    ????????? <property name="mail.from" value="ejinmy@shingwai.com "/>

    ?

    ????????? <!-- Enable debugging output from the javamail classes -->

    ????????? <property name="mail.debug" value="false"/>

    ?????? </configuration>

    ??? </attribute>

    ? </mbean>

    ?

    </server>

    之後就可以通通如下代碼來使用 javamail service

    Session session =(Session)portableRemoteObject.narrow(new javax.naming.InitialContext.Lookup(“java:/Mail”),Session.Class)

    MimeMessage = mimeMessage = new MimeMessage(session)

    6.????? 建立消息隊(duì)列

    1. 部署一個(gè)點(diǎn)對(duì)點(diǎn)的隊(duì)列

    定義的是 queue 類型隊(duì)列

    D:\jboss\server\default\deploy 中,編寫名稱以 -service.xml 結(jié)尾的文件,可以實(shí)現(xiàn)新的消息隊(duì)列的建立。

    <?xml version="1.0" encoding="UTF-8"?>

    定義對(duì)象的 JNDI 名稱

    ?


    <server>

    ?<mbean code="org.jboss.mq.server.jmx.Queue"

    ??? name="jboss.mq.destination:service=Queue,name=queueexample1">

    ? <depends optional-attribute-name="DestinationManager">

    ? ? jboss.mq:service=DestinationManager

    ? </depends>

    ? </mbean>

    </server>

    1.??? 部署一個(gè)主題隊(duì)列

    ?<?xml version="1.0" encoding="UTF-8"?>

    定義對(duì)象的 JNDI 名稱

    ?


    <server>

    ?<mbean code="org.jboss.mq.server.jmx.Topic"

    ??? name="jboss.mq.destination:service=Topic,name=topicexample1">

    ? <depends optional-attribute-name="DestinationManager">

    ? ? jboss.mq:service=DestinationManager

    ? </depends>

    ? </mbean>

    apache aixs 安裝

    ? 下載 axis-1_1.zip ,將解壓得到的 axis-1_1\webapps\axis 目錄整體復(fù)制到 tomcat 目錄下。啟動(dòng) tomcat ,就可以打開瀏覽器訪問 http://localhost:8080/axis

    如果能正常顯示,表明安裝成功

    1.??? tomcat 配置

    為了能編譯 servlet 文件,要把 D:\Tomcat 5.0\common\lib 目錄下的 servlet.jar 加到 classpath .

    Tomcat 有兩個(gè)重要的配置文件 web.xml,server.xml 如果在遮兩個(gè)文件沒有任何配置,我們的 jsp 文件要放在 D:\Tomcat 5.0\webapps\ROOT 下,才能運(yùn)行,如我們有一個(gè) time.jsp 文件,放在了 D:\Tomcat 5.0\webapps\ROOT

    目錄下,我們 可以在瀏覽器訪問 ,servlet 文件放在 tomcat_home\webapps\ROOT\web-inf\classes 目錄下

    web.xml 文件 中可包含如下配置信息

    servlet 的定義

    servlet 的映射

    安全配置

    welcome 文件清單

    資源引用

    環(huán)境變量的定義

    web.xml 文件清單

    <web-app>

    <display-name>

    <description>

    <filter>

    用來定義 servlet

    <filter-mapping>

    <servlet>

    <servlet-mapping>

    <session-config>

    <welcome-file-list>

    <taglib>

    <resource-ref>

    <security-constraint>

    <login-config>

    <security-role>

    元素定義的先後順序不能顛倒 , 否則不能運(yùn)行服務(wù)器

    file of web.xml

    Servlet 過濾器能夠檢查和修改其中的信息

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

    過濾器的名字,如有多個(gè),不允許重名

    <web-app>

    ? <display-name>longweb</display-name>

    ? <filter>

    ?? <filter-name>SampleFilter</filter-name>

    實(shí)現(xiàn)過濾器的類

    ?? <filter-class>mypack.SampleFilter</filter-class>

    ? </filter>

    過濾器負(fù)責(zé)過濾的 url

    ? <filter-mapping>

    ? <filter-name>SampleFilter</filter-name>

    ? <url-pattern>*.jsp</url-pattern>

    </filter-mapping>

    <servlet>

    ??????? <servlet-name>org.apache.jsp.index_jsp</servlet-name>

    ??????? <servlet-class>org.apache.jsp.index_jsp</servlet-class>

    ??? </servlet>

    ?

    ??? <servlet-mapping>

    ??????? <servlet-name>org.apache.jsp.index_jsp</servlet-name>

    ??????? <url-pattern>/index.jsp</url-pattern>

    Httpsession 的生命周期

    ?? </servlet-mapping>

    如果僅給出 web 應(yīng)用的 root ,會(huì)自動(dòng)調(diào)用這裡聲明的文件

    ? <session-config>

    ??? <session-timeout>30</session-timeout>

    ? </session-config>

    ? <welcome-file-list>

    ?? <welcome-file>index.jsp</welcome-file>

    ?? <welcome-file>index.html</welcome-file>

    如在整個(gè) web 出現(xiàn) http 404 not found 將會(huì)調(diào)用這個(gè)文件運(yùn)行

    ? </welcome-file-list>

    ? <error-page>

    ??? <error-code>404</error-code>

    ??? <location>/notfound.jsp</location>

    設(shè)置 web 所引用的 tag Library 標(biāo)識(shí)符

    ? </error-page>

    <taglib>

    <taglib-uri>/mytaglib</taglib-uri>

    <taglib-location>/WEB-INF/mytaglib.tld</taglib-location>

    Tld 文件的位置

    </taglib>

    <!- - 資源的配置 - ->

    <resource-ref>

    ? <description>DB Connectin</dscription>

    <res-ref-name>sampleDB</res-ref-name><!- -JNDI name - - >

    <res-type>javax.sql.DataSource</res-type>

    <res-auth>Container</res-auth>

    </resource-ref>

    // 安全的配置

    ? <security-constraint>

    ??? <web-resource-collection>

    聲明保護(hù)的資源

    ????? <web-resource-name>Shopping</web-resource-name>

    ????? <url-pattern>/welcome.jsp</url-pattern>

    ????? <url-pattern>jsp1.jsp</url-pattern>

    ????? <url-pattern>*.do </url-pattern>

    ????? <http-method>GET</http-method>

    ????? <http-method>POST</http-method>

    聲明可以訪問保護(hù)資源的角色

    ??? </web-resource-collection>

    ??? <auth-constraint>

    ????? <role-name>standard</role-name>

    驗(yàn)證方法

    ??? </auth-constraint>

    ? </security-constraint>

    聲明表單驗(yàn)證的登陸界面和出錯(cuò)頁(yè)面

    ? <login-config>

    ??? <auth-method>FORM</auth-method>

    ??? <form-login-config>

    ????? <form-login-page>/login.jsp</form-login-page>

    ????? <form-error-page>/login.jsp</form-error-page>

    ??? </form-login-config>

    ? </login-config>

    ? <security-role>

    Web 應(yīng)用引用的角色

    ??? <description>Standard Customer</description>

    ??? <role-name>standard</role-name>

    ? </security-role>

    </web-app>

    ?

    ?

    server.xml 文件

    ?

    <?xml version="1.0" encoding="UTF-8"?>

    <!--This comment marks this file as generated, so it may be deleted and regenerated at any time. To preserve manual changes to this file, delete this comment.-->

    <Server debug="0" port="8084" shutdown="SHUTDOWN">

    ? <Service name="Tomcat-Standalone">

    監(jiān)聽端口

    <Connector

    port="80"?????????????? maxThreads="150" minSpareThreads="25" maxSpareThreads="75"

    ?????????????? enableLookups="false" redirectPort="8443" acceptCount="100"

    ?????????????? debug="0" connectionTimeout="20000"

    ?????????????? disableUploadTimeout="true" />

    ???? <Engine debug="0" defaultHost="localhost" name="Standalone">

    ?<Host appBase="C:\webservice\EmployeeClient\Tomcat\webapps" debug="0" name="localhost" unpackWARs="true">

    // 如果不自己設(shè)置一個(gè) ,哪全部 JSP 文件都要放在 D:\Tomcat 5.0\webapps\ROOT

    // 如果自己設(shè)置一個(gè)目錄,則要在這裡設(shè)置虛主機(jī)

    ?<Context path="/javaconfig" docBase="C:\javaconfig" debug="0" reloadable="true">

    Web 應(yīng)用的文件路徑

    True: 表示服務(wù)器運(yùn)行狀態(tài)下會(huì)監(jiān)視在 web-inf/classes 目錄下 class 改動(dòng)

    ???????????? ? <Resource name="sampleDB" auth="Container" type="javax.sql.DataSource" description="User database that can be updated and saved">

    ??? </Resource>

    ??? <ResourceParams name="sampleDB">

    ????? <parameter>

    ??????? <name>factory</name>

    ??????? <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>

    ? ???? </parameter>

    ?????????????? <parameter>

    ?????????????????? ???? <name>username</name>

    ????????????????????????? ?<value>Admin</value>

    ?????????????? </parameter>

    ?????????????????? ?? <parameter>

    ????????????????????????? ? <name>password</name>

    ????????????????????????? ? <value>123</value>

    ????????????????????????? </parameter>

    ????????????????????????? <parameter>

    ????????????????????????? ? <name>driverClassName</name>

    ????????????????????????? ? <value>sun.jdbc.odbc.JdbcOdbcDriver</value>

    ????????????????????????? </parameter>

    ????????????????????????? <parameter>

    ????????????????????????? ? <name>url</name>

    ????????????????????????? ? <value>jdbc:odbc:ejb</value>

    ????????????????????????? </parameter>

    ??? </ResourceParams>

    ????? </Host>

    ??? </Engine>

    ? </Service>

    </Server>

    ?

    tomcat security

    1.????? memoryRealm

    在初始化階段,從 xml 文件 (tomcat-users.xml) 中讀取安全驗(yàn)證信息,並把它們以一組對(duì)象的形式存放在內(nèi)存中

    ??? <Context path="/shop" docBase="C:\project\shoping\longweb" debug="0" reloadable="true">

    ??????????? <Realm className="org.apache.catalina.realm.MemoryRealm"/>

    ????? </Context>

    tomcat-users.xml 文件 D:\Tomcat 5.0\conf

    <?xml version='1.0' encoding='utf-8'?>

    <tomcat-users>

    ? <role rolename="tomcat"/>

    ? <user username="admin" password="admin" roles="standard"/>

    </tomcat-users>

    ?

    2.????? JDBCRealm

    ? 通過 jdbc 驅(qū)動(dòng)程序訪問存放在數(shù)據(jù)庫(kù)中的安全驗(yàn)證信息

    必須在數(shù)據(jù)中創(chuàng)建兩張表 users and user_roles 。 Users: 定義用戶的信息,包括用戶名和密碼, user_roles 定義用戶和角色

    表中代表的字段

    <Context path="/shop" docBase="C:\project\shoping\longweb" debug="0" reloadable="true">

    ????? <Realm className="org.apache.catalina.realm.JDBCRealm" driverName=”com.mysql.jdbc.Driver” debug=”99” connectionURL=”jdbc:mysql://localhost/tomcateuser” connectionName=”dbuser” connectinoPassword=”1234” userTable=”users” userNameCol=”user_name” useCredCol=”user_pass” userRoleTable=”user_roles” roleNameCol=”role_name”/>

    </Context>

    3.????? DataSourceRealm

    DatasourceRealm JDBCRealm 很相似,都是將安全信息存方法在關(guān)係數(shù)據(jù)庫(kù)中,創(chuàng)建的數(shù)據(jù)庫(kù)結(jié)構(gòu)也相同,兩者不 侗在於訪問數(shù)據(jù)庫(kù)的方式不侗, DataSourceRealm 通過 JNDI DataSource 來訪問數(shù)據(jù)庫(kù),

    用於配置 tomcat 服務(wù)范圍的 JNDI 資源

    <!-- Global JNDI resources -->

    ? <GlobalNamingResources>

    ??? <!-- Test entry for demonstration purposes -->

    ??? <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    ??? <!-- Editable user database that can also be used by

    ???????? UserDatabaseRealm to authenticate users -->

    ??? <Resource name="UserDatabase" auth="Container"

    ????????????? type="javax.sql.DataSource "

    ? [1] ????? description="User database that can be updated and saved">

    ??? </Resource>

    ??? <ResourceParams name="UserDatabase">

    ????? <parameter>

    ??????? <name>factory</name>

    ??????? <value>org.apache.commons.dbcp.BasicSourceFactory </value>

    ????? </parameter>

    ????? <parameter>

    ??????? <name>driverClassName </name>

    ??????? <value>com.mysql.jdbc.Driver </value>

    ????? </parameter>

    ????? <parameter>

    ??????? <name>url </name>

    ??????? <value>jdbc:mysql://localhost:3306/tomcateuser?autoReconnect=true </value>

    ????? </parameter>

    ??? </ResourceParams>

    ? </GlobalNamingResources>

    ?

    <Realm className="org.apache.catalina.realm.DataSourceRealm" debug=”99”

    dataSourceName=”UserDatabase” userTable=”users” userNameCol=”user_name” userCredcol=”user_pass”? userRoleTable=”user_roles” rolenameCol=”role_name”/>

    4

    <form name=”form1” method=”post” action=”j_security_check”>

    <input name=”j_username” type=”text” size=”30”>

    <input name=”j_password” type=”password” size=”30”>

    ?

    Tomcat 客戶訪問日志

    <Host name="localhost" debug="0" appBase="webapps"

    ?????? unpackWARs="true" autoDeploy="true">

    ??? ?? <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"

    ??? ????? prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t %r %s %b" resolveHosts="true"/>

    %h: 表示遠(yuǎn)程主機(jī)名

    %t 表示時(shí)間日期

    pattern 屬性的默認(rèn)值為 common , 它相當(dāng)於 ”%h %l %u %t %r %s %b”

    此時(shí)會(huì)在 Tomcat_home\logs 目錄下生成一個(gè) .txt 文件內(nèi)容大體如下 :

    2005-04-15 08:37:35 createObjectName with StandardEngine[Catalina].StandardHost[localhost].StandardContext[/admin]

    2005-04-15 08:37:35 preRegister with Catalina:type=Logger,path=/admin,host=localhost

    ?

    遠(yuǎn)程地址過濾器

    <Host name="localhost" debug="0" appBase="webapps"

    ?????? unpackWARs="true" autoDeploy="true">

    <Valve className=”org.apache.Catalina.valves.RemoteAddrVale” deny=”127.*,222.*”/>

    以上代碼表明,所有 IP 地址以 127,222 開頭的客戶都被拒絕訪問



    ?

    posted on 2006-04-10 12:56 jinmy liao 閱讀(1206) 評(píng)論(0)  編輯  收藏 所屬分類: page view

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 久久久精品2019免费观看 | 无码专区—VA亚洲V天堂| 无码天堂亚洲国产AV| 国产一卡2卡3卡4卡无卡免费视频 国产一卡二卡3卡四卡免费 | 一级毛片在线免费视频| 午夜免费福利网站| 亚洲乱码中文论理电影| 91香蕉在线观看免费高清| 亚洲欧洲精品无码AV| 国产成人无码精品久久久久免费| 在线涩涩免费观看国产精品| jjzz亚洲亚洲女人| 亚洲成a人片在线不卡一二三区 | 亚洲人成在线播放| 四虎免费影院ww4164h| 亚洲国产精品日韩专区AV| 亚洲av无码av在线播放| 妞干网在线免费观看| 亚洲乱码一区二区三区国产精品| 4444www免费看| 亚洲国产综合精品中文第一区| 久久久久免费精品国产| 美女黄网站人色视频免费国产| 亚洲第一成人在线| av无码免费一区二区三区| 亚洲伦理一二三四| 色se01短视频永久免费| 亚洲综合色7777情网站777| 免费国产成人高清在线观看网站| 亚洲熟妇无码爱v在线观看| 啦啦啦完整版免费视频在线观看| 亚洲精品福利网站| 无码乱肉视频免费大全合集| 亚洲丰满熟女一区二区v| 老司机在线免费视频| 亚洲jizzjizz在线播放久| 最近免费中文字幕大全| 亚洲色最新高清av网站| 免费看的一级毛片| 国产成人亚洲综合无| 无码视频免费一区二三区|