How to integrate spring-security.xml file into spring boot ? using Annotation base only - spring-mvc

I have searched and didn't find any helpful solution that's why i am going to post this question.
Actually i have spring boot project which is completely configure based upon 'Annotation'.
Now for some reason, i need to add spring-security into this project.
for that i am getting spring-security-XXX.xml file from other co-worker.
Now, i am thinking how can i wrote some Annotation which will automatically load that spring-serity-xxx.xml file into my current project environment without change any other part, so that i can achieve security feature as per spring-serity-xxx.xml file.
For example, #Configuration(classpath:spring-security-config.xml) something like, is it possible ?.
if it's possible then provide me completed list of configuration.
NOTE : security added to get OAuth integration.
Any Help Appreciate..!!

Use #ImportResource annotation.

Related

Symfony 3.3 custom config file

I've very new to Symfony. Before I've used mostly Laravel.
Lets assume I have an API Key which I want to use here and there thru the project.
It doesn't feel right to store it as a class constant because I can't find any class to keep it in. And it seems pretty dumb to have it in various places thru the app as a string.
Normally using Laravel I would have used a config file specifically for this task.
However in symfony I can't seem to do the same(either that or my google-fu skills are pretty bad). If they are, a simple link to some documentation will do just fine.
So my question is: Where can I store various constants used thru the app?
I'm sorry, but I'm afraid your Google-fu skills let you down this time.
Symfony.com has an excellent article about Configuration: Configuration -
Symfony Best Practices
The common way to save configuration parameters is by using parameters.yml. It supports environment variables as of Symfony 3.2.
The best practice for Symfony 2.x and 3.x:
Define the infrastructure-related configuration options in the
app/config/parameters.yml file.
The best practice for Symfony 4:
Define the infrastructure-related configuration options as environment
variables. During development, use the .env file at the root of your
project to set these.

liferay error on superclassing IFramePortlet

In the developing of liferay portlet, If I use IFramePortlet(com.liferay.portlet.iframe.IFramePortlet) in portlet-class tag in portlet xml
ERROR like this -
Registering portlets for gospel-for-asia-portlet
06:08:00,712
ERROR [localhost-startStop-6][PortletBagFactory:411] java.lang.ClassNotFoundException: com.liferay.portlet.iframe.IFramePortlet
(sometimes NoClassDefFoundError happens)
This error occurs on registering not building. I did add External Jars with portal-impl.jar for this.
That source is presented on github. I didn't change anything.
I am struggling with this problem for couple of days. Any clues would be welcomed.
Thank you.
You must not add portal-impl.jar to your custom portlets. This is the problem: IFramePortlet is part of portal-impl.jar, so it's part of Liferay's implementation. You don't have access to this class from a plugin. If you want it, you'll have to get the sourcecode and implement it yourself.
Adding portal-impl.jar will try to initialize all kind of portal infrastructure for a second time. Plus, you'll not want to depend on such a big library just for a tiny trivial portlet implementation.

spring based bundle in apache felix osgi

I am working one POC where I want to create plugin based web application. Main application will have all the spring mvc context. Plugins can write spring controllers but they cannot have their own spring context file. What I want is when plugin is installed all its controller is scanned (plugins controller need to be in specific package so for that package component scan will be defined in parent context) and ready to use. I am able achieve the installation part however when I am trying to access bundle/plugin controller end point through rest call I get no mapping found error.
Has anyone tried something like this? It will be great if I can get reference to some example.
Thanks!!!
If you remove the spring part, I've already done this with
a) Apache Wicket and Pax Wicket
b) Vaadin
For a) you might want to look at the Apache Karaf WebConsole.
For b) take a look at this rather "old" showcase of mine.
Both of those showcases use either standard OSGi services or Blueprint for the services (http-services) and the discovery of new "web-components" or views.

Symfony2 where to place custom helper classes

I'm starting with a Symfony2 project. I know the framework basics but I have a question:
Where is the right place to pot those helper classes I create for help or for the business logic?
Max's answer is correct. However I question the path he recommends for your code.
The following classes and files have specific emplacements:
Service Container Extensions (belong in) DependencyInjection/
from http://symfony.com/doc/current/cookbook/bundles/best_practices.html
That says your Services should be placed in a folder called 'DependencyInjection', not 'Services'. In full, it should be src/Foo/BarBundle/DependencyInjection
I say this as someone that had the former and has just finished moving them all to the latter (!)
What #Adam says is wrong, you have to store your Dependency Injection Extensions in DependecyInjection directory, not the services itself. In the documentation says that you can store your (custom) business logic classes in any place you like.
http://symfony.com/doc/current/best_practices/business-logic.html
The best way to keep the business logic is create service to handle all the logic. So it will be in:
src/Foo/BarBundle/Service
and you need to call the service in the services.yml.
I recently did some small work on an existing Symfony2 project. As described by answer from Tuong Le, I created my Helper classes under the Helper directory of the bundle and class name with Helper suffix i.e. the helper class is located at:
src/MyBundle/Helper/MyUtilHelper.php
I can use MyUtilHelper class in my bundle without calling the service container i.e. I didn't need to call.
$container->get('my_util');
I don't really know whether there is some special config. in my setup; someone already got it setup and I was just adding new functionality.
You can create the custom classes under your Bundle, such as under a folder Helper/..
However, to use those helper in your code, you'll need to define those Helper(s) in your service description file (such as services.xml)... Then you can use $container->get('your_helper')->
According to official documentation - in particular - Symfony Best Practices - you should store your services in Utils folder under the src. I belive, that this is correct way regardless of whether you want or don't wont to make the functionality provided by services of your bundle available to other parts of application via Service Container. Furthermore, you can store helper classes in any place you consider suitable. Concerning #Adam Knowles and #PachinSV answers - they are not quite right because they do not answer your question - "Where is the right place to pot those helper classes I create for help or for the business logic?" or "Where to store classes which I want to register and use via Service Container" - but not where to put bundle Extension class - which main purpose is to provide information about configuration which should be automatically loaded from your bundle to apps Service Container during the process of booting the Kernel.

404 Error using Flash Builder 4 BlazeDS wizard

My issue this time around is trying to use the new DCD BlazeDS wizard in Flash Builder 4. If I set my project up as a combined Java/Flex app I am unable to connect to the RDS servlet using the wizard. I get a 404 error every time.
I'm certain the service is set up correctly since my app can access the exposed java classes and BlazeMonster can see the exposed services.
Is anyone else having this issue and if so has anyone found a work-around? I'd very much like to use the code generation features of the wizard for my project.
Thanks as always,
Codeflayer
You also need to make sure you have the RDSDispatchServlet setup in the web.xml config file.

Resources