How to use server with SAML authentication? - maven

I have server that use saml access
I want to write java application that get dependencies from this server.
I created settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>repoID</id>
<username>myuser</username>
<password>mypaswrod</password>
</server>
</servers>
<profiles>
<profile>
<id>snapshot.build</id>
<repositories>
<repository>
<id>repoID</id>
<url>my-url</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>snapshot.build</activeProfile>
</activeProfiles>
</settings>
when I tried to run mvn clean install I got error from mvn because the SAML.
The error because it the mvn didn't succeed to download the relevant dependencies.
The error from MVN "no checkssum avaliable", when I tried to open the file that was download I got html error of SAML
Does MVN support SMAL access ?

Related

How can I whitelist my private nexus on maven 3.8?

It seems like maven 3.8 has introduced some kinf of MITM attack protection, doing that it drops all the connections to the private repositories (such as nexus sonatype and so on). Here it is what happens when I try to download dependencies that are hosted into my private repository
And it stays there, waiting forever...
The private repositories are defined into the settings.xml file and everything worked perfectly (with mvn 3.6.3) until maven 3.8.
How can I put such private repositories in the "maven trusted" ones?
Here it is the settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>first-profile</id>
<repositories>
<repository>
<id>my-nexus</id>
<url>http://nexus.mycompany.com:8081/repository/dev/</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>my-nexus</id>
<username>username</username>
<password>password</password>
</server>
</servers>
<activeProfiles>
<activeProfile>first-profile</activeProfile>
</activeProfiles>
</settings>
Overriding the shipped mirror tag from /opt/maven/conf/settings.xml by placing a new variant into the user's settings.xml, only adding local repo ids to be not considered by the mirrorOf rule, worked for me.
Maven 3.8.x
<settings>
<mirrors>
<!-- a copy of /opt/maven/conf/settings.xml, so can override with exception rules -->
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>!my-repo1,!my-repo2,external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
</mirrors>
</settings>

Configuring Multiple Maven Repositories

I have a SpringBoot project that uses maven and IntelliJ IDEA Ultimate Edition (a build automation tool used primarily for Java projects)
I have this settings.xml for maven but when I do a mvn -U clean install, only goes the the first repository to find the files
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>C:/Users/sandro/.m2</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>TeamNexus1</id>
<mirrorOf>*</mirrorOf>
<name>TeamNexus1</name>
<url>http://benficiones.com:8081/nexus/content/groups/public/</url>
</mirror>
<mirror>
<id>TeamNexus2</id>
<mirrorOf>*</mirrorOf>
<name>TeamNexus2</name>
<url>http://benficiones2.com:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>p1</id>
<repositories>
<repository>
<id>TeamNexus1</id>
<name>TeamNexus1</name>
<url>http://benficiones.com:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</repository>
<repository>
<id>TeamNexus2</id>
<name>TeamNexus2</name>
<url>http://benficiones2.com:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>p1</activeProfile>
</activeProfiles>
</settings>
You defined TeamNexus1 als <mirrorOf> everything. This means that any requests, to whatever repository they go, are redirected to TeamNexus1.
This is probably not what you want.
If you want to use the two repositories in addition to MavenCentral (which is implicitly configured), you can just remove the whole <mirrors> section.

How to avoid from using the defined mirror with a different profile in Maven?

My project at work is using an Artifactory as mirror of Maven. So there is the following setting in ~/.m2/settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>artifactory</id>
<username>rx</username>
<password>67CoHEdAxq6PALFzoB</password>
</server>
</servers>
<mirrors>
<mirror>
<id>artifactory</id>
<mirrorOf>*</mirrorOf>
<url>https://dev.mycompany.com/artifactory/maven-all</url>
</mirror>
</mirrors>
</settings>
As a result, all the repositories will download dependencies or plugins from the mirror: https://dev.mycompany.com/artifactory/maven-all. However, I need to develop my own projects on the same PC without using the mirror but only the maven central repository, https://repo.maven.apache.org/maven2. So I intend to use a profile, inside which the repository has a unique id, private, then make use of <mirrorOf>*,!private</mirrorOf> to be prevented from using the Artifactory mirror. The changed settings.xml looks like this:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>artifactory</id>
<username>rx</username>
<password>67CoHEdAxq6PALFzoB</password>
</server>
</servers>
<mirrors>
<mirror>
<id>artifactory</id>
<mirrorOf>*,!private</mirrorOf>
<url>https://dev.mycompany.com/artifactory/maven-all</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>private</id>
<repositories>
<repository>
<id>private</id>
<id>https://repo.maven.apache.org/maven2/</id>
</repository>
</repositories>
</profile>
</profiles>
</settings>
Problem: when making use of the profile private to generate a project with the following command:
mvn -P private archetype:generate -DgroupId=rx.practice.servlet -DartifactId=servlet -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=fa[Clse
Maven still tries to download the plugin from the mirror, where does not contain those plugins. Anyone can explain why? and How to fix it?

kiescanner does not detect updated kjars at remote maven nexus repository

I have a spring-boot application (myapp) with drools the kie-ci module enabled (the drools version i use i the 7.13.0.Final).
I also host my kjars to a remote nexus maven repository.
KieScanner is not fully operative with remote nexus repository.
At the time of project building for first time, all the κjars are detected and downloaded in my local maven repo but when myapp is running the remote updated kjars are not detected by kiescanner.
When i manually delete the local kjars from the .m2 repository, then the latest kjars are downloaded locally and kiescanner detects them.
Seems to be more a maven issue than a drools issue.
My settings.xml maven file is the following:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<servers>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central</id>
<name>central</name>
<url>http:///XXX.XXX.X.ΧΧ:8081/repository/maven-group/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>maven-snapshots</id>
<url>http://XXX.XXX.X.ΧΧ:8081/repository/maven-snapshots/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
and i execute myapp by the following format:
java -jar -Dspring.profiles.active=myprofile target/myapp-0.0.1-SNAPSHOT.jar
How i can make myapp to detect remote nexus updated kjars dynamically?
Thank you very much for you time!

Is it possible to add MVN option in CLI?

Is it possible to add to run mvn as command with profile or Repository or other element and not from settings.xml ?
for example
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<localRepository>/home/vcap/app/.java-buildpack/tomcat/temp/maven_repo_6194547201292702175</localRepository>
<interactiveMode>false</interactiveMode>
<profiles>
<profile>
<repositories>
<repository>
<id>public.nexus</id>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</profile>
</profiles>
<activeProfiles>
<activeProfile>public.nexus</activeProfile>
</activeProfiles>
</settings>

Resources