Problem with calling isCallerInRole(String role)
mhwish Mar 18, 2010 12:26 AMA.o.a
Sir,
I want to know that either by calling ctx.isCallerInRole("user") it should execute by itself or we have to give this method implementation. I have seen many tuturials and web document related to JAAS they all just execute isCallerInRole("user"), they do not give this method's implementation.
And What will be the implementation of this method??????????????????
My Method is just like as:
@Resource SessionContext ctx;
@PermitAll
public void helloMethod() {
System.out.println(".............With in hellMethod() method..................");
String s=ctx.getCallerPrincipal().getName();
System.out.println(ctx.getCallerPrincipal().getName());
System.out.println(".............Role are going to verify authorize users..................");
if(ctx.isCallerInRole("user") { ////////Problem is here (My role always in Database is "user" but it always execute else condition and print "UNAUTHORIZE")
System.out.println("hello Ali");
}
else {
System.out.println("UNAUTHORISED ");
}
}
I think that there is some problem in my ejb-jar.xml:
<?xml version="1.0" encoding="windows-1252" ?>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>LoginSessionBean</ejb-name>
<home>loginsession.LoginSessionBean</home>
<remote>loginsession.LoginSession</remote>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<message-driven>
<ejb-name>LoginSessionBean</ejb-name>
<transaction-type>Container</transaction-type>
<security-identity>
<run-as>
<role-name>user</role-name>
</run-as>
</security-identity>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<security-role>
<role-name>user</role-name>
</security-role>
<method-permission>
<role-name>user</role-name>
<method>
<ejb-name>LoginSessionBean</ejb-name>
<method-name>helloMethod</method-name>
</method>
</method-permission>
</assembly-descriptor>
</ejb-jar>
I am using JDeveloper 11g
and JBOSS 4.0.4
when I right click on my ejb-jar.xml and select "Properties" then In General Tab there are Written as:
Internal Error when attempting to create this panel:
java.lang.NullPointerException
at oracle.jdevimpl.deploy.ejb.dd.EjbJarPanel.onEntry(EjbJarPanel.java:82)
at oracle.ide.panels.MDDPanel.enterTraversableImpl(MDDPanel.java:1109)
at oracle.ide.panels.MDDPanel.enterTraversable(MDDPanel.java:1090)
at oracle.ide.panels.MDDPanel.mav$enterTraversable(MDDPanel.java:116)
at oracle.ide.panels.MDDPanel$Tsl.updateSelectedNavigable(MDDPanel.java:1546)
at oracle.ide.panels.MDDPanel$Tsl.updateSelection(MDDPanel.java:1414)
at oracle.ide.panels.MDDPanel$Tsl.actionPerformed(MDDPanel.java:1408)
at javax.swing.Timer.fireActionPerformed(Timer.java:271)
at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
at java.awt.Dialog$1.run(Dialog.java:525)
at java.awt.Dialog$2.run(Dialog.java:553)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Dialog.show(Dialog.java:551)
at java.awt.Component.show(Component.java:1300)
at java.awt.Component.setVisible(Component.java:1253)
at oracle.bali.ewt.dialog.JEWTDialog.runDialog(Unknown Source)
at oracle.bali.ewt.dialog.JEWTDialog.runDialog(Unknown Source)
at oracle.ide.dialogs.WizardLauncher.runDialog(WizardLauncher.java:55)
at oracle.ide.panels.TDialogLauncher.showDialog(TDialogLauncher.java:225)
at oracle.jdevimpl.ejb.editor.EjbModuleEditor.showDialog(EjbModuleEditor.java:143)
at oracle.jdevimpl.ejb.editor.EjbModuleEditor.showDialog(EjbModuleEditor.java:95)
at oracle.jdeveloper.ejb.EjbController.handleEvent(EjbController.java:270)
at oracle.ide.controller.IdeAction.performAction(IdeAction.java:513)
at oracle.ide.controller.IdeAction.actionPerformedImpl(IdeAction.java:843)
at oracle.ide.controller.IdeAction.actionPerformed(IdeAction.java:486)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1000)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1041)
at java.awt.Component.processMouseEvent(Component.java:5501)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5266)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3968)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1778)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
I am using JDeveloper 11g
and JBOSS 4.0.4
What is the problem? please reply soon....................