All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.nemerosa.ontrack.model.security.DefaultOntrackAuthenticatedUser.kt Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.model.security

import org.springframework.security.core.CredentialsContainer
import org.springframework.security.core.userdetails.UserDetails

class DefaultOntrackAuthenticatedUser(
        override val user: OntrackUser,
        val authorizedAccount: AuthorizedAccount,
        val groups: List
) : OntrackAuthenticatedUser, UserDetails by user, CredentialsContainer {

    override val account: Account = authorizedAccount.account

    override fun isGranted(fn: Class) =
            authorizedAccount.isGranted(fn) || groups.any { it.isGranted(fn) }

    override fun isGranted(projectId: Int, fn: Class) =
            authorizedAccount.isGranted(projectId, fn) || groups.any { it.isGranted(projectId, fn) }

    override fun eraseCredentials() {
        if (user is CredentialsContainer) {
            user.eraseCredentials()
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy