Search in sources :

Example 1 with UserSettingsClient

use of org.apache.metron.hbase.client.UserSettingsClient in project metron by apache.

the class HBaseConfig method userSettingsClient.

@Bean()
public UserSettingsClient userSettingsClient() {
    UserSettingsClient userSettingsClient = new UserSettingsClient();
    userSettingsClient.init(() -> {
        try {
            return globalConfigService.get();
        } catch (RestException e) {
            throw new IllegalStateException("Unable to retrieve the global config.", e);
        }
    }, new HTableProvider());
    return userSettingsClient;
}
Also used : HTableProvider(org.apache.metron.hbase.HTableProvider) UserSettingsClient(org.apache.metron.hbase.client.UserSettingsClient) RestException(org.apache.metron.rest.RestException) Bean(org.springframework.context.annotation.Bean)

Example 2 with UserSettingsClient

use of org.apache.metron.hbase.client.UserSettingsClient in project metron by apache.

the class AlertsUIServiceImplTest method setUp.

@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
    kafkaService = mock(KafkaService.class);
    environment = mock(Environment.class);
    userSettingsClient = mock(UserSettingsClient.class);
    alertsUIService = new AlertsUIServiceImpl(kafkaService, environment, userSettingsClient);
    // assume user1 is logged in for tests
    Authentication authentication = Mockito.mock(Authentication.class);
    UserDetails userDetails = Mockito.mock(UserDetails.class);
    when(authentication.getPrincipal()).thenReturn(userDetails);
    when(userDetails.getUsername()).thenReturn(user1);
    SecurityContextHolder.getContext().setAuthentication(authentication);
}
Also used : KafkaService(org.apache.metron.rest.service.KafkaService) UserDetails(org.springframework.security.core.userdetails.UserDetails) UserSettingsClient(org.apache.metron.hbase.client.UserSettingsClient) Authentication(org.springframework.security.core.Authentication) Environment(org.springframework.core.env.Environment) Before(org.junit.Before)

Aggregations

UserSettingsClient (org.apache.metron.hbase.client.UserSettingsClient)2 HTableProvider (org.apache.metron.hbase.HTableProvider)1 RestException (org.apache.metron.rest.RestException)1 KafkaService (org.apache.metron.rest.service.KafkaService)1 Before (org.junit.Before)1 Bean (org.springframework.context.annotation.Bean)1 Environment (org.springframework.core.env.Environment)1 Authentication (org.springframework.security.core.Authentication)1 UserDetails (org.springframework.security.core.userdetails.UserDetails)1