I'm working on migrating a complex application to Liberty and it uses property files that use the WAS URL resource. Is there a way, without re-writing anything in the application so that it will run in Liberty? How can I define the URL in the server.xml ?
Did you try using jndiURL like this:
<jndiURLEntry jndiName="myFirstJNDIEntry" value='"file:///myDirectory/myConfigFile.properties"' />
And access it in code like:
#Resource(name="myFirstJNDIEntry")
private URL propsURL;
It is discussed in this Redbook Microservices Best Practices for Java and in documentation JNDI URL Entry (jndiURLEntry)
Related
I have been using the Spring Framework for about 4 years now, and now Spring Boot for the last couple of months. My Spring MVC applications are usually deployed on a Java EE container such as JBoss/WildFly or WebLogic. Doing so allows me to use JNDI for things like datasources or any other sensitive data that involve secrets/passwords. That makes my app "consume" that JNDI resource based on its name.
Now with Spring Boot and especially for self-contained microservices (embedded tomcat), that information is now stored within the application (application.properties and/or in Spring Java Config classes), so versioned in Git.
That makes that information a lot more exposed to other developers, which I'm not very comfortable with. I also don't like having those details show up in SonarQube and Jenkins (through workspaces).
Question is: Are there any best practices for this specific requirement?
* UPDATE *
I see some articles here and there about the use of Jasypt, but I wonder if it's still a valid library to use since the last stable release is dated from 2014.
Thank you
You could consider using a vault. Spring supports a few of them out of the box. You can find more information here http://projects.spring.io/spring-vault/.
If you have spring cloud in your stack, then it's very easy. Use encrypt the value and put it in the application properties. Follow the instruction mentioned here.
Other way is, set the values as environmental variables and using the environmental variables in the application properties. Instructions here
I want to open access to a database using JDBC protocol, so that many people in the company can access it.
The JDBC connection string would look like jdbc:sqlserver://[serverName[\instanceName][:portNumber].
I'm wondering if there is a way to have a layer of abstraction between the client and the server. Let me explain...
For example, using REST services, we can tell people to use a URL that looks like https://servername/path/to/resource/123, which we can url-rewrite to https://my-server/my-path/resource?id=123. Implementation, location, complexity is hidden from the user, and anything can be changed transparently.
Is there something similar we can do with JDBC ? For example, can I redirect jdbc://[serverName[\instanceName][:portNumber] to jdbc:sqlserver://[my--server[\my-instance][:my-port] ?
Thanks for your help !
We can't rewrite JDBC url.
But you can use JNDI (Javax Naming Directory Interface). You must configure JNDI data source first, ex: in tomcat 6.0
Then you can use this JNDI in your application
I have been searching for an example Spring Webservice which is being protected using oauth 2.0..
Looking around I found https://github.com/spring-projects/spring-security-oauth/tree/master/samples/oauth2 but there some files seems to be missing from the project.
Two things that I am looking for is :
When user authenticates, user name and password goes to /login.do , now I can not understand how this Servlet is being configured, if its not controller. web.xml is missing.
When I try to see how beans configured then applicationContext.xml is also missing. I am not able to find those files in order to see how things are configured.
Help Required :
Should I use annotation in order to configure my web service or xml configuration. I am willing to use the latest version, and leverage advanced configurations, for better security.
I have another Single page application ( HTML5 ) , which accesses data from this spring web service, which is being hosted on Google App Engine. My ultimate objective is to create a chrome plugin of (html5) pages and use my service from there..
Please suggest a better path so that I can achieve my objectives.
Best regards,
Shashank Pratap
Apologize for late reply.
1) Regarding Oauth2.0 implementation : Since GAE does not support Servlet 3.0 therefore, developer is restricted to servlet 2.5. Therefore I found that we are restricted to 1.0.5.RELEASE. I was able to configure it successfully.
Best Practice on GAE : Rather than following this approach, I would suggest others to use Google Endpoints. As it supports oauth2.0 as well as we can develop REST API relatively quickly.
Scale ability and Response time : Since I was using Spring dependency injection along with spring security, application responded slower than the combination of Google Endpoints and Google Juice, as juice does injection just in time, where as spring prepares everything as soon as new instance starts, which created problem for me.
2) Chrome Plugin is completely different story. :-)
Please correct if I am wrong.
Thanks,
Shashank Pratap
I have a multiple spring based web applications (Spring 3) running on the same Tomcat server instance, I would like to implement single sign on with out using CAS or any other thing because I only have one domain so it would be a real over kill.
Now I found Tomcat's single sign on valve attribute but I really don't know how to use it with spring correctly, I found a question here about it but really not much there for it.
Is the tomcat's method the best one ? and if it is how to do it correctly ?
What I Have So Far:
I have developed an application that should handle the log in for all the applications and will be on tomcat's root, but I can't transfer data between my applications.
Is there a way to make this application the center one ?
I am using MySQL,Hibernate,Tomcat,Spring MVC,Spring Security
My application uses Spring Security and Spring MVC and is hosted on Glassfish 3.1.2.
I'm looking for a forum software (phpBB like) that I can integrate easily in my app.
Does anyone know some ?
I found JForum but it's a web app which needs to be installed... Maybe should I install it and copy the directory in my application?
I tried jForum, and even if it seems that the project is not continuing, it fits to my application.
To get it working with Spring, I had to use SSO (Single sign-on) by modifying jForum config.
In the file SystemGlobals.properties, I had to change property authentication.type = default to authentication.type = sso.
jForum will use the remote user of the request context.
See classes below for more informations
net.jforum.JForum
net.jforum.ControllerUtils
net.jforum.sso.RemoteUserSSO
net.jforum.sso.SSOUtils