You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by si...@apache.org on 2016/01/14 18:04:07 UTC
[72/85] incubator-metron git commit: Move all com/apache folders to
org/apache
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/auth/CustomDomainADRealm.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/auth/CustomDomainADRealm.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/auth/CustomDomainADRealm.java
deleted file mode 100644
index 1ea5b0f..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/auth/CustomDomainADRealm.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.apache.metron.dataservices.auth;
-
-import javax.naming.NamingException;
-
-import org.apache.shiro.authc.AuthenticationInfo;
-import org.apache.shiro.authc.AuthenticationToken;
-import org.apache.shiro.authc.UsernamePasswordToken;
-import org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm;
-import org.apache.shiro.realm.ldap.LdapContextFactory;
-
-public class CustomDomainADRealm extends ActiveDirectoryRealm {
-
- private String customDomain;
-
- public void setCustomDomain(String customDomain) {
- this.customDomain = customDomain;
- }
-
- public String getCustomDomain() {
- return customDomain;
- }
-
- @Override
- protected AuthenticationInfo queryForAuthenticationInfo(
- AuthenticationToken token, LdapContextFactory ldapContextFactory)
- throws NamingException {
-
- UsernamePasswordToken upToken = (UsernamePasswordToken)token;
- String userName = upToken.getUsername();
- upToken.setUsername( userName + "@" + customDomain );
-
- return super.queryForAuthenticationInfo(token, ldapContextFactory);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/auth/RestSecurityInterceptor.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/auth/RestSecurityInterceptor.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/auth/RestSecurityInterceptor.java
deleted file mode 100644
index 682a9e5..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/auth/RestSecurityInterceptor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.apache.metron.dataservices.auth;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.core.Cookie;
-import javax.ws.rs.ext.Provider;
-
-import org.jboss.resteasy.core.Headers;
-import org.jboss.resteasy.core.ServerResponse;
-
-import com.google.inject.Inject;
-
-@AuthTokenFilter
-@Provider
-public class RestSecurityInterceptor implements javax.ws.rs.container.ContainerRequestFilter {
-
- private static final ServerResponse ACCESS_DENIED = new ServerResponse("Access denied for this resource", 401, new Headers<Object>());;
-
- @Inject
- private Properties configProps;
-
- @Override
- public void filter(ContainerRequestContext requestContext) throws IOException {
-
- // get our token...
- Map<String, Cookie> cookies = requestContext.getCookies();
-
- Cookie authTokenCookie = cookies.get( "authToken" );
- if( authTokenCookie == null )
- {
- requestContext.abortWith(ACCESS_DENIED );
- return;
- }
-
- String authToken = authTokenCookie.getValue();
- try {
-
- if( ! AuthToken.validateToken(configProps, authToken) )
- {
- requestContext.abortWith(ACCESS_DENIED );
- return;
- }
- }
- catch (Exception e) {
-
- e.printStackTrace();
- requestContext.abortWith(ACCESS_DENIED );
- return;
- }
-
- // if the token is good, just return...
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/common/MetronService.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/common/MetronService.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/common/MetronService.java
deleted file mode 100644
index ae296d4..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/common/MetronService.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.apache.metron.dataservices.common;
-
-public interface MetronService {
-
- //secure service that front elastic search or solr
- //and the message broker
-
- public String identify();
- public boolean init(String topicname);
- public boolean login();
-
- //standing query operations
- public boolean registerRulesFromFile();
- public boolean registerRules();
- public String viewRules();
- public boolean editRules();
- public boolean deleteRules();
-
- //register for writing to kafka topic
- public boolean registerForAlertsTopic(String topicname);
-
- //client registers for alerts
- public String receiveAlertAll();
- public String receiveAlertLast();
- public boolean disconnectFromAlertsTopic(String topicname);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/KafkaClient.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/KafkaClient.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/KafkaClient.java
deleted file mode 100644
index f142d31..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/KafkaClient.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package com.apache.metron.dataservices.kafkaclient;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import kafka.consumer.ConsumerConfig;
-import kafka.consumer.KafkaStream;
-import kafka.javaapi.consumer.ConsumerConnector;
-
-import org.eclipse.jetty.websocket.api.RemoteEndpoint;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class KafkaClient
-{
- private static final Logger logger = LoggerFactory.getLogger( KafkaClient.class );
-
- private final ConsumerConnector consumer;
- private final String topic;
- private ExecutorService executor;
- private RemoteEndpoint remote;
-
- public KafkaClient(String zooKeeper, String groupId, String topic, RemoteEndpoint remote)
- {
- this.consumer = kafka.consumer.Consumer.createJavaConsumerConnector(
- createConsumerConfig(zooKeeper, groupId ));
-
- this.topic = topic;
- this.remote = remote;
- }
-
- private static ConsumerConfig createConsumerConfig(String a_zookeeper, String a_groupId) {
- Properties props = new Properties();
- props.put("zookeeper.connect", a_zookeeper);
- props.put("group.id", a_groupId);
- props.put("zookeeper.session.timeout.ms", "1000");
- props.put("zookeeper.sync.time.ms", "1000");
- props.put("auto.commit.interval.ms", "1000");
- props.put("auto.offset.reset", "smallest");
-
- return new ConsumerConfig(props);
- }
-
- public void shutdown() {
-
- logger.info( "Client shutdown() method invoked" );
-
- if (consumer != null) {
- consumer.shutdown();
- }
-
- if (executor != null) {
- executor.shutdown();
- }
- }
-
- public void run(int a_numThreads) {
- Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
- topicCountMap.put(topic, new Integer(a_numThreads));
- Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = consumer.createMessageStreams(topicCountMap);
- List<KafkaStream<byte[], byte[]>> streams = consumerMap.get(topic);
-
- logger.debug( "streams.size = " + streams.size() );
-
- // now launch all the threads
- //
- executor = Executors.newFixedThreadPool(a_numThreads);
-
- // now create an object to consume the messages
- //
- int threadNumber = 0;
- for (final KafkaStream stream : streams) {
- executor.submit(new KafkaConsumer(this.remote, stream, threadNumber));
- threadNumber++;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/KafkaConsumer.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/KafkaConsumer.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/KafkaConsumer.java
deleted file mode 100644
index dd09dee..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/KafkaConsumer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.apache.metron.dataservices.kafkaclient;
-
-import java.io.IOException;
-
-import kafka.consumer.ConsumerIterator;
-import kafka.consumer.KafkaStream;
-
-import org.eclipse.jetty.websocket.api.RemoteEndpoint;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class KafkaConsumer implements Runnable
-{
- private static final Logger logger = LoggerFactory.getLogger( KafkaConsumer.class );
-
- private KafkaStream m_stream;
- private int m_threadNumber;
- private RemoteEndpoint remote;
-
- public KafkaConsumer( RemoteEndpoint remote, KafkaStream a_stream, int a_threadNumber)
- {
- this.m_threadNumber = a_threadNumber;
- this.m_stream = a_stream;
- this.remote = remote;
- }
-
- public void run()
- {
- logger.debug( "calling ConsumerTest.run()" );
- ConsumerIterator<byte[], byte[]> it = m_stream.iterator();
-
- while (it.hasNext())
- {
- String message = new String(it.next().message());
- try
- {
- remote.sendString( message );
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
-
- logger.debug("Shutting down Thread: " + m_threadNumber);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/poll/PollingKafkaClient.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/poll/PollingKafkaClient.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/poll/PollingKafkaClient.java
deleted file mode 100644
index 0b7acc8..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/poll/PollingKafkaClient.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package com.apache.metron.dataservices.kafkaclient.poll;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import kafka.consumer.ConsumerConfig;
-import kafka.consumer.KafkaStream;
-import kafka.javaapi.consumer.ConsumerConnector;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PollingKafkaClient
-{
- private static final Logger logger = LoggerFactory.getLogger( PollingKafkaClient.class );
-
- private final ConsumerConnector consumer;
- private final String topic;
- private ExecutorService executor;
-
- public PollingKafkaClient(String zooKeeper, String groupId, String topic)
- {
- this.consumer = kafka.consumer.Consumer.createJavaConsumerConnector(
- createConsumerConfig(zooKeeper, groupId ));
-
- this.topic = topic;
- }
-
- private static ConsumerConfig createConsumerConfig(String a_zookeeper, String a_groupId) {
- Properties props = new Properties();
- props.put("zookeeper.connect", a_zookeeper);
- props.put("group.id", a_groupId);
- props.put( "zookeeper.session.timeout.ms", "1000");
- props.put( "zookeeper.sync.time.ms", "200");
- props.put( "auto.commit.interval.ms", "200");
- props.put( "auto.offset.reset", "smallest");
- // props.put( "fetch.min.bytes", "1" );
- props.put( "consumer.timeout.ms", "1000" );
-
- return new ConsumerConfig(props);
- }
-
- public void shutdown() {
-
- logger.info( "Client shutdown() method invoked" );
-
- if (consumer != null) {
- consumer.shutdown();
- }
-
- if (executor != null) {
- executor.shutdown();
- }
- }
-
- public void run(int a_numThreads) {
-
- }
-
-
- public List fetchMessages()
- {
- List<String> messages = new ArrayList<String>();
-
- Map<String, Integer> topicCountMap = new HashMap<String, Integer>();
- topicCountMap.put(topic, new Integer(1));
- Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = consumer.createMessageStreams(topicCountMap);
- List<KafkaStream<byte[], byte[]>> streams = consumerMap.get(topic);
-
- logger.debug( "streams.size = " + streams.size() );
-
- // now launch all the threads
- //
- executor = Executors.newFixedThreadPool(1);
-
- // now create an object to consume the messages
- //
- int threadNumber = 0;
- CountDownLatch latch = new CountDownLatch( streams.size() );
-
- for (final KafkaStream stream : streams) {
- executor.submit(new PollingKafkaConsumer(messages, stream, threadNumber, latch ));
- threadNumber++;
- }
-
- try {
- latch.await();
- }
- catch (InterruptedException e) {
- // TODO: handle
- }
-
- return messages;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/poll/PollingKafkaConsumer.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/poll/PollingKafkaConsumer.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/poll/PollingKafkaConsumer.java
deleted file mode 100644
index 0c513d3..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/kafkaclient/poll/PollingKafkaConsumer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.apache.metron.dataservices.kafkaclient.poll;
-
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-import kafka.consumer.ConsumerIterator;
-import kafka.consumer.KafkaStream;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PollingKafkaConsumer implements Runnable
-{
- private static final Logger logger = LoggerFactory.getLogger( PollingKafkaConsumer.class );
-
- private KafkaStream m_stream;
- private int m_threadNumber;
- private List<String> messages;
- private CountDownLatch latch;
-
- public PollingKafkaConsumer( List<String> messages, KafkaStream a_stream, int a_threadNumber, CountDownLatch latch )
- {
- this.m_threadNumber = a_threadNumber;
- this.m_stream = a_stream;
- this.messages = messages;
- this.latch = latch;
- }
-
- public void run()
- {
- logger.warn( "calling PollingKafkaConsumer.run()" );
- ConsumerIterator<byte[], byte[]> it = m_stream.iterator();
-
- try
- {
- while (it.hasNext())
- {
- String message = new String(it.next().message());
- logger.warn( "adding message: " + message);
- messages.add(message);
- }
- }
- catch( Exception e)
- {
- logger.error( "Exception waiting on Kafka...", e );
- }
-
- latch.countDown();
-
- logger.warn("Shutting down Thread: " + m_threadNumber);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/AlertsServerModule.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/AlertsServerModule.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/AlertsServerModule.java
deleted file mode 100644
index 6396a6c..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/AlertsServerModule.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.apache.metron.dataservices.modules.guice;
-
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Provides;
-import com.google.inject.Singleton;
-import com.apache.metron.alerts.server.AlertsCacheReaper;
-import com.apache.metron.alerts.server.AlertsProcessingServer;
-import com.apache.metron.alerts.server.AlertsSearcher;
-
-public class AlertsServerModule extends AbstractModule {
-
- private static final Logger logger = LoggerFactory.getLogger( AlertsServerModule.class );
-
- private Properties configProps;
-
- public AlertsServerModule( final Properties configProps ) {
- this.configProps = configProps;
- }
-
- @Override
- protected void configure() {
- bind( AlertsProcessingServer.class).in(Singleton.class);
- bind( AlertsSearcher.class).in(Singleton.class);
- bind( AlertsCacheReaper.class ).in(Singleton.class );
- }
-
- @Provides Properties getConfigProps()
- {
- return configProps;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/DefaultServletModule.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/DefaultServletModule.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/DefaultServletModule.java
deleted file mode 100644
index 184769b..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/DefaultServletModule.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.apache.metron.dataservices.modules.guice;
-
-import java.util.Properties;
-
-import org.apache.shiro.guice.web.ShiroWebModule;
-import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Singleton;
-import com.google.inject.servlet.ServletModule;
-import com.apache.metron.dataservices.servlet.LoginServlet;
-import com.apache.metron.dataservices.servlet.LogoutServlet;
-import com.apache.metron.dataservices.websocket.KafkaMessageSenderServlet;
-import com.apache.metron.dataservices.websocket.KafkaWebSocketCreator;
-
-public class DefaultServletModule extends ServletModule {
-
- private static final Logger logger = LoggerFactory.getLogger( DefaultServletModule.class );
-
- private Properties configProps;
-
- public DefaultServletModule( final Properties configProps ) {
- this.configProps = configProps;
- }
-
- @Override
- protected void configureServlets() {
-
- ShiroWebModule.bindGuiceFilter(binder());
-
- bind( KafkaWebSocketCreator.class ).in(Singleton.class);
-
- bind( HttpServletDispatcher.class ).in(Singleton.class);
- serve( "/rest/*").with(HttpServletDispatcher.class);
-
- bind( KafkaMessageSenderServlet.class ).in(Singleton.class);
- serve( "/ws/*").with(KafkaMessageSenderServlet.class );
-
- bind( LoginServlet.class).in(Singleton.class);
- serve( "/login" ).with( LoginServlet.class );
-
- bind( LogoutServlet.class).in(Singleton.class);
- serve( "/logout" ).with( LogoutServlet.class );
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/DefaultShiroWebModule.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/DefaultShiroWebModule.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/DefaultShiroWebModule.java
deleted file mode 100644
index 6c0c8da..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/DefaultShiroWebModule.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.apache.metron.dataservices.modules.guice;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.servlet.ServletContext;
-
-import org.apache.shiro.guice.web.ShiroWebModule;
-import org.apache.shiro.web.filter.authc.LogoutFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Provides;
-import com.google.inject.name.Names;
-import com.apache.metron.dataservices.auth.CustomDomainADRealm;
-
-public class DefaultShiroWebModule extends ShiroWebModule {
-
- private static final Logger logger = LoggerFactory.getLogger( DefaultShiroWebModule.class );
-
- private Properties configProps;
-
- public DefaultShiroWebModule(final ServletContext sc) {
- super(sc);
- }
-
- public DefaultShiroWebModule(final Properties configProps, final ServletContext sc) {
- super(sc);
- this.configProps = configProps;
- }
-
- protected void configureShiroWeb() {
- bindConstant().annotatedWith(Names.named("shiro.loginUrl")).to( "/login.jsp" );
- bindRealm().to(CustomDomainADRealm.class);
- bind( LogoutFilter.class);
-
- addFilterChain("/login", ANON);
- addFilterChain("/logout", ANON);
- addFilterChain("/withsocket.jsp", AUTHC );
- addFilterChain("/withsocket2.jsp", ANON );
- }
-
- @Provides
- @javax.inject.Singleton
- CustomDomainADRealm providesRealm()
- {
-
- CustomDomainADRealm realm = new CustomDomainADRealm();
-
- String ldapUrl = configProps.getProperty("ldapUrl");
- logger.info( "got ldapurl from config: " + ldapUrl );
- realm.setUrl(ldapUrl);
-
- // String ldapAuthMechanism = configProps.getProperty( "ldapAuthMechanism", "simple" ).trim();
- // logger.info( "got ldapAuthMechanism from config: " + ldapAuthMechanism );
-
-
- String activeDirectorySystemUsername = configProps.getProperty( "activeDirectorySystemUsername" ).trim();
- logger.info( "got activeDirectorySystemUsername from config: " + activeDirectorySystemUsername );
- realm.setSystemUsername(activeDirectorySystemUsername);
-
- String activeDirectorySystemPassword = configProps.getProperty( "activeDirectorySystemPassword" ).trim();
- logger.info( "got activeDirectorySystemPassword from config: " + activeDirectorySystemPassword );
- realm.setSystemPassword(activeDirectorySystemPassword);
-
- String adDomain = configProps.getProperty( "adDomain" ).trim();
- realm.setCustomDomain( adDomain );
-
- String activeDirectoryBaseSearchDN = configProps.getProperty( "activeDirectoryBaseSearchDN" ).trim();
- logger.info( "got activeDirectoryBaseSearchDN from config: " + activeDirectoryBaseSearchDN );
- realm.setSearchBase( activeDirectoryBaseSearchDN );
-
- String groupRolesMapStr = configProps.getProperty( "groupRolesMap" );
- logger.info( "got groupRolesMapStr from config: " + groupRolesMapStr );
-
- String[] mappings = groupRolesMapStr.split( "\\|" );
-
- Map<String,String> groupRolesMap = new HashMap<String, String>();
- for( String mapping : mappings )
- {
- System.out.println( "mapping: " + mapping );
- String[] mappingParts = mapping.split(":");
- groupRolesMap.put( mappingParts[0], mappingParts[1]);
- }
-
- realm.setGroupRolesMap(groupRolesMap);
- return realm;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/RestEasyModule.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/RestEasyModule.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/RestEasyModule.java
deleted file mode 100644
index e58e694..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/RestEasyModule.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.apache.metron.dataservices.modules.guice;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.AbstractModule;
-import com.apache.metron.dataservices.auth.RestSecurityInterceptor;
-import com.apache.metron.dataservices.rest.Index;
-import com.apache.metron.pcapservice.PcapReceiverImplRestEasy;
-
-public class RestEasyModule extends AbstractModule {
-
- private static final Logger logger = LoggerFactory.getLogger( RestEasyModule.class );
-
- @Override
- protected void configure() {
-
- bind( Index.class );
- bind( PcapReceiverImplRestEasy.class );
- bind( RestSecurityInterceptor.class );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/ServiceModule.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/ServiceModule.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/ServiceModule.java
deleted file mode 100644
index 1185a47..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/modules/guice/ServiceModule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.apache.metron.dataservices.modules.guice;
-
-import javax.inject.Singleton;
-
-import org.jboss.resteasy.plugins.guice.ext.RequestScopeModule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Provides;
-import com.apache.metron.dataservices.common.MetronService;
-import com.apache.metron.services.alerts.ElasticSearch_KafkaAlertsService;
-import com.apache.metron.services.alerts.Solr_KafkaAlertsService;
-
-public class ServiceModule extends RequestScopeModule {
-
- private static final Logger logger = LoggerFactory.getLogger( ServiceModule.class );
-
- private String[] args;
-
- public ServiceModule(String[] args) {
- this.args = args;
- }
-
- @Provides
- @Singleton
- public MetronService socservice() {
- if (args.length > 0 && args[0].equals("ElasticSearch_KafkaAlertsService")) {
- return new ElasticSearch_KafkaAlertsService();
- } else {
- return new Solr_KafkaAlertsService();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/rest/Index.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/rest/Index.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/rest/Index.java
deleted file mode 100644
index 72a9c58..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/rest/Index.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.apache.metron.dataservices.rest;
-
-import java.util.List;
-import java.util.Properties;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Response;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Inject;
-import com.apache.metron.dataservices.auth.AuthTokenFilter;
-import com.apache.metron.dataservices.kafkaclient.poll.PollingKafkaClient;
-
-@Path("/")
-public class Index
-{
- private static final Logger logger = LoggerFactory.getLogger( Index.class );
-
- @Inject
- private Properties configProps;
-
- @AuthTokenFilter
- @GET
- @Path("/alerts/{groupId}")
- public Response getAlerts( @PathParam("groupId") String groupId )
- {
- String zooKeeperHost = configProps.getProperty( "kafkaZookeeperHost" );
- logger.info( "kafkaZookeeperHost: " + zooKeeperHost );
- String zooKeeperPort = configProps.getProperty( "kafkaZookeeperPort" );
- logger.info( "kafkaZookeeperPort: " + zooKeeperPort );
-
- logger.warn( "got groupId from path as: " + groupId );
-
- PollingKafkaClient client = new PollingKafkaClient( zooKeeperHost + ":" + zooKeeperPort, groupId, "test");
- List<String> messages = client.fetchMessages();
- logger.warn( "found " + messages.size() + " messages in Kafka" );
-
- String respString1 = "<html><body><h2>Messages:</h2><ul>";
- String respString2 = "</ul></body></html>";
-
- for( String msg : messages )
- {
- respString1 = respString1 + "<li>" + msg + "</li>";
- }
-
- return Response.status(200).entity( respString1 + respString2 ).build();
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/rest/RestServices.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/rest/RestServices.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/rest/RestServices.java
deleted file mode 100644
index 5c84d72..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/rest/RestServices.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.apache.metron.dataservices.rest;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.ws.rs.core.Application;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RestServices extends Application
-{
- private static final Logger logger = LoggerFactory.getLogger( RestServices.class );
-
- private static Set services = new HashSet();
-
- public RestServices()
- {
- // initialize restful services
- services.add(new Index());
- }
-
- @Override
- public Set getSingletons()
- {
- return services;
- }
-
- public static Set getServices()
- {
- return services;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/servlet/LoginServlet.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/servlet/LoginServlet.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/servlet/LoginServlet.java
deleted file mode 100644
index 0411545..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/servlet/LoginServlet.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package com.apache.metron.dataservices.servlet;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.authc.AuthenticationException;
-import org.apache.shiro.authc.ExcessiveAttemptsException;
-import org.apache.shiro.authc.IncorrectCredentialsException;
-import org.apache.shiro.authc.LockedAccountException;
-import org.apache.shiro.authc.UnknownAccountException;
-import org.apache.shiro.authc.UsernamePasswordToken;
-import org.apache.shiro.subject.Subject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Inject;
-import com.apache.metron.dataservices.auth.AuthToken;
-
-public class LoginServlet extends HttpServlet
-{
- private static final Logger logger = LoggerFactory.getLogger( LoginServlet.class );
-
- private static final long serialVersionUID = 1L;
-
- @Inject
- private Properties configProps;
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- doPost( req, resp );
- }
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- String username = req.getParameter("username" );
- String password = req.getParameter("password" );
- UsernamePasswordToken token = new UsernamePasswordToken(username, password);
-
- logger.info( "Doing login for user: " + username );
-
- Subject currentUser = SecurityUtils.getSubject();
-
- try
- {
- currentUser.login(token);
- }
- catch ( UnknownAccountException uae )
- {
- logger.warn( "Failing login with 401:", uae );
- resp.sendError(405);
- return;
- }
- catch ( IncorrectCredentialsException ice )
- {
- logger.warn( "Failing login with 401:", ice );
- resp.sendError(405);
- return;
- }
- catch ( LockedAccountException lae )
- {
- logger.warn( "Failing login with 401:", lae );
- resp.sendError(401);
- return;
- }
- catch ( ExcessiveAttemptsException eae )
- {
- logger.warn( "Failing login with 401:", eae );
- resp.sendError(401);
- return;
- }
- catch ( AuthenticationException ae )
- {
- logger.warn( "Failing login with 401:", ae );
- resp.sendError(401);
- return;
- }
-
-
- if( currentUser.hasRole("ShiroUsersRole") )
- {
- try
- {
-
- Cookie authTokenCookie = new Cookie("authToken", AuthToken.generateToken(configProps));
- resp.addCookie(authTokenCookie);
-
- // resp.setStatus(HttpServletResponse.SC_OK);
- resp.sendRedirect( "/withsocket.jsp" );
- }
- catch( Exception e )
- {
- logger.error( "Failed creating authToken cookie.", e );
- resp.sendError( 500 );
- return;
- }
- }
- else
- {
- logger.error("User does not have required role!");
- resp.sendError(401);
- return;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/servlet/LogoutServlet.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/servlet/LogoutServlet.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/servlet/LogoutServlet.java
deleted file mode 100644
index bd50340..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/servlet/LogoutServlet.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.apache.metron.dataservices.servlet;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.subject.Subject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LogoutServlet extends HttpServlet
-{
- private static final Logger logger = LoggerFactory.getLogger( LogoutServlet.class );
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- doPost( req, resp );
- }
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- logger.info( "Doing logout here..." );
-
- Subject currentUser = SecurityUtils.getSubject();
-
- currentUser.logout();
-
- Cookie authCookie = new Cookie("authToken", "Logout" );
- authCookie.setMaxAge( 0 );
- resp.addCookie(authCookie);
-
- resp.sendRedirect( "/login.jsp" );
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaMessageSenderServlet.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaMessageSenderServlet.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaMessageSenderServlet.java
deleted file mode 100644
index 9215e76..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaMessageSenderServlet.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.apache.metron.dataservices.websocket;
-
-import javax.servlet.annotation.WebServlet;
-
-import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
-import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Inject;
-
-@WebServlet(name = "Message Sender Servlet", urlPatterns = { "/messages" })
-public class KafkaMessageSenderServlet extends WebSocketServlet
-{
- private static final Logger logger = LoggerFactory.getLogger( KafkaMessageSenderServlet.class );
-
- @Inject
- private KafkaWebSocketCreator socketCreator;
-
- @Override
- public void configure(WebSocketServletFactory factory)
- {
- factory.getPolicy().setIdleTimeout(600000);
- factory.setCreator( socketCreator );
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaMessageSenderSocket.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaMessageSenderSocket.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaMessageSenderSocket.java
deleted file mode 100644
index 47db439..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaMessageSenderSocket.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package com.apache.metron.dataservices.websocket;
-
-
-import java.io.IOException;
-import java.util.Properties;
-import java.util.UUID;
-
-import org.eclipse.jetty.websocket.api.Session;
-import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
-import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
-import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
-import org.eclipse.jetty.websocket.api.annotations.WebSocket;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.apache.metron.dataservices.kafkaclient.KafkaClient;
-
-@WebSocket(maxTextMessageSize = 64 * 1024)
-public class KafkaMessageSenderSocket
-{
- private static final Logger logger = LoggerFactory.getLogger( KafkaMessageSenderSocket.class );
-
- // config Properties object for our zooKeeper URL, etc. here
- private Properties configProps;
-
- boolean authGood = false;
- int threads = 1;
- KafkaClient client;
-
-
- public KafkaMessageSenderSocket( Properties configProps, final boolean authGood )
- {
- this.configProps = configProps;
- this.authGood = authGood;
- }
-
- @OnWebSocketConnect
- public void onConnect( Session session )
- {
- logger.info( "WebSocket connected!" );
- }
-
- @OnWebSocketClose
- public void onClose( Session session, int closeCode, String closeReason )
- {
- logger.info( "WebSocket closed. Shutting down Kafka client." );
- client.shutdown();
- }
-
- @OnWebSocketMessage
- public void onMessage( Session session, String text )
- {
-
- if( !authGood )
- {
- try
- {
- session.getRemote().sendString( "Must login first" );
- }
- catch (IOException e) {
- logger.error( "Unexpected error sending to remote", e );
- }
-
- return;
- }
-
- logger.debug( "WebSocket TEXT message received: " + text );
-
- String msg = text.trim();
- if( msg.startsWith( "startMessages" ))
- {
- String zooKeeperHost = configProps.getProperty( "kafkaZookeeperHost" );
- logger.info( "kafkaZookeeperHost: " + zooKeeperHost );
- String zooKeeperPort = configProps.getProperty( "kafkaZookeeperPort" );
- logger.info( "kafkaZookeeperPort: " + zooKeeperPort );
- String groupId = null; // configProps.getProperty( "kafkaGroupId" );
- String topic = configProps.getProperty( "kafkaTopicName" );
- logger.info( "kafkaTopic: " + topic );
-
- // try to parse out a groupID. If one exists, use it. If not
- // generate a new one and return to the client.
-
- if( msg.contains( ":" ))
- {
- String[] parts = msg.split( ":" );
- groupId = parts[1];
- }
- else
- {
- groupId = UUID.randomUUID().toString();
- try
- {
- session.getRemote().sendString( "groupId:" + groupId );
- }
- catch( IOException e )
- {
- throw new RuntimeException( e );
- }
- }
-
- System.out.println( "using groupId: " + groupId );
- client = new KafkaClient(zooKeeperHost + ":" + zooKeeperPort, groupId, topic, session.getRemote() );
- client.run(threads);
- }
- else if( msg.equals( "stopMessages" ))
- {
- client.shutdown();
- }
- else
- {
- logger.error("Received invalid message from remote: " + text );
- }
- }
-
- @OnWebSocketMessage
- public void onMessage( Session session, byte[] buff, int offset, int length )
- {
- logger.info( "WebSocket BINARY message received!" );
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaWebSocketCreator.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaWebSocketCreator.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaWebSocketCreator.java
deleted file mode 100644
index 37cb156..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/dataservices/websocket/KafkaWebSocketCreator.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.apache.metron.dataservices.websocket;
-
-import java.net.HttpCookie;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
-import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
-import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Inject;
-import com.apache.metron.dataservices.auth.AuthToken;
-
-public class KafkaWebSocketCreator implements WebSocketCreator
-{
- private static final Logger logger = LoggerFactory.getLogger( KafkaWebSocketCreator.class );
-
- @Inject
- private Properties configProps;
-
- @Override
- public Object createWebSocket(ServletUpgradeRequest request, ServletUpgradeResponse response)
- {
- boolean authGood = false;
- List<HttpCookie> cookies = request.getCookies();
- for( HttpCookie cookie : cookies )
- {
- String name = cookie.getName();
- if( name!= null && name.equals( "authToken" ))
- {
- String value = cookie.getValue();
-
- try
- {
- if( value != null && AuthToken.validateToken(configProps, value))
- {
- authGood = true;
- break;
- }
- }
- catch( Exception e )
- {
- logger.error(" Exception validating authToken:", e );
- authGood = false;
- break;
- }
-
- }
- else
- {
- continue;
- }
- }
-
- return new KafkaMessageSenderSocket( configProps, authGood );
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/CellTimestampComparator.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/CellTimestampComparator.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/CellTimestampComparator.java
deleted file mode 100644
index 43a4f28..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/CellTimestampComparator.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.apache.metron.pcapservice;
-
-import java.util.Comparator;
-
-import org.apache.hadoop.hbase.Cell;
-
-/**
- * Comparator created for sorting pcaps cells based on the timestamp (asc).
- *
- * @author Sayi
- */
-public class CellTimestampComparator implements Comparator<Cell> {
-
- /*
- * (non-Javadoc)
- *
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
-
- public int compare(Cell o1, Cell o2) {
- return Long.valueOf(o1.getTimestamp()).compareTo(o2.getTimestamp());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/ConfigurationUtil.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/ConfigurationUtil.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/ConfigurationUtil.java
deleted file mode 100644
index 51f85fe..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/ConfigurationUtil.java
+++ /dev/null
@@ -1,269 +0,0 @@
-package com.apache.metron.pcapservice;
-
-import org.apache.commons.configuration.Configuration;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.springframework.util.Assert;
-
-import com.apache.metron.configuration.ConfigurationManager;
-
-
-
-/**
- * utility class for this module which loads commons configuration to fetch
- * properties from underlying resources to communicate with hbase.
- *
- * @author Sayi
- */
-public class ConfigurationUtil {
-
- /** Configuration definition file name for fetching pcaps from hbase */
- private static final String configDefFileName = "config-definition-hbase.xml";
-
- /** property configuration. */
- private static Configuration propConfiguration = null;
-
-
- /**
- * The Enum SizeUnit.
- */
- public enum SizeUnit {
-
- /** The kb. */
- KB,
- /** The mb. */
- MB
- };
-
- /** The Constant DEFAULT_HCONNECTION_RETRY_LIMIT. */
- private static final int DEFAULT_HCONNECTION_RETRY_LIMIT = 0;
-
- /**
- * Loads configuration resources
- * @return Configuration
- */
- public static Configuration getConfiguration() {
- if(propConfiguration == null){
- propConfiguration = ConfigurationManager.getConfiguration(configDefFileName);
- }
- return propConfiguration;
- }
-
- /**
- * Returns the configured default result size in bytes, if the user input is
- * null; otherwise, returns the user input after validating with the
- * configured max value. Throws IllegalArgumentException if : 1. input is
- * less than or equals to 0 OR 2. input is greater than configured
- * {hbase.scan.max.result.size} value
- *
- * @param input
- * the input
- * @return long
- */
- public static long validateMaxResultSize(String input) {
- if (input == null) {
- return getDefaultResultSize();
- }
- // validate the user input
- long value = convertToBytes(Long.parseLong(input), getResultSizeUnit());
- Assert.isTrue(
- isAllowableResultSize(value),
- "'maxResponseSize' param value must be positive and less than {hbase.scan.max.result.size} value");
- return convertToBytes(value, getResultSizeUnit());
- }
-
- /**
- * Checks if is allowable result size.
- *
- * @param input
- * the input
- * @return true, if is allowable result size
- */
- public static boolean isAllowableResultSize(long input) {
- if (input <= 0 || input > getMaxResultSize()) {
- return false;
- }
- return true;
- }
-
- /**
- * Returns the configured default result size in bytes.
- *
- * @return long
- */
- public static long getDefaultResultSize() {
- float value = ConfigurationUtil.getConfiguration().getFloat(
- "hbase.scan.default.result.size");
- return convertToBytes(value, getResultSizeUnit());
- }
-
- /**
- * Returns the configured max result size in bytes.
- *
- * @return long
- */
- public static long getMaxResultSize() {
- float value = ConfigurationUtil.getConfiguration().getFloat(
- "hbase.scan.max.result.size");
- return convertToBytes(value, getResultSizeUnit());
- }
-
- /**
- * Returns the configured max row size in bytes.
- *
- * @return long
- */
- public static long getMaxRowSize() {
- float maxRowSize = ConfigurationUtil.getConfiguration().getFloat(
- "hbase.table.max.row.size");
- return convertToBytes(maxRowSize, getRowSizeUnit());
- }
-
- /**
- * Gets the result size unit.
- *
- * @return the result size unit
- */
- public static SizeUnit getResultSizeUnit() {
- return SizeUnit.valueOf(ConfigurationUtil.getConfiguration()
- .getString("hbase.scan.result.size.unit"));
- }
-
- /**
- * Gets the row size unit.
- *
- * @return the row size unit
- */
- public static SizeUnit getRowSizeUnit() {
- return SizeUnit.valueOf(ConfigurationUtil.getConfiguration()
- .getString("hbase.table.row.size.unit"));
- }
-
- /**
- * Gets the connection retry limit.
- *
- * @return the connection retry limit
- */
- public static int getConnectionRetryLimit() {
- return ConfigurationUtil.getConfiguration().getInt(
- "hbase.hconnection.retries.number",
- DEFAULT_HCONNECTION_RETRY_LIMIT);
- }
-
- /**
- * Checks if is default include reverse traffic.
- *
- * @return true, if is default include reverse traffic
- */
- public static boolean isDefaultIncludeReverseTraffic() {
- return ConfigurationUtil.getConfiguration().getBoolean(
- "pcaps.include.reverse.traffic");
- }
-
- /**
- * Gets the table name.
- *
- * @return the table name
- */
- public static byte[] getTableName() {
- return Bytes.toBytes(ConfigurationUtil.getConfiguration().getString(
- "hbase.table.name"));
- }
-
- /**
- * Gets the column family.
- *
- * @return the column family
- */
- public static byte[] getColumnFamily() {
- return Bytes.toBytes(ConfigurationUtil.getConfiguration().getString(
- "hbase.table.column.family"));
- }
-
- /**
- * Gets the column qualifier.
- *
- * @return the column qualifier
- */
- public static byte[] getColumnQualifier() {
- return Bytes.toBytes(ConfigurationUtil.getConfiguration().getString(
- "hbase.table.column.qualifier"));
- }
-
- /**
- * Gets the max versions.
- *
- * @return the max versions
- */
- public static int getMaxVersions() {
- return ConfigurationUtil.getConfiguration().getInt(
- "hbase.table.column.maxVersions");
- }
-
- /**
- * Gets the configured tokens in rowkey.
- *
- * @return the configured tokens in rowkey
- */
- public static int getConfiguredTokensInRowkey() {
- return ConfigurationUtil.getConfiguration().getInt(
- "hbase.table.row.key.tokens");
- }
-
- /**
- * Gets the minimum tokens in inputkey.
- *
- * @return the minimum tokens in inputkey
- */
- public static int getMinimumTokensInInputkey() {
- return ConfigurationUtil.getConfiguration().getInt(
- "rest.api.input.key.min.tokens");
- }
-
- /**
- * Gets the appending token digits.
- *
- * @return the appending token digits
- */
- public static int getAppendingTokenDigits() {
- return ConfigurationUtil.getConfiguration().getInt(
- "hbase.table.row.key.token.appending.digits");
- }
-
- /**
- * Convert to bytes.
- *
- * @param value
- * the value
- * @param unit
- * the unit
- * @return the long
- */
- public static long convertToBytes(float value, SizeUnit unit) {
- if (SizeUnit.KB == unit) {
- return (long) (value * 1024);
- }
- if (SizeUnit.MB == unit) {
- return (long) (value * 1024 * 1024);
- }
- return (long) value;
- }
-
- /**
- * The main method.
- *
- * @param args
- * the arguments
- */
- public static void main(String[] args) {
- long r1 = getMaxRowSize();
- System.out.println("getMaxRowSizeInBytes = " + r1);
- long r2 = getMaxResultSize();
- System.out.println("getMaxAllowableResultSizeInBytes = " + r2);
-
- SizeUnit u1 = getRowSizeUnit();
- System.out.println("getMaxRowSizeUnit = " + u1.toString());
- SizeUnit u2 = getResultSizeUnit();
- System.out.println("getMaxAllowableResultsSizeUnit = " + u2.toString());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/HBaseConfigConstants.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/HBaseConfigConstants.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/HBaseConfigConstants.java
deleted file mode 100644
index bd3eecb..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/HBaseConfigConstants.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.apache.metron.pcapservice;
-
-/**
- * HBase configuration properties.
- *
- * @author Sayi
- */
-public class HBaseConfigConstants {
-
- /** The Constant HBASE_ZOOKEEPER_QUORUM. */
- public static final String HBASE_ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum";
-
- /** The Constant HBASE_ZOOKEEPER_CLIENT_PORT. */
- public static final String HBASE_ZOOKEEPER_CLIENT_PORT = "hbase.zookeeper.clientPort";
-
- /** The Constant HBASE_ZOOKEEPER_SESSION_TIMEOUT. */
- public static final String HBASE_ZOOKEEPER_SESSION_TIMEOUT = "zookeeper.session.timeout";
-
- /** The Constant HBASE_ZOOKEEPER_RECOVERY_RETRY. */
- public static final String HBASE_ZOOKEEPER_RECOVERY_RETRY = "zookeeper.recovery.retry";
-
- /** The Constant HBASE_CLIENT_RETRIES_NUMBER. */
- public static final String HBASE_CLIENT_RETRIES_NUMBER = "hbase.client.retries.number";
-
- /** The delimeter. */
- String delimeter = "-";
-
- /** The regex. */
- String regex = "\\-";
-
- /** The Constant PCAP_KEY_DELIMETER. */
- public static final String PCAP_KEY_DELIMETER = "-";
-
- /** The Constant START_KEY. */
- public static final String START_KEY = "startKey";
-
- /** The Constant END_KEY. */
- public static final String END_KEY = "endKey";
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/HBaseConfigurationUtil.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/HBaseConfigurationUtil.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/HBaseConfigurationUtil.java
deleted file mode 100644
index 6061a5d..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/HBaseConfigurationUtil.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/**
- *
- */
-package com.apache.metron.pcapservice;
-
-import java.io.IOException;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.client.HConnection;
-import org.apache.hadoop.hbase.client.HConnectionManager;
-import org.apache.log4j.Logger;
-import org.mortbay.log.Log;
-
-/**
- * Utility class which creates HConnection instance when the first request is
- * received and registers a shut down hook which closes the connection when the
- * JVM exits. Creates new connection to the cluster only if the existing
- * connection is closed for unknown reasons. Also creates Configuration with
- * HBase resources using configuration properties.
- *
- * @author Sayi
- *
- */
-public class HBaseConfigurationUtil {
-
- /** The Constant LOGGER. */
- private static final Logger LOGGER = Logger
- .getLogger(HBaseConfigurationUtil.class);
-
- /** Configuration which holds all HBase properties. */
- private static Configuration config;
-
- /**
- * A cluster connection which knows how to find master node and locate regions
- * on the cluster.
- */
- private static HConnection clusterConnection = null;
-
- /**
- * Creates HConnection instance when the first request is received and returns
- * the same instance for all subsequent requests if the connection is still
- * open.
- *
- * @return HConnection instance
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public static HConnection getConnection() throws IOException {
- if (!connectionAvailable()) {
- synchronized (HBaseConfigurationUtil.class) {
- createClusterConncetion();
- }
- }
- return clusterConnection;
- }
-
- /**
- * Creates the cluster conncetion.
- *
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- private static void createClusterConncetion() throws IOException {
- try {
- if (connectionAvailable()) {
- return;
- }
- clusterConnection = HConnectionManager.createConnection(read());
- addShutdownHook();
- System.out.println("Created HConnection and added shutDownHook");
- } catch (IOException e) {
- LOGGER
- .error(
- "Exception occurred while creating HConnection using HConnectionManager",
- e);
- throw e;
- }
- }
-
- /**
- * Connection available.
- *
- * @return true, if successful
- */
- private static boolean connectionAvailable() {
- if (clusterConnection == null) {
- System.out.println("clusterConnection=" + clusterConnection);
- return false;
- }
- System.out.println("clusterConnection.isClosed()="
- + clusterConnection.isClosed());
- return clusterConnection != null && !clusterConnection.isClosed();
- }
-
- /**
- * Adds the shutdown hook.
- */
- private static void addShutdownHook() {
- Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
- public void run() {
- System.out
- .println("Executing ShutdownHook HBaseConfigurationUtil : Closing HConnection");
- try {
- clusterConnection.close();
- } catch (IOException e) {
- Log.debug("Caught ignorable exception ", e);
- }
- }
- }, "HBaseConfigurationUtilShutDown"));
- }
-
- /**
- * Closes the underlying connection to cluster; ignores if any exception is
- * thrown.
- */
- public static void closeConnection() {
- if (clusterConnection != null) {
- try {
- clusterConnection.close();
- } catch (IOException e) {
- Log.debug("Caught ignorable exception ", e);
- }
- }
- }
-
- /**
- * This method creates Configuration with HBase resources using configuration
- * properties. The same Configuration object will be used to communicate with
- * all HBase tables;
- *
- * @return Configuration object
- */
- public static Configuration read() {
- if (config == null) {
- synchronized (HBaseConfigurationUtil.class) {
- if (config == null) {
- config = HBaseConfiguration.create();
-
- config.set(
- HBaseConfigConstants.HBASE_ZOOKEEPER_QUORUM,
- ConfigurationUtil.getConfiguration().getString(
- "hbase.zookeeper.quorum"));
- config.set(
- HBaseConfigConstants.HBASE_ZOOKEEPER_CLIENT_PORT,
- ConfigurationUtil.getConfiguration().getString(
- "hbase.zookeeper.clientPort"));
- config.set(
- HBaseConfigConstants.HBASE_CLIENT_RETRIES_NUMBER,
- ConfigurationUtil.getConfiguration().getString(
- "hbase.client.retries.number"));
- config.set(
- HBaseConfigConstants.HBASE_ZOOKEEPER_SESSION_TIMEOUT,
- ConfigurationUtil.getConfiguration().getString(
- "zookeeper.session.timeout"));
- config.set(
- HBaseConfigConstants.HBASE_ZOOKEEPER_RECOVERY_RETRY,
- ConfigurationUtil.getConfiguration().getString(
- "zookeeper.recovery.retry"));
- }
- }
- }
- return config;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/IPcapGetter.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/IPcapGetter.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/IPcapGetter.java
deleted file mode 100644
index 3bb10c2..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/IPcapGetter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- *
- */
-package com.apache.metron.pcapservice;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * interface to all 'keys' based pcaps fetching methods.
- *
- * @author Sayi
- */
-public interface IPcapGetter {
-
- /**
- * Gets the pcaps for the input list of keys and lastRowKey.
- *
- * @param keys
- * the list of keys for which pcaps are to be retrieved
- * @param lastRowKey
- * last row key from the previous partial response
- * @param startTime
- * the start time in system milliseconds to be used to filter the
- * pcaps. The value is set to '0' if the caller sends negative value
- * @param endTime
- * the end time in system milliseconds to be used to filter the
- * pcaps. The value is set to Long.MAX_VALUE if the caller sends
- * negative value. 'endTime' must be greater than the 'startTime'.
- * @param includeReverseTraffic
- * indicates whether or not to include pcaps from the reverse traffic
- * @param includeDuplicateLastRow
- * indicates whether or not to include the last row from the previous
- * partial response
- * @param maxResultSize
- * the max result size
- * @return PcapsResponse with all matching pcaps merged together
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public PcapsResponse getPcaps(List<String> keys, String lastRowKey,
- long startTime, long endTime, boolean includeReverseTraffic,
- boolean includeDuplicateLastRow, long maxResultSize) throws IOException;
-
- /**
- * Gets the pcaps for the input key.
- *
- * @param key
- * the key for which pcaps is to be retrieved.
- * @param startTime
- * the start time in system milliseconds to be used to filter the
- * pcaps. The value is set to '0' if the caller sends negative value
- * @param endTime
- * the end time in system milliseconds to be used to filter the
- * pcaps.The value is set to Long.MAX_VALUE if the caller sends
- * negative value. 'endTime' must be greater than the 'startTime'.
- * @param includeReverseTraffic
- * indicates whether or not to include pcaps from the reverse traffic
- * @return PcapsResponse with all matching pcaps merged together
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public PcapsResponse getPcaps(String key, long startTime, long endTime,
- boolean includeReverseTraffic) throws IOException;
-
- /**
- * Gets the pcaps for the input list of keys.
- *
- * @param keys
- * the list of keys for which pcaps are to be retrieved.
- * @return PcapsResponse with all matching pcaps merged together
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public PcapsResponse getPcaps(List<String> keys) throws IOException;
-
- /**
- * Gets the pcaps for the input key.
- *
- * @param key
- * the key for which pcaps is to be retrieved.
- * @return PcapsResponse with all matching pcaps merged together
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public PcapsResponse getPcaps(String key) throws IOException;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7c5661ea/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/IPcapScanner.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/IPcapScanner.java b/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/IPcapScanner.java
deleted file mode 100644
index 195c5d6..0000000
--- a/metron-streaming/Metron-DataServices/src/main/java/com/apache/metron/pcapservice/IPcapScanner.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.apache.metron.pcapservice;
-
-import java.io.IOException;
-
-/**
- * The Interface for all pcaps fetching methods based on key range.
- */
-public interface IPcapScanner {
-
- /**
- * Gets the pcaps for between startKey (inclusive) and endKey (exclusive).
- *
- * @param startKey
- * the start key of a key range for which pcaps is to be retrieved.
- * @param endKey
- * the end key of a key range for which pcaps is to be retrieved.
- * @param maxResponseSize
- * indicates the maximum response size in MegaBytes(MB). User needs
- * to pass positive value and must be less than 60 (MB)
- * @param startTime
- * the start time in system milliseconds to be used to filter the
- * pcaps. The value is set to '0' if the caller sends negative value
- * @param endTime
- * the end time in system milliseconds to be used to filter the
- * pcaps. The value is set Long.MAX_VALUE if the caller sends
- * negative value
- * @return byte array with all matching pcaps merged together
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public byte[] getPcaps(String startKey, String endKey, long maxResponseSize,
- long startTime, long endTime) throws IOException;
-
- /**
- * Gets the pcaps for between startKey (inclusive) and endKey (exclusive).
- *
- * @param startKey
- * the start key (inclusive) of a key range for which pcaps is to be
- * retrieved.
- * @param endKey
- * the end key (exclusive) of a key range for which pcaps is to be
- * retrieved.
- * @return byte array with all matching pcaps merged together
- * @throws IOException
- * Signals that an I/O exception has occurred.
- */
- public byte[] getPcaps(String startKey, String endKey) throws IOException;
-
-}