Below is the steps that deploy the security in our recent projects:
1.Download 'jbossws-native-3.1.1.GA.zip' from 'http://www.jboss.org/jbossws/downloads/'
2.Install jbossws-native-3.1.1.GA
unzip jbossws-native-3.1.1.GA.zip
Copy \jbossws-native-bin-dist\ant.properties.example to a new file named ant.properties
Modify the ant.properties as follows:
jboss423.home=@jboss423.home@ -> jboss423.home=C:/usr/local/jboss-4.2.3.GA
jbossws.integration.target=jboss500 -> jbossws.integration.target=jboss423
run->cmd under path \jbossws-native-bin-dist\ run "ant deploy-jboss423"
3.Annotations can be used on the Java Jboss server in the following way to secure access to the operations of a webservice:
package nl.ontraq.jobboard.authentication;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateless;
import nl.ontraq.jobboard.util.Constants;
import org.jboss.annotation.security.SecurityDomain;
import org.jboss.ws.annotation.EndpointConfig;
import org.jboss.wsf.spi.annotation.WebContext;
@javax.jws.WebService(name = "Authentication",
serviceName = "Authentication",
portName = "AuthenticationSOAP",
targetNamespace = "http://jobboard.ontraq.nl/Authentication/",
endpointInterface = "nl.ontraq.jobboard.authentication.Authentication")
@WebContext(contextRoot="/ojbservices/authentication", urlPattern="/Authentication")
@Stateless
@EndpointConfig(configName="Standard WSSecurity Endpoint")
@SecurityDomain("ojbpolicy")
public class AuthenticationImpl implements Authentication {
...
@RolesAllowed({Constants.OJB_ROLES_ADMIN, Constants.OJB_ROLES_CANDIDATE})
public int saveSetting(EditSettings parameters) {
...
}
}
The Role constants were defined in the CLass nl.ontraq.jobboard.util.Constants.
package nl.ontraq.jobboard.util;
public class Constants {
public static final String OJB_ID_OWNER = "OJB";
public static final String OJB_USERNAME = "username";
public static final String OJB_CANDIDATE_UID = "CandidateUID";
public static final String OJB_ROLES_GUEST = "guest";
public static final String OJB_ROLES_CANDIDATE = "candidate";
public static final String OJB_ROLES_EMPLOYER = "employer";
public static final String OJB_ROLES_ADMIN = "admin";
}
4.Init roles data into table 'ojb.role'
INSERT INTO ojb."role"("idRole", rolename, roledescription) VALUES (1,"guest","Guest role");
INSERT INTO ojb."role"("idRole", rolename, roledescription) VALUES (2,"candidate","Candidate role");
INSERT INTO ojb."role"("idRole", rolename, roledescription) VALUES (3,"employer","Employer role");
INSERT INTO ojb."role"("idRole", rolename, roledescription) VALUES (9,"admin","Admin role");
5.The user role information is in the table ojb.user_has_role
6.The securitydomain 'ojbpolicy' must have been defined in the file 'login-config.xml' present in the Jboss 'conf' directory:
<application-policy name="ojbpolicy">
<authentication>
<login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag="required">
<module-option name="dsJndiName">java:/LoginDS</module-option>
<module-option name="principalsQuery">
select password from ojb.ojbuser where username=?
</module-option>
<!-- NOTE: make sure you use double quotes for fieldnames !! -->
<module-option name="rolesQuery">
select c."rolename",'Roles' from ojb.user_has_role a, ojb.ojbuser b, ojb.role c
where a."User_idUser" = b."idUser" and a."Role_idRole" = c."idRole" and b."username"=?
</module-option>
<module-option name="unauthenticatedIdentity">guest</module-option>
</login-module>
</authentication>
</application-policy>
7.A datasource 'LoginDS' needs to be defined in the deploy directory, file 'postgresql-ds.xml':
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>LoginDS</jndi-name>
<connection-url>jdbc:postgresql://localhost/ojb</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<user-name>ojb_owner</user-name>
<password>ojb_owner</password>
</local-tx-datasource>
</datasources>
8.Copy postgress database driver 'postgresql-8.3-603.jdbc3.jar' needs to be available in the 'lib' directory of Jboss ('.../server/default/lib').
9.Create jboss-wsse-server.xml and save in META-INF folder based on the EJB (OJBAuthenticationEJB)
Sample file:
<jboss-ws-security xmlns="http://www.jboss.com/ws-security/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/ws-security/config
http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
</jboss-ws-security>
10.Create jboss-wsse-client.xml and and save in META-INF folder based on the EJB (OJBAuthenticationEJB)
Sample file:
<jboss-ws-security xmlns="http://www.jboss.com/ws-security/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/ws-security/config
http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
</jboss-ws-security>
11.Deploy the EAR, then the security base on the role can be used then.
分享到:
相关推荐
赠送原API文档:commons-math3-3.1.1-javadoc.jar; 赠送源代码:commons-math3-3.1.1-sources.jar; 赠送Maven依赖信息文件:commons-math3-3.1.1.pom; 包含翻译后的API文档:commons-math3-3.1.1-javadoc-API文档...
赠送原API文档:spring-cloud-gateway-server-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-gateway-server-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-gateway-server-3.1.1.pom; 包含翻译后的...
hadoop-annotations-3.1.1.jar hadoop-common-3.1.1.jar hadoop-mapreduce-client-core-3.1.1.jar hadoop-yarn-api-3.1.1.jar hadoop-auth-3.1.1.jar hadoop-hdfs-3.1.1.jar hadoop-mapreduce-client-hs-3.1.1.jar ...
赠送原API文档:spring-cloud-commons-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-commons-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-commons-3.1.1.pom; 包含翻译后的API文档:spring-cloud-...
赠送原API文档:spring-cloud-loadbalancer-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-loadbalancer-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-loadbalancer-3.1.1.pom; 包含翻译后的API文档...
赠送原API文档:spring-cloud-loadbalancer-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-loadbalancer-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-loadbalancer-3.1.1.pom; 包含翻译后的API文档...
Hadoop-Eclipse-Plugin-3.1.1是一款专为Eclipse集成开发环境设计的插件,用于方便地在Hadoop分布式文件系统(HDFS)上进行开发和调试MapReduce程序。这款插件是Hadoop生态系统的组成部分,它使得Java开发者能够更加...
赠送原API文档:spring-cloud-gateway-server-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-gateway-server-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-gateway-server-3.1.1.pom; 包含翻译后的...
赠送原API文档:spring-cloud-commons-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-commons-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-commons-3.1.1.pom; 包含翻译后的API文档:spring-cloud-...
maven-jar-plugin-3.1.1.jar
赠送原API文档:spring-cloud-openfeign-core-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-openfeign-core-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-openfeign-core-3.1.1.pom; 包含翻译后的...
java运行依赖jar包
MQTT中文文档,帮助理解MQTT具体协议,用于创建服务器或者客户端
flink-core-1.8.1 flink-cdc-3.1.1基础依赖lib包 免费下载flink-core-1.8.1 flink-cdc-3.1.1基础依赖lib包 免费下载flink-core-1.8.1 flink-cdc-3.1.1基础依赖lib包 免费下载flink-core-1.8.1 flink-cdc-3.1.1基础...
赠送原API文档:spring-cloud-openfeign-core-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-openfeign-core-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-openfeign-core-3.1.1.pom; 包含翻译后的...
赠送原API文档:common-image-3.1.1-javadoc.jar; 赠送源代码:common-image-3.1.1-sources.jar; 赠送Maven依赖信息文件:common-image-3.1.1.pom; 包含翻译后的API文档:common-image-3.1.1-javadoc-API文档-...
flink-cdc-3.1.1-bin.tar.gz 免费下载flink-cdc-3.1.1-bin.tar.gz 免费下载flink-cdc-3.1.1-bin.tar.gz 免费下载flink-cdc-3.1.1-bin.tar.gz 免费下载flink-cdc-3.1.1-bin.tar.gz 免费下载flink-cdc-3.1.1-bin.tar....
赠送原API文档:spring-cloud-context-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-context-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-context-3.1.1.pom; 包含翻译后的API文档:spring-cloud-...
配置springmvc的spring-webmvc的jar包,可用于ssm框架的使用
《全面解析 sinaWeibo javaSDK - weibo4j-oauth2-beta3.1.1》 在当今社交媒体时代,新浪微博作为中国最受欢迎的社交平台之一,为开发者提供了丰富的API接口,以便构建与微博互动的应用程序。其中,`sinaWeibo java...