Este contenido no está disponible en el idioma seleccionado.
Chapter 10. Auditing
Important
Important
Procedure 10.1. Enable the security audit feature
Open the log4j configuration file
Navigate to$JBOSS_HOME/server/$PROFILE/conf/
Open thejboss-log4j.xml
file using a text editor.Uncomment the security audit category
By default, the Security Audit Provider category definition in thejboss-log4j.xml
file is commented out. Uncomment the category definition shown in Example 10.1, “log4j Security Audit Provider category”.Example 10.1. log4j Security Audit Provider category
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Uncomment the audit appender
By default, the AUDIT appender definition in thejboss-log4j.xml
file is commented out. Uncomment the appender definition shown in Example 10.1, “log4j Security Audit Provider category”.Example 10.2. log4j Security Audit Provider category
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Save, and restart server
You have now activated the auditing service for your implementation, as configured in thejboss-log4j.xml
file.Restart the server to ensure the new security policy takes effect.Verify security auditing is functioning correctly
Once the audit service is configured and deployed, audit log entries will verify the audit service and EJB invocation success.Theaudit.log
file is located injboss-as/server/$PROFILE/log/
directory.A successful EJB invocation would look similar to the followingaudit.log
output.Example 10.3. Successful EJB Invocation log entry
2008-12-05 16:08:26,719 TRACE [org.jboss.security.audit.providers.LogAuditProvider] (http-127.0.0.1-8080-2:) [Success]policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518; Resource:=[org.jboss.security.authorization.resources.EJBResource:contextMap={policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518}:method=public abstract org.jboss.test.security.interfaces.RunAsServiceRemote org.jboss.test.security.interfaces.RunAsServiceRemoteHome.create() throws java.rmi.RemoteException,javax.ejb.CreateException:ejbMethodInterface=Home:ejbName=RunAs:ejbPrincipal=jduke:MethodRoles=Roles(identitySubstitutionCaller,):securityRoleReferences=null:callerSubject=Subject: Principal: [roles=[identitySubstitutionCaller, extraRunAsRole],principal=runAsUser] Principal: Roles(members:extraRunAsRole,identitySubstitutionCaller) :callerRunAs=[roles=[identitySubstitutionCaller, extraRunAsRole],principal=runAsUser]:callerRunAs=[roles=[identitySubstitutionCaller, extraRunAsRole],principal=runAsUser]:ejbRestrictionEnforcement=false:ejbVersion=null];Source=org.jboss.security.plugins.javaee.EJBAuthorizationHelper;Exception:=;
2008-12-05 16:08:26,719 TRACE [org.jboss.security.audit.providers.LogAuditProvider] (http-127.0.0.1-8080-2:) [Success]policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518; Resource:=[org.jboss.security.authorization.resources.EJBResource:contextMap={policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518}:method=public abstract org.jboss.test.security.interfaces.RunAsServiceRemote org.jboss.test.security.interfaces.RunAsServiceRemoteHome.create() throws java.rmi.RemoteException,javax.ejb.CreateException:ejbMethodInterface=Home:ejbName=RunAs:ejbPrincipal=jduke:MethodRoles=Roles(identitySubstitutionCaller,):securityRoleReferences=null:callerSubject=Subject: Principal: [roles=[identitySubstitutionCaller, extraRunAsRole],principal=runAsUser] Principal: Roles(members:extraRunAsRole,identitySubstitutionCaller) :callerRunAs=[roles=[identitySubstitutionCaller, extraRunAsRole],principal=runAsUser]:callerRunAs=[roles=[identitySubstitutionCaller, extraRunAsRole],principal=runAsUser]:ejbRestrictionEnforcement=false:ejbVersion=null];Source=org.jboss.security.plugins.javaee.EJBAuthorizationHelper;Exception:=;
Copy to Clipboard Copied! Toggle word wrap Toggle overflow An unsuccessful EJB invocation would look similar to the followingaudit.log
output.Example 10.4. Unsuccessful EJB Invocation log entry
[Error]policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518;Resource:=[org.jboss.security.authorization.resources.EJBResource:contextMap={policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518}:method=public java.security.Principal org.jboss.test.security.ejb3.SimpleStatelessSessionBean.invokeUnavailableMethod():ejbMethodInterface=Remote:ejbName=SimpleStatelessSessionBean:ejbPrincipal=UserA:MethodRoles=Roles(<NOBODY>,):securityRoleReferences=null:callerSubject=Subject: Principal: UserA Principal: Roles(members:RegularUser,Administrator) :callerRunAs=null:callerRunAs=null:ejbRestrictionEnforcement=false:ejbVersion=null];Source=org.jboss.security.plugins.javaee.EJBAuthorizationHelper;Exception:=Authorization Failed: ;
[Error]policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518;Resource:=[org.jboss.security.authorization.resources.EJBResource:contextMap={policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518}:method=public java.security.Principal org.jboss.test.security.ejb3.SimpleStatelessSessionBean.invokeUnavailableMethod():ejbMethodInterface=Remote:ejbName=SimpleStatelessSessionBean:ejbPrincipal=UserA:MethodRoles=Roles(<NOBODY>,):securityRoleReferences=null:callerSubject=Subject: Principal: UserA Principal: Roles(members:RegularUser,Administrator) :callerRunAs=null:callerRunAs=null:ejbRestrictionEnforcement=false:ejbVersion=null];Source=org.jboss.security.plugins.javaee.EJBAuthorizationHelper;Exception:=Authorization Failed: ;
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure 10.2. Enable security auditing for Web containers
Enable EJB security auditing
You must enable security as described in Procedure 10.1, “Enable the security audit feature”.Activate auditing in the server realm
Web container auditing must first be activated in the server realm of theserver.xml
file.Theserver.xml
file is located in thejboss-as/server/$PROFILE/deploy/jbossweb.sar/
directory.The<Realm>
element must have theenableAudit="
attribute set, as per Example 10.5, “server.xml audit activation”.true
"Example 10.5. server.xml audit activation
<Realm className="org.jboss.web.tomcat.security.JBossWebRealm" certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping" allRolesMode="authOnly" enableAudit="true"/>
<Realm className="org.jboss.web.tomcat.security.JBossWebRealm" certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping" allRolesMode="authOnly" enableAudit="true"/>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify auditing levels system property
The auditing levels for Web applications must be specified using the org.jboss.security.web.audit system property in therun.conf
(Linux) orrun.conf.bat
(Microsoft Windows) script.Alternatively, you can specify the system property in thejboss-as/server/$PROFILE/deploy/properties-service.xml
file.Linux
Add the system property into thejboss-as/bin/run.sh
file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Microsoft Windows
Add the system property into thejboss-as/bin/run.bat
file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow properties-service.xml
Update theSystemPropertiesService
class MBean in thejboss-as/server/$PROFILE/deploy/properties-service.xml
file, and declare the java property as an <attribute>. You can uncomment the relevant operating system block in the code sample below.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify security auditing is functioning correctly
Once the system property is specified in the files, audit log entries will verify Web invocation success.Theaudit.log
file is located injboss-as/server/$PROFILE/log/
directory.A successful Web invocation would look similar to the followingaudit.log
output.Example 10.6. Successful Web Invocation log entry
2008-12-05 16:08:38,997 TRACE [org.jboss.security.audit.providers.LogAuditProvider] (http-127.0.0.1-8080-17:) [Success]policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518;Resource:=[org.jboss.security.authorization.resources.WebResource:contextMap={policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518,securityConstraints=[Lorg.apache.catalina.deploy.SecurityConstraint;@6feeae6, resourcePermissionCheck=true},canonicalRequestURI=/restricted/get-only/x,request=[/web-constraints:cookies=null:headers=user-agent=Jakarta Commons-HttpClient/3.0,authorization=host=localhost:8080,][parameters=],CodeSource=null];securityConstraints=SecurityConstraint[RestrictedAccess - Get Only];Source=org.jboss.security.plugins.javaee.WebAuthorizationHelper;resourcePermissionCheck=true;Exception:=;
2008-12-05 16:08:38,997 TRACE [org.jboss.security.audit.providers.LogAuditProvider] (http-127.0.0.1-8080-17:) [Success]policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518;Resource:=[org.jboss.security.authorization.resources.WebResource:contextMap={policyRegistration=org.jboss.security.plugins.JBossPolicyRegistration@76ed4518,securityConstraints=[Lorg.apache.catalina.deploy.SecurityConstraint;@6feeae6, resourcePermissionCheck=true},canonicalRequestURI=/restricted/get-only/x,request=[/web-constraints:cookies=null:headers=user-agent=Jakarta Commons-HttpClient/3.0,authorization=host=localhost:8080,][parameters=],CodeSource=null];securityConstraints=SecurityConstraint[RestrictedAccess - Get Only];Source=org.jboss.security.plugins.javaee.WebAuthorizationHelper;resourcePermissionCheck=true;Exception:=;
Copy to Clipboard Copied! Toggle word wrap Toggle overflow An unsuccessful EJB invocation would look similar to the followingaudit.log
output.Example 10.7. Unsuccessful Web Invocation log entry
2008-12-05 16:08:41,561 TRACE [org.jboss.security.audit.providers.LogAuditProvider] (http-127.0.0.1-8080-4:) [Failure]principal=anil;Source=org.jboss.web.tomcat.security.JBossWebRealm;request=[/jaspi-web-basic:cookies=null:headers=user-agent=Jakarta Commons-HttpClient/3.0,authorization=host=localhost:8080,][parameters=][attributes=];2008-12-05 16:07:30,129 TRACE [org.jboss.security.audit.providers.LogAuditProvider] (WorkerThread#1[127.0.0.1:55055]:)
2008-12-05 16:08:41,561 TRACE [org.jboss.security.audit.providers.LogAuditProvider] (http-127.0.0.1-8080-4:) [Failure]principal=anil;Source=org.jboss.web.tomcat.security.JBossWebRealm;request=[/jaspi-web-basic:cookies=null:headers=user-agent=Jakarta Commons-HttpClient/3.0,authorization=host=localhost:8080,][parameters=][attributes=];2008-12-05 16:07:30,129 TRACE [org.jboss.security.audit.providers.LogAuditProvider] (WorkerThread#1[127.0.0.1:55055]:)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow