JaasConfigServiceImpl implements JaasConfigService { @Override public boolean isKerberos() { Object principal = configProperties.get( KERBEROS_PRINCIPAL ); Object keytab = configProperties.get( KERBEROS_KEYTAB ); return principal != null && keytab != null && !"".equals( principal ) && !"".equals( keytab ); } JaasConfigServiceImpl( Properties configProperties ); @Override String getJaasConfig(); @Override boolean isKerberos(); static final String KERBEROS_PRINCIPAL; static final String KERBEROS_KEYTAB; }
@Test public void testEmptyPrincipalIsNotKerberos() throws Exception { Properties configProperties = new Properties(); configProperties.setProperty( JaasConfigServiceImpl.KERBEROS_KEYTAB, "/user/path/file.keytab" ); JaasConfigServiceImpl service = new JaasConfigServiceImpl( configProperties ); assertFalse( service.isKerberos() ); }
@Test public void testEmptyKeytabIsNotKerberos() throws Exception { Properties configProperties = new Properties(); configProperties.setProperty( JaasConfigServiceImpl.KERBEROS_PRINCIPAL, "me@host.com" ); JaasConfigServiceImpl service = new JaasConfigServiceImpl( configProperties ); assertFalse( service.isKerberos() ); }