简体   繁体   English

MiniKdc 无法从 org.springframework.security.kerberos.test.MiniKdc 获得

[英]MiniKdc not available from org.springframework.security.kerberos.test.MiniKdc

I am trying to use "MiniKdc" in my code implementation like "MiniKdc.main(config)" but am getting error "can not resolve symbol 'MiniKdc' ".我试图在我的代码实现中使用“MiniKdc”,如“MiniKdc.main(config)”,但出现错误“无法解析符号‘MiniKdc’”。

I am following this example https://www.baeldung.com/spring-security-kerberos-integration我正在关注这个例子https://www.baeldung.com/spring-security-kerberos-integration

i have added this dependecy in my build.gradle implementation 'org.springframework.security.kerberos:spring-security-kerberos-test:1.0.1.RELEASE'我在我的 build.gradle 实现“org.springframework.security.kerberos:spring-security-kerberos-test:1.0.1.RELEASE”中添加了这个依赖

i tried to search the dependecy from maven central/repository and i can't find it.我试图从 Maven 中心/存储库中搜索依赖项,但找不到它。

here is the class i am working on, i want to be able to import Minikdc in the second import statement.这是我正在研究的课程,我希望能够在第二个导入语句中导入 Minikdc。

import org.apache.commons.io.FileUtils;
import org.springframework.security.kerberos.test.MiniKdc;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

class KerberosMiniKdc {

    private static final String KRB_WORK_DIR = ".\\spring-security-sso\\spring-security-sso-kerberos\\krb-test-workdir";

    public static void main(String[] args) throws Exception {

        String[] config = MiniKdcConfigBuilder.builder()
                .workDir(prepareWorkDir())
                .confDir("minikdc-krb5.conf")
                .keytabName("example.keytab")
                .principals("client/localhost", "HTTP/localhost")
                .build();

        MiniKdc.main(config);
    }

    private static String prepareWorkDir() throws IOException {
        Path dir = Paths.get(KRB_WORK_DIR);
        File directory = dir.normalize().toFile();

        FileUtils.deleteQuietly(directory);
        FileUtils.forceMkdir(directory);
        return dir.toString();
    }
}

is there anything am doing wrong?有什么地方做错了吗?

As of 2021, spring-security-kerberos is not well maintained .截至 2021 年, spring-security-kerberos 维护不善。

I suggest using Apache Kerby instead, either directly or via other library like Kerb4J .我建议改用Apache Kerby ,直接或通过其他库(如Kerb4J ) See an example here .请参阅此处的示例。

package com.kerb4j;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.kerby.kerberos.kerb.client.KrbConfig;
import org.apache.kerby.kerberos.kerb.server.SimpleKdcServer;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;

import java.io.File;

public class KerberosSecurityTestcase {

    private static final Log log = LogFactory.getLog(KerberosSecurityTestcase.class);
    private static int i = 10000;
    protected int kdcPort;
    private SimpleKdcServer kdc;
    private File workDir;
    private KrbConfig conf;

    @BeforeAll
    public static void debugKerberos() {
        System.setProperty("sun.security.krb5.debug", "true");
    }

    @BeforeEach
    public void startMiniKdc() throws Exception {

        kdcPort = i++;

        createTestDir();
        createMiniKdcConf();

        log.info("Starting Simple KDC server on port " + kdcPort);

        kdc = new SimpleKdcServer(workDir, conf);
        kdc.setKdcPort(kdcPort);
        kdc.setAllowUdp(false);
        kdc.init();
        kdc.start();
    }

    @AfterEach
    public void stopMiniKdc() throws Exception {
        log.info("Stopping Simple KDC server on port " + kdcPort);
        if (kdc != null) {
            kdc.stop();
            log.info("Stopped Simple KDC server on port " + kdcPort);
        }
    }

    public void createTestDir() {
        workDir = new File(System.getProperty("test.dir", "target"));
    }

    public void createMiniKdcConf() {
        conf = new KrbConfig();
    }

    public SimpleKdcServer getKdc() {
        return kdc;
    }

    public File getWorkDir() {
        return workDir;
    }

    public KrbConfig getConf() {
        return conf;
    }

}

Disclaimer: I'm the author of Kerb4J免责声明:我是Kerb4J的作者

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误没有可用的“org.springframework.security.oauth2.jwt.JwtDecoder”类型的合格bean - ERROR No qualifying bean of type 'org.springframework.security.oauth2.jwt.JwtDecoder' available 没有可用的“org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder”类型的合格bean - No qualifying bean of type 'org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder' available NoSuchBeanDefinitionException:没有可用的“org.springframework.security.config.annotation.web.builders.HttpSecurity”类型的合格 bean - NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.config.annotation.web.builders.HttpSecurity' available 没有 &#39;org.springframework.security.config.annotation.ObjectPostProcessor 类型的合格 bean<?> &#39; 当我使用 ContextHierarchy 时可用 - No qualifying bean of type 'org.springframework.security.config.annotation.ObjectPostProcessor<?>' available when I use ContextHierarchy 没有可用的“org.springframework.security.core.userdetails.UserDetailsService”类型的合格 bean: - No qualifying bean of type 'org.springframework.security.core.userdetails.UserDetailsService' available: SpringBootTest:没有可用的“org.springframework.test.web.servlet.MockMvc”类型的合格bean: - SpringBootTest : No qualifying bean of type 'org.springframework.test.web.servlet.MockMvc' available: 导入 org.springframework.security 无法解析 - The import org.springframework.security cannot be resolved 错误:org.springframework.security.authentication.InternalAuthenticationServiceException - error:org.springframework.security.authentication.InternalAuthenticationServiceException 在春季测试中,当前请求的类型不是[org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper] - Current request is not of type [org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper] in spring test 启动Jetty时出现Spring Security错误:没有可用的名为org.springframework.web.filter.DelegatingFilterProxy-1b68ddbd的bean - Spring Security Error when starting Jetty: No bean named 'org.springframework.web.filter.DelegatingFilterProxy-1b68ddbd' available
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM