Cant get Spring SAML2 working - spring

I can't seem to get saml2 working. Here is what I have done.
I downloaded the sample application from here: https://github.com/spring-projects/spring-security-saml, this was a link from their documentation: http://docs.spring.io/spring-security-saml/docs/1.0.x/reference/html/chapter-quick-start.html
1) converted the sample application 'saml2-sample' into an eclispe project: mvn eclipse:eclipse
2) built the project: mvn package
3) added the 'Dynamic Web Module` facet to the project:
Right Click on project > Properties > Project Facets
4) Run the application on the STS Server:
Right Click on project > Run As > Run on Server
Server starts up and everything looks ok in the console except the url loads with HTTP Status 404 - /spring-security-saml2-sample/ at the URL http://localhost:8080/spring-security-saml2-sample/

Please, follow these steps:
Download the project from Github as archive.
Unzip the archive.
By STS/Eclipse: File > Import > Existing Maven Projects and select as root dir {your_download_folder}/spring-security-saml-master/sample folder.
Now, you may see these errors:
Fix the pom.xml as shown in this gist.
In the end, you may also fix the MetadataController class (note that some methods have changed between versions).
The easiest way is to remove that class, otherwise you should fix it manually.
Finally, run the project as webapp.
That's all!
Annotation-based configuration
If you would like to use an annotation-based configuration, you could see this one: spring-boot-security-saml-sample.

The try to change the Spring Framework dependency to latest version's like 3.2.13 or 4.0.9. I'm able to run the application successfully with both of these dependencies. Also when you're updating spring dependencies, please make sure to change xsd version to what you're using spring version "securityContext.xml" and "saml-servlet.xml".
Fyi - I've use following versions in a pom.xml file
<properties>
<junit.version>4.12</junit.version>
<jsp-api-version>2.0</jsp-api-version>
<spring.version>4.0.9.RELEASE</spring.version>
<spring.security.version>3.2.5.RELEASE</spring.security.version>
<spring-security-saml2-core-version>1.0.0.RELEASE</spring-security-saml2-core-version>
<slf4j-log4j12-version>1.7.10</slf4j-log4j12-version>
<jstl.version>1.2</jstl.version>
</properties>

Related

Springboot not recognized on IntelliJ

Even after installing Java and Maven, creating a spring project from springinitializr is facing an issue. The issue is that the project is not recognised as spring project, the annotations, import nothing are working. Can anyone please help out
I tried to redo the process, but things were same. Is any settings.xml needs to be made but I don't see it as necessity.
When opening your project in intellij. you should do so via the import > new Project and choose the pom.xml for the generated project from spring initialize. This way it can resolve dependencies and properly open your project.
if the problem persists you can go to your MainApplication.java > right click > run as spring boot project.
If it does not put the configuration on the run shortcut on the up right of the application you can configure it by adding the command : mvn spring-boot:run and add other configurations id desired.

Intellij MavenWrapperDownloader.java: Can not resolve symbol error

Setup:
Intellij IDEA community edition 2020.2
Spring Bott starter parent: 2.3.5
Java 11
WRAPPER_VERSION: 0.5.6
mvn 2
Hi,
I googled a lot e.g. here but I just can't fix it.
I created a new mvn spring project with Intellij. When I commit the project I get errors detected by code analyses in class: MavenWrapperDownloader.java.
e.g. It reports:
Cannot resolve symbol String
I tried:
invalidate caches and restart
delete .idea folder and reimport
checked sdk setup
mvn reimport
mvn clean and then rebuild (while the build is always successful)
I'm pretty new to maven. I guess the scope of the mvn package might be wrong because the build process works as expected.
UPDATE:
I reinstallt my openjdk11. No success. Then I found out that my .mvn/wrapper dir is not set as source root. I know that was never the case in my other projects. As a trial I've set my .mvn folder as source root and now the MavenWrapperDownloader.java file is recognized as a java class and the compiler interprets the symbols. But now there is another error. It says I have to define a package name for that class because the class does not have one per default. It is pretty strange to me. I also tried to use another spring boot starter version but nothing changed
When I execute Analyze->inspect code I get the following:
I had the same problem and File -> Invalidate Caches/Restart fixed it - at least for now.
IntelliJ Ultimate 2020.3
Spring Boot Starter Parent 2.4.2
Java 15
Maven 4.0.0
Maven Wrapper 0.5.6
The easiest solution is to generate your project again with Spring Starter.
After you set up everything you need at pom file -> Generate -> Download it.
Open with your IDE and copy-paste all code sources which you have already written.

Spring Boot 1.5.2 Starter Project

I am creating a simple spring boot project by going to http://start.spring.io and selecting web and actuator as dependencies. My spring boot version is 1.5.2.RELEASE. The project gets downloaded to my local machine. Then I unzip the project and import as a maven project to my workspace. I use spring STS IDE (I don't think it matters. But i just wanted to mention this). I do see errors in my project. Apparently it is a build path problem and it is complaining about spring-context-4.3.7.RELEASE.jar. I do see this jar in my maven repository and in java build path though. Anybody knows what this problem is? If I just create a spring boot application with version 1.3.8, it works without any issues and I don't see any build path problem. Am I doing something wrong or could this be a spring packaging issue?
I sometimes get similar errors when my local Maven repository is corrupted.
To fix it, close Spring Tool Suite, then go to <HOME>/.m2/ and delete the repository/ folder or just the folder you think is the culprit, like repository/org/springframework/spring-context/4.3.7.RELEASE/.
Notice that this will result in the need to download again the deleted artifacts.
After that, in you Spring Tool Suite, right-click on your project > "Maven" > "Update project..." > Make sure the right project is selected > "OK".
EDIT
There is a way in Spring Tool Suite (and eclipse I suppose) to know which artifact is corrupted: in the "Problems" view. To show it:
Windows -> Show View -> Problems
And there should be an error entry about a corrupted artifact, like the following:
Archive for required library: 'C:/Users/{username}/.m2/repository/path/to/file.jar' in project 'my-project' cannot be read or is not a valid ZIP file
The project cannot be built until build path errors are resolved
Thanks for taking time out to post this reply. I tried this prior to making my initial post. Sorry, I didn’t list down everything I tried only because I had tried everything I could think of – for hours and hours. What worked for me is changing the version to 1.5.1.RELEASE from 1.5.2.RELEASE in my pom file; and then in Spring Tool Suite, right-clicking on the project and doing a "Maven" -> "Update project"
So now I have the following in my pom file.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
I believe it has to do something with the way that spring boot team package their artifacts. This must be a bug.

Show Logback error when I run Simple Spring Boot project

I follow this tutorial to create spring boot project, when I run the project, it shows an error. Please help me to fix it.
my pom.xml
You mentioned that it worked with gradle but not Maven.
One possible solution is to delete your local maven repository to force it to redownload the dependencies:
Go to your home folder and remove the folder ~/.m2/repository.
Then, try rebuilding your project with maven : mvn clean install
I try to update Java and Maven,but it also do not work,and then I change Maven to Gradle,the application can run! Maybe Maven has problem.

How do I deploy a maven created webapp to tomcat

So I was following http://www.mkyong.com/jsf2/jsf-2-0-hello-world-example/ for a simple tutorial on how to use maven and jsf. I created a maven project by running mvn archetype:generate -Dfilter=org.apache:maven-archetype-webapp in my command prompt. Then I continued with the tutorial, I wound up creating all necessary files, but then when I got to the end, I realized I did have a server created. So I created one real quick, but when it came to the point of adding files to the server (from the add or remove dialog box), no projects or files showed up. I am not on my computer where the project is located so I can't copy/paste the .pom file in, but it looks practically exactly like the pom in the tutorial (only difference is groupId, artifact, ect.) No additional plugins, dependencies, or configs.
Do you want to deploy the webapp within Eclipse to Tomcat? Or as some sort of automatic/continuous deployment?
Within Eclipse you often need to add the Dynamic Web project and JSF facets to your project so Eclipse recognizes the project as deployment capable. If you are using m2eclipse make sure to install the m2eclipse wtp add on so this is done automatically.
If you want to add auto-deployment to the pom.xml I recommend using the maven cargo plugin: http://cargo.codehaus.org/Maven2+plugin - it supports the major containers.
For tomcat you need to modify the tomcat-users.xml to allow auto-deployment and leave the tomcat-manager application in place. If you have startet tomcat and pointing your browser to http://localhost:8080/manager/html/list it should either tell you to login or what to add to that file.
The configured user is then used in the configuration to deploy the war file via the tomcat-manager using the mvn cargo:deploy goal. The configuration has to be added to the pom.xml using war as packaging, not to the parent-pom.xml

Resources