The import org.springframework.security.cas cannot be resolved

39 views
Skip to first unread message

fasr favk

unread,
May 24, 2023, 4:46:33 PM5/24/23
to CAS Community
Hello, I'am using the latest cas server + spring security and am having this error while importing org.springframework.security.cas.*;

Error : The import org.springframework.security.cas cannot be resolved
i tried  this commands but nothing worked : 
gradle clean build
gradle clean build --refresh-dependencies  

My build.gradle code : 

import org.apache.tools.ant.taskdefs.condition.*
import org.gradle.internal.logging.text.*
import org.apereo.cas.metadata.*
import java.nio.file.*
import static org.gradle.internal.logging.text.StyledTextOutput.Style

buildscript {
    repositories {
        if (project.privateRepoUrl) {
          maven {
            url project.privateRepoUrl
            credentials {
              username = project.privateRepoUsername
              password = System.env.PRIVATE_REPO_TOKEN
            }
          }
        }
        mavenLocal()
        mavenCentral()
        gradlePluginPortal()
        maven {
            url 'https://oss.sonatype.org/content/repositories/snapshots'
            mavenContent { snapshotsOnly() }
        }
        maven {
            url "https://repo.spring.io/milestone"
            mavenContent { releasesOnly() }
        }
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${project.springBootVersion}"
        classpath "io.freefair.gradle:maven-plugin:${project.gradleFreeFairPluginVersion}"
        classpath "io.freefair.gradle:lombok-plugin:${project.gradleFreeFairPluginVersion}"
        classpath "io.spring.gradle:dependency-management-plugin:${project.gradleDependencyManagementPluginVersion}"
        classpath "com.google.cloud.tools:jib-gradle-plugin:${project.jibVersion}"
       
        classpath "de.undercouch:gradle-download-task:${project.gradleDownloadTaskVersion}"
        classpath "org.apereo.cas:cas-server-core-api-configuration-model:${project.'cas.version'}"
        classpath "org.apereo.cas:cas-server-core-configuration-metadata-repository:${project.'cas.version'}"
    }
}

repositories {
    if (project.privateRepoUrl) {
      maven {
        url project.privateRepoUrl
        credentials {
          username = project.privateRepoUsername
          password = System.env.PRIVATE_REPO_TOKEN
        }
      }
    }
    mavenLocal()
    mavenCentral()
    maven { url 'https://oss.sonatype.org/content/repositories/releases' }
    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots'
        mavenContent { snapshotsOnly() }
    }
    maven {
        url "https://repository.apache.org/content/repositories/snapshots"
        mavenContent { snapshotsOnly() }
    }
    maven {
        url 'https://build.shibboleth.net/nexus/content/repositories/releases/'
        mavenContent { releasesOnly() }
    }
    maven {
        url "https://build.shibboleth.net/nexus/content/repositories/snapshots"
        mavenContent { snapshotsOnly() }
    }
    maven {
        url "https://repo.spring.io/milestone"
        mavenContent { releasesOnly() }
    }
    maven {
        url "https://jitpack.io"
        content {
            includeGroupByRegex ".*wss4j.*"
        }
        mavenContent { releasesOnly() }
    }
}

apply plugin: "io.freefair.war-overlay"
apply plugin: "war"
apply plugin: "org.springframework.boot"
apply plugin: "io.freefair.lombok"

apply from: rootProject.file("gradle/springboot.gradle")
apply from: rootProject.file("gradle/jib.gradle")
apply from: rootProject.file("gradle/tasks.gradle")


configurations.all {
    resolutionStrategy {
        cacheChangingModulesFor 0, "seconds"
        cacheDynamicVersionsFor 0, "seconds"
        preferProjectModules()
        def failIfConflict = project.hasProperty("failOnVersionConflict") && Boolean.valueOf(project.getProperty("failOnVersionConflict"))
        if (failIfConflict) {
            failOnVersionConflict()
        }
    }
    exclude(group: "cglib", module: "cglib")
    exclude(group: "cglib", module: "cglib-full")
    exclude(group: "org.slf4j", module: "slf4j-log4j12")
    exclude(group: "org.slf4j", module: "slf4j-simple")
    exclude(group: "org.slf4j", module: "jcl-over-slf4j")
    exclude(group: "org.apache.logging.log4j", module: "log4j-to-slf4j")
}

war {
    entryCompression = ZipEntryCompression.STORED
    enabled = false
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(project.targetCompatibility)
    }
}

bootBuildImage {
    imageName = "${project.'containerImageOrg'}/${project.'containerImageName'}:${project.version}"
}

dependencies {
    /**
    * Do NOT modify the lines below or else you will risk breaking dependency management.
    */
    implementation enforcedPlatform("org.apereo.cas:cas-server-support-bom:${project.'cas.version'}")
    implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)

    implementation "org.springframework.security:spring-security-cas"
    implementation "org.springframework.security:spring-security-web"
    implementation "org.springframework.security:spring-security-config"
   

    implementation "org.apereo.cas:cas-server-core-api-configuration-model"
    implementation "org.apereo.cas:cas-server-webapp-init"

    if (project.hasProperty("casModules")) {
        def dependencies = project.getProperty("casModules").split(",")
        dependencies.each {
            def projectsToAdd = rootProject.subprojects.findAll {project ->
                project.name == "cas-server-core-${it}" || project.name == "cas-server-support-${it}"
            }
            projectsToAdd.each {implementation it}
        }
    }
    developmentOnly "org.springframework.boot:spring-boot-devtools:${project.springBootVersion}"
    testImplementation "org.springframework.boot:spring-boot-starter-test"
}

Ray Bon

unread,
May 24, 2023, 5:11:24 PM5/24/23
to cas-...@apereo.org
You should not need to import those spring-security packages.

What are you trying to accomplish with those packages?

Ray

On Wed, 2023-05-24 at 04:42 -0700, fasr favk wrote:
Notice: This message was sent from outside the University of Victoria email system. Please be cautious with links and sensitive information.

Ray Bon

unread,
May 24, 2023, 6:37:21 PM5/24/23
to favk...@gmail.com, cas-...@apereo.org
Just checked my build. Those three spring packages are already included by cas.

Are you setting up a client application or the cas overlay (authentication server)?

The gradle file looks to be from cas overlay. The only time you need to add non cas imports is if you are planning to customize cas (which should be done only after much deliberation - and then should be done on the main project).

Ray

On Wed, 2023-05-24 at 14:39 -0700, fasr favk wrote:
Notice: This message was sent from outside the University of Victoria email system. Please be cautious with links and sensitive information.

I'm trying to configure my cas authentication with spring security, so 'am creating a configuration classes where i need to import this package
Example : the public ServiceProperties serviceProperties() that needsthe package org.springframework.security.cas.ServiceProperties; to be imported.

fasr favk

unread,
May 25, 2023, 8:03:06 AM5/25/23
to CAS Community, Ray Bon
I'm trying to configure my cas authentication with spring security, so 'am creating a configuration classes where i need to import this package
Example : the public ServiceProperties serviceProperties() that needs the package org.springframework.security.cas.ServiceProperties; to be imported.

On Wednesday, May 24, 2023 at 9:11:24 PM UTC Ray Bon wrote:

fasr favk

unread,
May 25, 2023, 8:03:06 AM5/25/23
to CAS Community, Ray Bon, fasr favk
I was trying to setup my cas client application java classes inside the cas war overlay which now i think it is not possible and i need another Spring project for cas client to get work, am i wrong ? Am newbie btw.
Thanks.

Ray Bon

unread,
May 25, 2023, 12:11:32 PM5/25/23
to favk...@gmail.com, cas-...@apereo.org
Cas (cas-overlay-template) is a stand alone application that handles authentication.

For a client application, you 'front' it with some kind of authentication client. Different clients will handle different and sometimes multiple protocols: for the protocols Cas supports https://apereo.github.io/cas/6.6.x/protocol/Protocol-Overview.html

pac4j handles multiple protocols: https://www.pac4j.org/
There is shibboleth service provider: https://shibboleth.atlassian.net/wiki/spaces/SP3/overview

I am sure there are others.

Ray
Reply all
Reply to author
Forward
0 new messages