[JBoss Seam] - Re: who can explain the security features demonstrate in the
by shane.bryzak@jboss.com
"wuhaixing" wrote : In the seamspace project,security-rule.drl has the following code snippet I donn't know why.
| 1.
| check: PermissionCheck(name == "memberImage", action == "view", granted == false)
| there is a memberImage component,but where is the action view?
|
In ContentAction:
if (img == null || !Identity.instance().hasPermission("memberImage", "view", img))
"wuhaixing" wrote : 2.
| check: PermissionCheck(name == "blog", action == "create", granted == false)
| Does this mean Statful session bean BlogAction create is restircted?
|
No, this permission is used to control the display of a link in profile.xhtml:
<s:span rendered="#{s:hasPermission('blog', 'create', selectedMember)}">
"wuhaixing" wrote : 3.
| check: PermissionCheck(name == "friendComment", action == "create", granted == false)
| Restrict @Factory("friendComment")?and where is action create?
|
This is also in profile.xhtml:
<s:span rendered="#{s:hasPermission('friendComment', 'create', selectedMember.friends)}">
And the permission is checked in FriendAction:
Identity.instance().checkRestriction("#{s:hasPermission('friendComment', 'create', friends)}");
"wuhaixing" wrote : 4.
| @Restrict is not required to invoke permission check?
No, a permission check can be also be performed via Identity.checkRestriction().
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107903#4107903
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107903
18 years, 5 months
[Beginners Corner] - Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
by tamscot
When debugging in Eclipse...
when entering the sendMessage() method of the servlet...the
| QueueConnection qConnection =
| AsyncJujitsuFacadeUtil.getQueueConnection();
|
eventually stepping into...
| java.lang.Object objRef = initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME);
|
in the xdoclet generated class AsyncJujitsufacadeUtil.
When the following method is called...
| cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;
|
we step into the class ClassLoader method below
| // This method is invoked by the virtual machine to load a class.
| private synchronized Class loadClassInternal(String name)
| throws ClassNotFoundException
| {
| return loadClass(name);
| }
|
which I take is the
javax.jms.QueueConnectionFactory
The next method stepped into is
| public Class<?> loadClass(String name) throws ClassNotFoundException {
| return loadClass(name, false);
| }
|
The next method I think causes the exception...
| private void checkPackageAccess(Class cls, ProtectionDomain pd) {
| final SecurityManager sm = System.getSecurityManager();
| if (sm != null) {
| final String name = cls.getName();
| final int i = name.lastIndexOf('.');
| if (i != -1) {
| AccessController.doPrivileged(new PrivilegedAction() {
| public Object run() {
| sm.checkPackageAccess(name.substring(0, i));
| return null;
| }
| }, new AccessControlContext(new ProtectionDomain[] {pd}));
| }
| }
| domains.add(pd);
| }
|
When it gets to the comarison for sm != null, sm = null so goes to domain.add() then from there to the ClassCastException creation method.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107902#4107902
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107902
18 years, 5 months
[Beginners Corner] - Re: java.lang.ClassCastException: org.jnp.interfaces.NamingC
by tamscot
Okay here goes. This is a message driven ejb. The user enters a string which represents an identification. This is done from a html form and text input. The idea is the string is used as an id for the creation of a new object.
Here is the html
| <form action="CreateClubAction" method="GET">
| <table>
| <tr><th>Club ID</th><th><input type="text" name="clubId" value=""/></th></tr>
| <tr><td colspan="2"><input type="submit" name="add" value="add"/></td></tr>
| </table>
| </form>
|
The url "CreateClubAction" is a servlet which creates an "in memory copy of data required to initialize the application. It then sends a message, the string entered into the html page and replies to standout the string entered whilst displaying a jsp page with a copy of the in memory data.
here is some of CreateClubAction.java, the servlet.
| protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
| try{
| String clubId = request.getParameter("clubId");
| sendMessage(clubId);
| forward(request, response);
| }catch(Exception e){
| e.printStackTrace();
| }
| }
|
| private void sendMessage(String clubId) throws
| NamingException, JMSException {
| QueueConnection qConnection =
| AsyncJujitsuFacadeUtil.getQueueConnection();
| Queue queue = AsyncJujitsuFacadeUtil.getQueue();
| QueueSession qSession =
| qConnection.createQueueSession(false, SESSIONTYPE);
| QueueSender qSender = qSession.createSender(queue);
|
| Club aClub = new Club();
| aClub.setId(clubId);
|
| ObjectMessage objectMessage = qSession.createObjectMessage(aClub);
| qSender.send(objectMessage);
| qSession.close();
| qConnection.close();
|
| }
|
| private void forward(HttpServletRequest request, HttpServletResponse response)
| throws ServletException, IOException {
| this.getServletContext().getRequestDispatcher("/students.jsp")
| .forward(request, response);
|
| }
|
Where it is falling down is on the call to sendMessage() above. Which equates to the line in the xdoclet created class AsyncJujitsuFacadeUtil.java shown below.
| public static javax.jms.QueueConnection getQueueConnection() throws javax.naming.NamingException, javax.jms.JMSException
| {
| if (cachedConnectionFactory == null) {
| // Obtain initial context
| javax.naming.InitialContext initialContext = new javax.naming.InitialContext();
| try {
| java.lang.Object objRef = initialContext.lookup(CONNECTION_FACTORY_JNDI_NAME);
| cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;
| } finally {
| initialContext.close();
| }
| }
| return cachedConnectionFactory.createQueueConnection();
| }
|
The line below is where the exception points to...
| cachedConnectionFactory = (javax.jms.QueueConnectionFactory) objRef;
|
The bean class is shown below...
| public class AsyncJujitsuFacadeBean implements javax.ejb.MessageDrivenBean,
| javax.jms.MessageListener {
|
| /**
| *
| */
| private static final long serialVersionUID = 1L;
| /**
| * <!-- begin-user-doc -->
| * <!-- end-user-doc -->
| * The context for the message-driven bean, set by the EJB container.
| * @generated
| */
| private javax.ejb.MessageDrivenContext messageContext = null;
| private JujitsuFacade jujitsuFacade;
|
| /**
| * Required method for container to set context.
| * @generated
| */
| public void setMessageDrivenContext(
| javax.ejb.MessageDrivenContext messageContext)
| throws javax.ejb.EJBException {
| this.messageContext = messageContext;
| }
|
| /**
| * Required creation method for message-driven beans.
| *
| * <!-- begin-user-doc -->
| * <!-- end-user-doc -->
| *
| * <!-- begin-xdoclet-definition -->
| * @ejb.create-method
| * <!-- end-xdoclet-definition -->
| * @generated
| */
| public void ejbCreate() {
| //no specific action required for message-driven beans
| jujitsuFacade = ClubFacade.getJujitsuFacade();
| }
|
| /**
| * Required removal method for message-driven beans.
| * <!-- begin-user-doc -->
| * <!-- end-user-doc -->
| * @generated
| */
| public void ejbRemove() {
| messageContext = null;
| }
|
| /**
| * This method implements the business logic for the EJB.
| *
| * <p>Make sure that the business logic accounts for asynchronous message processing.
| * For example, it cannot be assumed that the EJB receives messages in the order they were
| * sent by the client. Instance pooling within the container means that messages are not
| * received or processed in a sequential order, although individual onMessage() calls to
| * a given message-driven bean instance are serialized.
| *
| * <p>The <code>onMessage()</code> method is required, and must take a single parameter
| * of type javax.jms.Message. The throws clause (if used) must not include an application
| * exception. Must not be declared as final or static.
| *
| * <!-- begin-user-doc -->
| * <!-- end-user-doc -->
| * @generated
| */
| public void onMessage(javax.jms.Message message) {
| // begin-user-code
| try{
| Club club = (Club)((ObjectMessage) message).getObject();
| jujitsuFacade.createClub(club);
| System.out.println("A New Club: " + club.getId());
| }catch(JMSException e){
| e.printStackTrace();
| }
| // end-user-code
| }
|
| /**
| *
| */
| public AsyncJujitsuFacadeBean() {
| // TODO Auto-generated constructor stub
| }
| }
|
Hope someone can understand whats going wrong here as I can't.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107900#4107900
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107900
18 years, 5 months
[JBoss Seam] - External Client and Seam Security
by agnadello
Hi,
I've configured Seam to use drools in my security setup according to Seam docs, chapter 13. Everything works fine...
I also have a QuartzInitializerServlet starting up jobs (POJO's):
public void execute(final JobExecutionContext theJobExecutionContext)
| throws JobExecutionException {
| this.LOGGER.info("Executing job with description: "
| + theJobExecutionContext.getJobDetail().getDescription());
|
| try {
| UsernamePasswordHandler handler = new UsernamePasswordHandler(
| "user", "Demo987!");
| this.LOGGER.info("Login attempt...");
| LoginContext lc = new LoginContext("client-login", handler);
| lc.login();
| this.LOGGER.info("Login successful!");
| // Any calls to secured resources now use the username/password
| // identity
| final EchoService service = (EchoService) new InitialContext()
| .lookup("sio/EchoServiceBean/local");
| final Echo echo = service.echo();
| this.LOGGER.info("Echo Message = '" + echo + "'");
| // Clear and restore the previous identity
| this.LOGGER.info("Logout attempt...");
| lc.logout();
| this.LOGGER.info("Logout successful!");
| } catch (Exception e) {
| e.printStackTrace();
| }
| }
The EJB method 'echo' is annotated with the Seam @Restrict annotation like this:
@Restrict("#{s:hasRole('admin')}")
My question is if it's possible to make the external JAAS login (from the Quartz job) to propagate to the Seam security framework?
The described implementation doesn't work and throws IllegalStateException with the message that there is no active session context.
Anyone done this before?
Seam 2.0.0.GA and JBoss AS 4.2.1.GA
Cheers!
Regards, Andreas
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107898#4107898
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107898
18 years, 5 months
[JBoss jBPM] - jbpm 3.2.2 web console on JBoss 4.2.0 - NullPointerException
by gerrmann
Hello,
I'm running the jbpm-console war that comes with the Jbpm 3.2.2. Suite distribution on a JBoss 4.2.0 server. I've modified the war as described in the Wiki article at http://www.jboss.com/wiki/Edit.jsp?page=DeployJbpm3.2WebAppUnderJBoss4.2.x. My Jbpm database is in Oracle 9i which was created using the Oracle script in the 3.2.2 Suite.
The console web app starts up without error. I am able to upload process definitions via the "Deploy" tab of the Jbpm Graphical Process Designer in Eclipse, and my Seam component (Seam 2.0) successfully starts a new process instance and inserts it into the database.
Here's the problem: Although I can bring up the console application in my browser and successfully log in, the following error is displayed on the "Processes" page of the console app:
"Error loading process list: An exception of type "java.lang.NullPointerException" was thrown."
No processes are displayed. I get a similar error when I click on any of the menu links (Tasks, Jobs, Identities,...) in the console application. I get the same error when I try to upload a process definition via the web console (although, as stated above, I have no problem uploading process definitions via the Graphical Process Designer in Eclipse).
I see no stack trace for the NullPointerException in the server log. I've added log4j.jar and a log4j.properties file to the jbpm console war so I get a log for the console web application, but again there is no stack trace.
Can anyone tell me where I might find a stack trace for the NullPointerException? OR has anyone else experienced this error and resolved it?
Thanks for any help you can give.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107893#4107893
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107893
18 years, 5 months