3

Our company is planning on migrating to authenticating with SAML, so I am doing the tutorial using a sample demo to understand how to implement saml using the spring framework and Okta. I am following the tutorial (here: https://www.youtube.com/watch?v=JBtyGfrz-jA), but when I get to the part implementing the SecurityConfiguration (~5:09 of the video), it throws an error with the code:

import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;

When I try building the project it throws:

com/example/SecurityConfiguration.java:[3,67] package org.springframework.security.extensions.saml2.config does not exist
com/example/SecurityConfiguration.java:[3,1] static import only from classes and interfaces
com/example/SecurityConfiguration.java:[39,20] cannot find symbol

I think the problem is with maven importing the wrong jar file, but I've tried many different versions of org.springframework.security.extensions, but none allows the SecurityConfiguration.java to find the saml() method.

Here is the pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.security.extensions</groupId>
            <artifactId>spring-security-saml-dsl</artifactId>
            <version>1.0.0.M3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/libs-milestone</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>
Al H
  • 31
  • 2
  • can you try with the artifactId spring-security-saml2-core instead of DSL for the extensions? Please see. http://docs.spring.io/autorepo/docs/spring-security-saml/current/reference/htmlsingle/#section-dependencies – OTM Jul 17 '17 at 17:44
  • I just tried it with spring-security-saml2-core 1.0.2.Release, and it is still giving me `com/example/SecurityConfiguration.java:[3,67] package org.springframework.security.extensions.saml2.config does not exist`. I think the java code cannot find the org.springframework.security.extensions from the maven dependencies, even when I try rebuilding the project in netbeans. – Al H Jul 17 '17 at 20:25
  • Your class needs to have a package name. can you pls chk ? – OTM Jul 18 '17 at 04:58

1 Answers1

0

Spring screwed up their project file when moving spring-security-saml-dsl (note: not spring-security-saml2-core) from 1.0.2.RELEASE to 1.0.3.RELEASE.

The issue should be fixed after changing the version of spring-security-saml-dsl to 1.0.2.RELEASE.

Bill Lam
  • 464
  • 4
  • 6