[Security & JAAS/JBoss] - JBoss Servlet making RMI call: Security Exception
by Lokeya
I am using JBoss as my Application server and trying to make an RMI call from that. Facing following exception. I googled and understood that its something to do with the Java 2 security issue. I tried to overcome that using the following lines of code in my servlet(RMI client) and RMI server
System.setProperty("java.security.policy","policy.all");
System.setSecurityManager(new RMISecurityManager());
where i grant AllPermissions. Even then facing the following issue. Is there some JBoss configuration which needs to be changed to get this working?
Help Appreciated.
java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:2000 connect,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java :264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4062232#4062232
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4062232
18Â years, 9Â months
[JBoss Seam] - Re: long running conversation problem
by sunil.su
Here is the page
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <html xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
| <head>
| <link href="style.css" rel="stylesheet" type="text/css"/>
| </head>
| <body>
|
| <h2>Create Org</h2>
|
| <f:facet name="beforeInvalidField">
| <h:graphicImage styleClass="errorImg" value="error.png"/>
| </f:facet>
| <f:facet name="afterInvalidField">
| <s:message styleClass="errorMsg" />
| </f:facet>
| <f:facet name="aroundInvalidField">
| <s:div styleClass="error"/>
| </f:facet>
| <h:form>
| <h1>Org</h1>
| <fieldset>
| <h:commandButton value="Org" action="#{orgmanager.start}" styleClass="button" />
| </fieldset>
| </h:form>
| <h:form>
| <s:validateAll>
| <table>
| <tr>
| <td>Org Name:</td>
| <td>
| <s:decorate>
| <h:inputText value="#{orgEntry.name}" size="32">
| </h:inputText>
| </s:decorate>
| </td>
| </tr>
|
| <tr>
| <td>Org Code:</td>
| <td>
| <a4j:outputPanel id="orgcode">
| <f:subview rendered="#{!empty(codeErrorMsg)}">
| <f:verbatim><div class="error"></f:verbatim>
| <h:graphicImage styleClass="errorImg" value="error.png"/>
| </f:subview>
|
| <h:inputText value="#{orgmanager.orgCode}" size="32">
| <a4j:support event="onblur" reRender="orgcode"/>
| </h:inputText>
| <f:subview rendered="#{!empty(codeErrorMsg)}">
| <h:outputText styleClass="errorMsg"
| value="#{codeErrorMsg}"/>
| <f:verbatim></div></f:verbatim>
| </f:subview>
| </a4j:outputPanel>
| </td>
| </tr>
|
| <tr>
| <td>Org Description:</td>
| <td>
| <s:decorate>
| <h:inputText value="#{orgEntry.description}" size="32">
| </h:inputText>
| </s:decorate>
| </td>
| </tr>
|
| <tr>
| <td>Org Level:</td>
| <td>
| <a4j:outputPanel id="orglevel">
| <s:decorate>
| <h:panelGroup>
| <h:selectOneMenu value = "#{orgLevelStr}">
| <f:selectItems value="#{orgLevels}" />
| <a4j:support event="onchange" action="#{orgmanager.getParentOrgCodes}"
| ajaxSingle="true" reRender="orgparent" />
| </h:selectOneMenu>
| </h:panelGroup>
| </s:decorate>
| </a4j:outputPanel>
| </td>
| </tr>
|
| <tr>
| <td>Org Parent:</td>
| <td>
| <a4j:outputPanel id="orgparent">
| <s:decorate>
| <h:panelGroup>
| <h:selectOneMenu value = "#{orgmanager.parentOrgCode}">
| <s:selectItems value="#{parentOrgCodes}" var="parentOrgCode" label="#{parentOrgCode}" />
| </h:selectOneMenu>
| </h:panelGroup>
| </s:decorate>
| </a4j:outputPanel>
| </td>
| </tr>
| </table>
| </s:validateAll>
|
| <h:commandButton type="submit"
| value="Create Org"
| action="#{orgmanager.createOrg}"/>
| </h:form>
|
| <p>Orgs:</p>
|
| <h:form>
| <h:dataTable id="orgList" value="#{orgList}" var="org">
| <h:column>
| <f:facet name="header">
| <h:outputText value="Name" />
| </f:facet>
| <h:outputText value="#{org.name}"/>
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Code" />
| </f:facet>
| <s:link value="#{org.code}" action="#{orgmanager.selectOrg}" propagation="join"/>
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Description" />
| </f:facet>
| <h:outputText value="#{org.description}"/>
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Level" />
| </f:facet>
| <h:outputText value="#{org.orgLevel.name}"/>
| </h:column>
| </h:dataTable>
| </h:form>
| </body>
| </html>
|
The code for the bean is
|
| @Stateful
| @Scope(ScopeType.CONVERSATION)
| @Name("orgmanager")
| @Conversational(ifNotBegunOutcome="menu")
| public class OrgManagerBean implements OrgManager, Serializable {
| @Logger
| private Log log;
|
| @PersistenceContext(type = EXTENDED)
| private EntityManager em;
|
| @In(create=true,required = false) @Out(required = false)
| private Org orgEntry;
|
| @EJB OrgDAO orgDAO;
| @EJB OrgLevelDAO orgLevelDAO;
|
| @Out(required = false)
| private List<String> parentOrgCodes = new ArrayList<String>();
| @Out(required = false)
| private List<SelectItem> orgLevels = new ArrayList<SelectItem>();
|
| @DataModel
| private List<Org> orgList;
|
| @DataModelSelectionIndex
| private int orgIndex;
|
| private OrgLevel orgLevel;
|
| //@Begin(join=true)
| public String start() {
| //loadOrgs();
| //loadOrgLevels();
| return "org";
| }
|
| @End
| public String createOrg() {
| Org parentOrg = null;
| orgLevel = orgLevelDAO.findByName(orgLevelStr);
| orgEntry.setOrgLevel(orgLevel);
| em.persist(orgEntry);
| if (parentOrgCode != null) {
| parentOrg = orgDAO.findOrgByCode(parentOrgCode);
| OrgLink orgLink = new OrgLink(parentOrg, orgEntry, new Date());
| em.persist(orgLink);
| }
| return "org";
| }
|
| public String listOrgLevel() {
| // TODO Auto-generated method stub
| return null;
| }
| public void loadOrgLevels() {
| List<OrgLevel> list = orgLevelDAO.findAll();
| orgLevels = new ArrayList<SelectItem>();
| for (OrgLevel level : list) {
| orgLevels.add(new SelectItem(level.getName(), level.getName()));
| }
| log.info("orgLevels size = " + orgLevels.size());
| }
|
| @Begin(join=true) @Create
| public void init() {
| log.info("init() called");
| loadOrgs();
| loadOrgLevels();
| }
| public void loadOrgs() {
| orgList = orgDAO.findAll();
| }
|
| public String selectOrg() {
| log.info("Index =" + orgIndex);
| System.out.println("Index =" + orgIndex);
| orgEntry = orgList.get(orgIndex);
| log.info("Selected Code: " + orgEntry.getCode());
| return "org";
| }
|
| @Out(required = false)
| String codeErrorMsg;
|
| @In(required = false)
| String orgLevelStr;
|
| public void getParentOrgCodes() {
| log.info("-> getParentOrgCodes");
| if (parentOrgCodes != null)
| parentOrgCodes.clear();
| if (orgLevelStr != null) {
| orgLevel = orgLevelDAO.findByName(orgLevelStr);
| orgEntry.setOrgLevel(orgLevel);
| int level = orgEntry.getOrgLevel().getLevel();
| List<Org> list = orgDAO.findOrgsAboveLevel(level);
| for (Org o : list) {
| parentOrgCodes.add(o.getCode());
| }
|
| }
| }
|
| String orgCode;
|
| public void setOrgCode(String orgCode) {
| this.orgCode = orgCode;
| if (orgDAO.findOrgByCode(orgCode) != null) {
| codeErrorMsg = "Warning: \"" + orgCode +
| "\" is already in the system.";
| }
| else {
| codeErrorMsg = "";
| orgEntry.setCode(orgCode);
| }
| }
|
| public String getOrgCode() {
| return orgCode;
| }
|
| String parentOrgCode;
| public String getParentOrgCode() {
| return parentOrgCode;
| }
| public void setParentOrgCode(String pOC) {
| parentOrgCode = pOC;
| }
|
| @Destroy @Remove
| public void destroy() {
| log.info("destroy() called");
| }
| }
|
Thanks....
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4062225#4062225
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4062225
18Â years, 10Â months
[JBoss Seam] - Re: Getting objects from conversation in a custom PhaseListe
by JakeC
OK, I've found out how to get objects from the Context, but I'm still killing the conversation, even though I thought I found a fix for that.
Now, in my try block for getDocument(), I have this:
| DocumentSet docSet = (DocumentSet)Contexts.getConversationContext().get("currentReferral");
| if(attachments != null)
| attachments = docSet.getAttachments();
|
My endConversation() now looks like this:
| Manager.instance().leaveConversation();
| Manager.instance().endRequest(ContextAdaptor.getRequest(request));
| Lifecycle.endRequest();
|
However, I'm still having the same problem with killing the Conversation.
The second time I try to access one of these links, the Conversation ID has changed, even though the URL has not. The commend for Manager.leaveConversation() says "Leave the scope of the current conversation, leaving it completely intact", but it doesn't work for me.
... Time Passes ...
OK, I've tried another tactic. I've tried NOT being a part of the initial conversation. My URL does NOT have "cid' in it. Instead, I use "tid". I look that value up from the SessionMap and call Manager.restoreConversation() with it. Now I get some really strange results, though.
restoreConversation() always returns true, but I do NOT always end up in the requested conversation! Every other time, I end up with a DIFFERENT conversationID (as returned by Manager.instance().getCurrentConversationId()), and my Contexts.getConversationContext().get() fails on those occasions.
So, I tried resetting it back to adding cid and clr to the original URL, and almost the same thing happened, except that restoreConversation actually returned false when it returned with a different conversation.
| INFO [DocumentResource] pathInfo=/src/0
| INFO [DocumentResource] restoreConversation to 4=true
| INFO [DocumentResource] cid=4
| INFO [DocumentResource] pathInfo=/src/0
| INFO [DocumentResource] restoreConversation to 4=false
| INFO [DocumentResource] cid=8
| INFO [DocumentResource] pathInfo=/src/0
| INFO [DocumentResource] restoreConversation to 4=true
| INFO [DocumentResource] cid=4
| INFO [DocumentResource] pathInfo=/src/0
| INFO [DocumentResource] restoreConversation to 4=false
| INFO [DocumentResource] cid=10
| INFO [DocumentResource] pathInfo=/src/0
| INFO [DocumentResource] restoreConversation to 4=true
| INFO [DocumentResource] cid=4
| INFO [DocumentResource] pathInfo=/src/0
| INFO [DocumentResource] restoreConversation to 4=false
| INFO [DocumentResource] cid=12
|
This was done by doing +Refresh in the browser (IE 6) once I got an error page. On the occasion that it succeeded, it didn't prompt me to save a file, but actually returned the binary data in the browser.
I could really use some help on preserving the Conversation Context. :-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4062223#4062223
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4062223
18Â years, 10Â months