org.springframework.security.kerberos.authentication.KerberosAuthenticationProvider Java Examples

The following examples show how to use org.springframework.security.kerberos.authentication.KerberosAuthenticationProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KerberosProvider.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
@Override
public final void onConfigured(final LoginIdentityProviderConfigurationContext configurationContext) throws ProviderCreationException {
    final String rawExpiration = configurationContext.getProperty("Authentication Expiration");
    if (StringUtils.isBlank(rawExpiration)) {
        throw new ProviderCreationException("The Authentication Expiration must be specified.");
    }

    try {
        expiration = FormatUtils.getTimeDuration(rawExpiration, TimeUnit.MILLISECONDS);
    } catch (final IllegalArgumentException iae) {
        throw new ProviderCreationException(String.format("The Expiration Duration '%s' is not a valid time duration", rawExpiration));
    }

    provider = new KerberosAuthenticationProvider();
    SunJaasKerberosClient client = new SunJaasKerberosClient();
    client.setDebug(true);
    provider.setKerberosClient(client);
    provider.setUserDetailsService(new KerberosUserDetailsService());
}
 
Example #2
Source File: KerberosBasicAuthenticationHandler.java    From registry with Apache License 2.0 6 votes vote down vote up
@Override
public void init(Properties config) throws ServletException {
    spnegoEnabled = Boolean.parseBoolean(config.getProperty(SPNEGO_ENABLED_CONFIG, Boolean.TRUE.toString()));
    if (spnegoEnabled) {
        super.init(config);
    }

    try {
        provider = new KerberosAuthenticationProvider();
        SunJaasKerberosClient client = new SunJaasKerberosClient();
        if (LOG.isDebugEnabled()) {
            client.setDebug(true);
        }
        provider.setKerberosClient(client);
        provider.setUserDetailsService(new KerberosUserDetailsService());
    } catch (Exception ex) {
        LOG.error("Failed to initialize the Kerberos Login Authentication Handler.", ex);
        throw new ServletException(ex);
    }
}
 
Example #3
Source File: KerberosProvider.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public final void onConfigured(final LoginIdentityProviderConfigurationContext configurationContext) throws ProviderCreationException {
    final String rawExpiration = configurationContext.getProperty("Authentication Expiration");
    if (StringUtils.isBlank(rawExpiration)) {
        throw new ProviderCreationException("The Authentication Expiration must be specified.");
    }

    try {
        expiration = Double.valueOf(FormatUtils.getPreciseTimeDuration(rawExpiration, TimeUnit.MILLISECONDS)).longValue();
    } catch (final IllegalArgumentException iae) {
        throw new ProviderCreationException(String.format("The Expiration Duration '%s' is not a valid time duration", rawExpiration));
    }

    defaultRealm = configurationContext.getProperty("Default Realm");
    if (StringUtils.isNotBlank(defaultRealm) && defaultRealm.contains("@")) {
        throw new ProviderCreationException(String.format("The Default Realm '%s' must not contain \"@\"", defaultRealm));
    }

    provider = new KerberosAuthenticationProvider();
    SunJaasKerberosClient client = new SunJaasKerberosClient();
    client.setDebug(true);
    provider.setKerberosClient(client);
    provider.setUserDetailsService(new KerberosUserDetailsService());
}
 
Example #4
Source File: WebSecurityConfig.java    From Hacktoberfest2019 with Apache License 2.0 5 votes vote down vote up
@Bean
public KerberosAuthenticationProvider kerberosAuthenticationProvider() {
    KerberosAuthenticationProvider provider = new KerberosAuthenticationProvider();
    SunJaasKerberosClient client = new SunJaasKerberosClient();
    client.setDebug(true);
    provider.setKerberosClient(client);
    provider.setUserDetailsService(dummyUserDetailsService());
    return provider;
}
 
Example #5
Source File: InsightsSecurityConfigurationAdapterKerberos.java    From Insights with Apache License 2.0 5 votes vote down vote up
/**
 * Used to configure kerberos Authentication Provider
 * 
 * @return
 */
@Bean
@Conditional(InsightsKerberosBeanInitializationCondition.class)
public KerberosAuthenticationProvider kerberosAuthenticationProvider() {
	KerberosAuthenticationProvider provider = new KerberosAuthenticationProvider();
	SunJaasKerberosClient client = new SunJaasKerberosClient();
	client.setDebug(true);
	provider.setKerberosClient(client);
	provider.setUserDetailsService(kerberosUserDetailsService());
	return provider;
}
 
Example #6
Source File: KerberosIdentityProvider.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
@Override
public void onConfigured(IdentityProviderConfigurationContext configurationContext) throws SecurityProviderCreationException {

    String rawDebug = configurationContext.getProperty("Enable Debug");
    boolean enableDebug = (rawDebug != null && rawDebug.equalsIgnoreCase("true"));

    String rawExpiration = configurationContext.getProperty("Authentication Expiration");
    if (StringUtils.isBlank(rawExpiration)) {
        rawExpiration = default_expiration;
        logger.info("No Authentication Expiration specified, defaulting to " + default_expiration);
    }

    try {
        expiration = FormatUtils.getTimeDuration(rawExpiration, TimeUnit.MILLISECONDS);
    } catch (final IllegalArgumentException iae) {
        throw new SecurityProviderCreationException(
                String.format("The Expiration Duration '%s' is not a valid time duration", rawExpiration));
    }

    defaultRealm = configurationContext.getProperty("Default Realm");
    if (StringUtils.isNotBlank(defaultRealm) && defaultRealm.contains("@")) {
        throw new SecurityProviderCreationException(String.format("The Default Realm '%s' must not contain \"@\"", defaultRealm));
    }

    provider = new KerberosAuthenticationProvider();
    SunJaasKerberosClient client = new SunJaasKerberosClient();
    client.setDebug(enableDebug);
    provider.setKerberosClient(client);
    provider.setUserDetailsService(new KerberosUserDetailsService());

}
 
Example #7
Source File: WebSecurityConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public KerberosAuthenticationProvider kerberosAuthenticationProvider() {
    KerberosAuthenticationProvider provider = new KerberosAuthenticationProvider();
    SunJaasKerberosClient client = new SunJaasKerberosClient();
    client.setDebug(true);
    provider.setKerberosClient(client);
    provider.setUserDetailsService(dummyUserDetailsService());
    return provider;
}
 
Example #8
Source File: WebSecurityConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public KerberosAuthenticationProvider kerberosAuthenticationProvider() {
	KerberosAuthenticationProvider provider = new KerberosAuthenticationProvider();
	SunJaasKerberosClient client = new SunJaasKerberosClient();
	client.setDebug(true);
	provider.setKerberosClient(client);
	provider.setUserDetailsService(dummyUserDetailsService());
	return provider;
}