Jahnvi Vyas

Ranch Hand
+ Follow
since May 03, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Jahnvi Vyas

Hi,

I have a security policy file. I am granting permissions to some files. Now even if I have given permissions explicitly it doesnt taking it and gives error. My code snippet is as follows:

.
.
.
grant codeBase "file:${jboss.server.home.dir}/deploy/jboss-ws4ee.sar/-"{
permission java.security.AllPermission;
};
.
.

The stack-trace for the same is as follows:

11:09:49,518 ERROR [MainDeployer] Could not initialise deployment: file:/C:/Java/jboss-4.0.2/server/all/deploy/jboss-ws4ee.sar/jboss-ws4ee.war
java.security.AccessControlException: access denied (java.io.FilePermission C:\Java\jboss-4.0.2\server\all\tmp\deploy\tmp17221jboss-ws4ee.war read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.SecurityManager.checkRead(SecurityManager.java:863)
at java.io.File.lastModified(File.java:771)
at org.jboss.deployment.MainDeployer.init(MainDeployer.java:866)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:765)
at org.jboss.deployment.MainDeployer.addDeployer(MainDeployer.java:360)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy37.addDeployer(Unknown Source)
at org.jboss.deployment.SubDeployerSupport.startService(SubDeployerSupport.java:111)
at org.jboss.web.AbstractWebContainer.startService(AbstractWebContainer.java:600)
at org.jboss.web.tomcat.tc5.Tomcat5.startService(Tomcat5.java:409)
at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:897)
at $Proxy0.start(Unknown Source)
at org.jboss.system.ServiceController.start(ServiceController.java:418)
at org.jboss.system.ServiceController.start(ServiceController.java:440)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy4.start(Unknown Source)
at org.jboss.deployment.SARDeployer.start(SARDeployer.java:273)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
at $Proxy8.deploy(Unknown Source)
at org.jboss.deployment.scanner.URLDeploymentScanner.deploy
....

Here I am giving all permission which in turn encapsulate FilePermission also. So this should work. But why it is bypassing this permission?

Any clues?!

Thanks.

Jahnvi
17 years ago
My file will reside on server.
17 years ago
Hi,

I want to write security policy for my JMX MBeanServer and for other MBean related things. I wrote the code for granting permission in java.policy file.

But I am not sure how much this policy file is reliable? If there is any possiblity that someone makes changes in this file, then the whole idea of securing MBeanServer and MBeans will be collapsed. Is there any way to protect this file? I was thinking of signing it. Is it proper way or there are other ways also?

Thank You.

Jahnvi
17 years ago
Hei, I got the answer.

For that we have to populate jndi.properties file and it is to be placed in src or classes folder. Additional change is in ServiceURL string we have to give /jndi/rmi. Snapshot of the changes are as follows..

=> jndi.properties

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jnp.interfaces
java.naming.provider.url=localhost

=> MBeanAgent class

private JMXServiceURL serviceURL;
...
serviceURL = new JMXServiceURL("rmi", "localhost", 0,"/jndi/rmi");
....

I am posting this solution because it may be helpful to anybody who is going through such problem, as I went through many forums and ma..ny people had same kind of problem but nobody has answer.

So, best of luck to who so ever is reading this post.

Thank you..

Jahnvi.
17 years ago
Hi,

I am managing and monitoring web based chat application in local intranet by using JMX. Part of my code is as follows :

...
mbeanServer.registerMBean(regMBean, regName);
serviceURL = new JMXServiceURL("rmi", "localhost", 0,"/jndi/jmx");
connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(
serviceURL, null, mbeanServer);
ObjectName serverName = new ObjectName(":service="+ JMXConnectorServer.class.getName() + ",protocol="
+ serviceURL.getProtocol());
mbeanServer.registerMBean(connectorServer, serverName);

=>errconnectorServer.start();
System.out.println("server started");
setStarted(true); ....

I am getting following stacktrace.

[STDOUT] java.io.IOException: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
14:43:13,095 INFO [STDOUT] at mx4j.remote.resolver.rmi.Resolver.bindServer(Resolver.java:199)
14:43:13,095 INFO [STDOUT] at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:152)
14:43:13,095 INFO [STDOUT] at com.csam.webchat.misc.WebChatMBeanAgent.startServer(WebChatMBeanAgent.java:50)
14:43:13,095 INFO [STDOUT] at org.apache.jsp.login_jsp._jspService(login_jsp.java:78)
....

Can anybody help me out??

Thank You..

Jahnvi
17 years ago
Hi,

Does anybody have idea regarding how to instrument MBeans with real application??

Uptil now I have developed one example, in which when attributes change that time notification is been raised and I simply display message. Say I have a small application based on socket programming - a simple chat server, in which client can send message to server or to other clients. Now I want to apply JMX to this. But I dont know actually how should I instrument MBeans in that..

If You have any suggestion regarding some other application also(not necessasry this chat server example), then please do post your suggestion.

Thank You..

Jahnvi
17 years ago
Hi,

I am developing EJB project using JBoss 4.0.1 application server and MS SQL Server as database server. I have created simple entity beans in my EJB project. Now for datasource I have downloaded jstl 1.2 driver and placed its jar file in JBoss\server\default\lib\ folder, still its not pointing to proper database. I have used xDoclet utility and I have pointed data source as per need properly. The stacktrace I got is as follows:

15:42:28,929 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property.)
at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:177) .....

What may be the reason for that??

Thank You..

Jahnvi..
17 years ago
Thanks Greg.

I tried that code (RSAPublicKey....) and it works. But now another problem occured. When I am signing message with this key I am getting error:

--> java.security.InvalidKeyException :No Installed provider supports this key:sun.security.rsa.RSAPrivateCrtKeyImpl

So, do I need to install it or simply if I update my jdk version(if it is the cause for the error) will give me proper result?

Thanks..

Jahnvi.
17 years ago
Sorry Ben.

I am usually using such abbrevations but I take care while posting messages on JavaRanch. But this time in hurry I made mistake.

I will take care in future.

Thanks..

Jahnvi.
17 years ago
JSP
Hi,

I am generating a KeyPair. My code is as follows:

KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA");
kpg.initialize(1024,new SecureRandom());

I am using SecureRandom() method still always it generates same key pair. So do I need to randomise it. If so then how should I do it.

Thanks..

Jahnvi.
[ November 05, 2006: Message edited by: Bear Bibeault ]
17 years ago
Hi Joe,

I know that reading/writing in blob is very easy. It can be done with setBlob and getBlob. But I want to store Public Key and Private Key in database and I want to retrive these keys as it is that is as a Key because I am using it further to sign message. And there are no ways to store key in database rather than bytes[] or Blob. I tried for Blob but when I retrive key as Blob there are no ways to further type cast or convert it into key.

So, what I want to do is... I will retrive Key from InputStream and this InputStream I will pass to ObjectInputStream. Now from here I will extract it as Object and so I can convert it as Key.

I hope now you got what actually I want to do. I tried to store and retrive these in files rather than database, that time it works. But I want to store into database.

Please, if you have any suggestion then I will be greatful.

Thanks..

Jahnvi.
17 years ago
Thanks Joe.

Even I was thinking the same thing. But I dont know how to write to a ObjectOutputStream. Let me tell you my problem in detail.

I have a byte array. I created a ObjectOutputStream and I am writing this array in OOS by using write method. But how to pass it to sql querry. Because I have to store this data to database. The field type is blob.
Do you know how can it be achieved??

Thanks..

Jahnvi.
17 years ago
Thanks Ben.

Can U just explain which kind of setting should be done in a context param??

Thanks..

Jahnvi
17 years ago
JSP