Kerberos broken after upgrading from Java6 to Java7

后端 未结 3 1770
轻奢々
轻奢々 2021-02-05 22:17

I have a working application using the spring-security kerberos extension, running on jboss, running java 6.

I\'m in the process of upgrading my jvm from java 6 to jav

3条回答
  •  被撕碎了的回忆
    2021-02-05 22:59

    Change the keyTabLocation object to a string.

    So private String keyTabLocaiton.
    
          @Override
            public void afterPropertiesSet() throws Exception {
                Assert.notNull(this.servicePrincipal, "servicePrincipal must be specified");
                Assert.notNull(this.keyTabLocation, "keyTab must be specified");
                // if (keyTabLocation instanceof ClassPathResource) {
                // LOG.warn("Your keytab is in the classpath. This file needs special protection and shouldn't be in the classpath. JAAS may also not be able to load this file from classpath.");
                // }
                LoginConfig loginConfig = new LoginConfig(this.keyTabLocation, this.servicePrincipal,
                        this.debug);
                Set princ = new HashSet(1);
                princ.add(new KerberosPrincipal(this.servicePrincipal));
                Subject sub = new Subject(false, princ, new HashSet(), new HashSet());
                LoginContext lc = new LoginContext("", sub, null, loginConfig);
                lc.login();
                this.serviceSubject = lc.getSubject();
            }
    
    
    

    Also where the LoginConfig guy, set the isInitiator flag to true.

     public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
                HashMap options = new HashMap();
                options.put("useKeyTab", "true");
                options.put("keyTab", this.keyTabLocation);
                options.put("principal", this.servicePrincipalName);
                options.put("storeKey", "true");
                options.put("doNotPrompt", "true");
                if (this.debug) {
                    options.put("debug", "true");
                }
                options.put("isInitiator", "true");
                //options.put("isInitiator", "false");
    
                return new AppConfigurationEntry[] { new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule",
                        AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options), };
            }
    

    Hopefully this helps you fix your issue.

    提交回复
    热议问题