Security Exception while connecting to Oracle Database using ojdbc6.jar - java

I have replaced classes12.jar to ojdbc6.jar to connect oracle 12c database. Here I am connecting to Service name not to SID.
This works fine if I run my applet application through eclipse as java application.
But if I export the same application to a WAR file and deployed in weblogic it doesn't work.
I am encountering getting below exception.
java.security.AccessControlException: access denied
("java.util.PropertyPermission" "oracle.jdbc.RetainV9LongBindBehavior" "read")
How to solve this exception?

Related

Getting security issue while upgrading apache santuario library from 1.5.6 to 3.0.1

while updating apache santuario library we are facing below error.
java.security.AccessControlException: access denied ("java.security.SecurityPermission" "org.apache.xml.security.register")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:886)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at org.apache.xml.security.utils.JavaUtils.checkRegisterPermission(JavaUtils.java:219)
at org.apache.xml.security.utils.XMLUtils.setDsPrefix(XMLUtils.java:96)
at org.apache.xml.security.utils.ElementProxy.setNamespacePrefix(ElementProxy.java:487)
at org.apache.xml.security.utils.ElementProxy.registerDefaultPrefixes(ElementProxy.java:500)
at org.apache.xml.security.Init.dynamicInit(Init.java:121)
at org.apache.xml.security.Init.init(Init.java:92)
at org.apache.ws.security.WSSConfig.setXmlSecIgnoreLineBreak(WSSConfig.java:400)
at org.apache.ws.security.WSSConfig.init(WSSConfig.java:420)
at org.apache.ws.security.WSSConfig.getNewInstance(WSSConfig.java:455)
at org.apache.ws.security.WSSecurityEngine.getWssConfig(WSSecurityEngine.java:142)
at
we have added permission in catalina.policy as java.security.SecurityPermission "org.apache.xml.security.register" it works for us but I want to provide specific jar level permission to library.
Thanks in advance!

Can't connect to a SQL Server from Weblogic

I got the job to make run a project that usually runs at OpenShift, on WebLogic 12.1.3.0, i changed many things, make mvn build a .war, added weblogic.xml, I had to set at application.properties the connection data that is located at OpenShift's environment variables.
Now, when I deploy at WebLogic my app, I have this problem:
Login failed for user 'user'. ClientConnectionId...
and this: SQL Error: 18456, SQLState: S0001
So now I added at my springdatasource.url the integrated security;
...integratedSecurity=true;
With this last change, I got another problem at deploy, the next:
java.lang.UnsatisfiedLinkError: no sqljdbc_auth in java.library.path
and the weblogic logs:
SQL Error: 18456, SQLState: S0001
Hope anybody can help me to finally deploy the app, I set the connection data at weblogic's datasources, I tested it and worked, so I know credentials are OK.

Tomcat AccessControlException despite using AllPermission

I'm attempting to deploy a WAR to Tomcat and running into problems with the Java Security Manager. This is Tomcat 7.0.55 running Java 1.8.0, and Tomcat is started with parameters like this:
-Dcatalina.base="/path/to/apache-tomcat-7.0.55"
-Dcatalina.home="/path/to/apache-tomcat-7.0.55"
-Djava.endorsed.dirs="/path/to/apache-tomcat-7.0.55\endorsed"
-Djava.security.manager
-Djava.security.policy="/path/to/config/custom_catalina.policy"
The important thing here is that it's enabling the Java Security Manager and then pointing it at a custom security policy, which looks like this:
grant {
permission java.security.AllPermission;
};
It seems like this should result in the rather pointless configuration of activating the security manager and then telling it to just allow everything (I don't run the server so don't blame me!). However, when I deploy my WAR it fails with several stack traces containing things like:
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "java.version" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457) ~[?:1.8.0_51]
at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_51]
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) ~[?:1.8.0_51]
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1294) ~[?:1.8.0_51]
at java.lang.System.getProperty(System.java:753) ~[?:1.8.0_51]
at org.apache.commons.lang3.JavaVersion.maxVersion(JavaVersion.java:196) ~[commons-lang3-3.4.jar:3.4]
I've tried explicitly granting AllPermission to my own application with something like:
grant codeBase "file:${catalina.home}/webapps/myApp/-" {
permission java.security.AllPermission;
};
and even explicitly granting the PropertyPermission to read java.version. None of it makes any difference. The same AccessControlExceptions still get thrown and prevent deployment.
What is going on here? How can I troubleshoot this?
Ours was not coming during deployment, rather while heavy load testing.
We changed the Connector in server.xml from Nio2 to Nio and it solved problem for us
org.apache.coyote.http11.Http11NioProtocol (The first version of NIO, instead of NIO2).
We didn't disable tomcat security manager, that is against our firm's policy.

Which is the sybase driver(version) to be used in Weblogic 12c ? Where should I add the downloaded driver?

I am migrating my application from Weblogic 9 to 12c.
The connection pool - cvSybasepool created for my application is working fine on Web logic 9.
I had used com.sybase.jdbc.SybDriver to connect to Sybase database on Weblogic 9.
After replicating the connection pool(cvSybasepool) on Weblogic 12c, I get the following error:
<Jun 21, 2016 4:40:25 AM EDT> <Error> <Deployer> <BEA-149205> <Failed to initialize the application "cvSybasepool" due to error weblogic.application.ModuleException: weblogic.com
mon.resourcepool.ResourceSystemException: Cannot load driver class com.sybase.jdbc.SybDriver for datasource 'cvSybasepool'.
weblogic.application.ModuleException: weblogic.common.resourcepool.ResourceSystemException: Cannot load driver class com.sybase.jdbc.SybDriver for datasource 'cvSybasepool'.
at weblogic.jdbc.module.JDBCModule.prepare(JDBCModule.java:350)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:175)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:170)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: weblogic.common.resourcepool.ResourceSystemException: Cannot load driver class com.sybase.jdbc.SybDriver for datasource 'cvSybasepool'.
at weblogic.jdbc.common.internal.JDBCUtil.parseException(JDBCUtil.java:322)
at weblogic.jdbc.common.internal.ConnectionEnvFactory.loadDriver(ConnectionEnvFactory.java:82)
at weblogic.jdbc.common.internal.ConnectionEnvFactory.<init>(ConnectionEnvFactory.java:141)
at weblogic.jdbc.common.internal.ConnectionPool.initPooledResourceFactory(ConnectionPool.java:1110)
at weblogic.common.resourcepool.ResourcePoolImpl.start(ResourcePoolImpl.java:226)
Truncated. see log file for complete stacktrace
>
I suspect the Sybase JDBC driver jar is missing on Web logic 12c.
Also, When the Sybase driver provided by Web logic server is used, I get the following error
FILogger.log(232) - java.sql.SQLException: [FMWGEN][Sybase JDBC Driver][Sybase]A USE DATABASE statement is not allowed in a procedure or trigger. at weblogic.jdbc.sybasebase.ddcn.b(Unknown Source) at weblogic.jdbc.sybasebase.ddcn.a(Unknown Source) at weblogic.jdbc.sybasebase.ddcm.b(Unknown Source) at weblogic.jdbc.sybasebase.ddcm.a(Unknown Source)
Which driver needs to be used to connect to Sybase DB on Weblogic
12c? Jconn2.jar/Jconn3.jar?
Which jar needs to be added to Weblogic server?
Where do I need to add the jar and what configuration has be done?
I finally resolved the issue.
I could not use the sybase driver(weblogic.jdbc.sybase.SybaseDriver) bundled with weblogic as it was not complaint with my SQL code
Below are steps I followed.
Downloaded & copied JDBC driver JAR - jConnect.jar to
${WL_HOME}/server/lib/
Updated the setDomainEnv.cmd script in my domain's bin directory,
and prepended the JAR file to the PRE_CLASSPATH environment
variable(If the newly added JDBC driver JAR is required in other
domains, then edit the commEnv.cmd/sh script in WL_HOME/common/bin
and prepend your JAR file to the WEBLOGIC_CLASSPATH environment
variable.)
Restarted the server.
Update or re-create your datasource to use the sybase driver available with weblogic server 12c (weblogic.jdbc.sybase.SybaseDriver)

Java applet: connect to "maps.googleapis.com" - access denied ("java.net.SocketPermission")

I'm running a java applet embedded into a Grails application on my local. The applet should connect to the Google Maps API, but it gives me access denied.
Exception in thread "AWT-EventQueue-11" java.security.AccessControlException: access denied ("java.net.SocketPermission" "maps.googleapis.com:80" "connect,resolve")
When running the .java file in the applet viewer, the connection is fine, however when the applet is running on the tomcat server, I get access denied.
I've tried every solution I could find - granting permissions, signing the .jar file, creating and crossdomain.xml file and so on. Nothing works.
I'm running java version "1.8.0_40" on ubuntu.
You have to put the your applet inside of a jar and sign it using jarsigner

Categories