test_class.declarator: oneopsAuthBroker
test_class.modifier: private
test_class.original_string: private OneopsAuthBroker oneopsAuthBroker;
test_class.type: OneopsAuthBroker
test_class.var_name: oneopsAuthBroker
test_class.declarator: cmsClient
test_class.modifier: private
test_class.original_string: private CMSClient cmsClient;
test_class.type: CMSClient
test_class.var_name: cmsClient
test_class.declarator: connectionInfoSystem
test_class.modifier: private
test_class.original_string: private ConnectionInfo connectionInfoSystem;
test_class.type: ConnectionInfo
test_class.var_name: connectionInfoSystem
test_class.declarator: connectionInfoUser
test_class.modifier: private
test_class.original_string: private ConnectionInfo connectionInfoUser;
test_class.type: ConnectionInfo
test_class.var_name: connectionInfoUser
test_class.declarator: connectionBadInfo
test_class.modifier: private
test_class.original_string: private ConnectionInfo connectionBadInfo;
test_class.type: ConnectionInfo
test_class.var_name: connectionBadInfo
test_class.declarator: connectionContextSystem
test_class.modifier: private
test_class.original_string: private ConnectionContext connectionContextSystem;
test_class.type: ConnectionContext
test_class.var_name: connectionContextSystem
test_class.declarator: connectionContextMock
test_class.modifier: private
test_class.original_string: private ConnectionContext connectionContextMock;
test_class.type: ConnectionContext
test_class.var_name: connectionContextMock
test_class.declarator: consumerInfo
test_class.modifier: private
test_class.original_string: private ConsumerInfo consumerInfo;
test_class.type: ConsumerInfo
test_class.var_name: consumerInfo
test_class.declarator: activeMQDestination
test_class.modifier: private
test_class.original_string: private ActiveMQDestination  activeMQDestination;
test_class.type: ActiveMQDestination
test_class.var_name: activeMQDestination
test_class.declarator: producerInfo
test_class.modifier: private
test_class.original_string: private ProducerInfo producerInfo;
test_class.type: ProducerInfo
test_class.var_name: producerInfo
test_class.declarator: AUTH_KEY_VALUE = "blahblah"
test_class.modifier: private static final
test_class.original_string: private static final String AUTH_KEY_VALUE = "blahblah";
test_class.type: String
test_class.var_name: AUTH_KEY_VALUE
test_class.declarator: CONN_INFO_PASS_BAD = "foobarbizbat"
test_class.modifier: private static final
test_class.original_string: private static final String CONN_INFO_PASS_BAD = "foobarbizbat";
test_class.type: String
test_class.var_name: CONN_INFO_PASS_BAD
test_class.declarator: CLOUD_NAME = "stubbedCloudName"
test_class.modifier: private static final
test_class.original_string: private static final String CLOUD_NAME = "stubbedCloudName";
test_class.type: String
test_class.var_name: CLOUD_NAME
test_class.declarator: SYSTEM_CLIENT_ID = "system"
test_class.modifier: private static final
test_class.original_string: private static final String SYSTEM_CLIENT_ID = "system";
test_class.type: String
test_class.var_name: SYSTEM_CLIENT_ID
test_class.declarator: MOCK_CLIENT_ID = "stubbedClientId"
test_class.modifier: private static final
test_class.original_string: private static final String MOCK_CLIENT_ID = "stubbedClientId";
test_class.type: String
test_class.var_name: MOCK_CLIENT_ID
test_class.declarator: MOCK_REMOTE_ADDR = "stubbedRemoteAddr"
test_class.modifier: private static final
test_class.original_string: private static final String MOCK_REMOTE_ADDR = "stubbedRemoteAddr";
test_class.type: String
test_class.var_name: MOCK_REMOTE_ADDR
test_class.declarator: MOCK_PHYSICAL_NAME = "controller.response"
test_class.modifier: private static final
test_class.original_string: private static final String MOCK_PHYSICAL_NAME = "controller.response";
test_class.type: String
test_class.var_name: MOCK_PHYSICAL_NAME
test_class.declarator: MQ_PHYSICAL_NAME = "ActiveMQ.dest"
test_class.modifier: private static final
test_class.original_string: private static final String MQ_PHYSICAL_NAME = "ActiveMQ.dest";
test_class.type: String
test_class.var_name: MQ_PHYSICAL_NAME
test_class.declarator: AUTH_ATTR_KEY = "auth"
test_class.modifier: private static final
test_class.original_string: private static final String AUTH_ATTR_KEY = "auth";
test_class.type: String
test_class.var_name: AUTH_ATTR_KEY
test_class.declarator: logger = Logger.getLogger(OneopsAuthBrokerTest.class)
test_class.modifier: private static
test_class.original_string: private static Logger logger = Logger.getLogger(OneopsAuthBrokerTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.file: amq-plugin/src/test/java/com/oneops/amq/plugins/OneopsAuthBrokerTest.java
test_class.identifier: OneopsAuthBrokerTest
test_case.body: @Test(priority=3, expectedExceptions = CmsAuthException.class)
  	/** force result as if null user passed in; should throw*/
  	public void addConnectionNullUserTest() throws Exception{
  
  		ConnectionInfo connWithNullUser = mock(ConnectionInfo.class);
  		when(connWithNullUser.getClientId()).thenReturn(MOCK_CLIENT_ID);
  		when(connWithNullUser.getUserName()).thenReturn(null); // !
  		when(connWithNullUser.getPassword()).thenReturn(CONN_INFO_PASS_BAD); 
  		this.oneopsAuthBroker.addConnection(connectionContextMock, connWithNullUser);
  
  	}
test_case.class_method_signature: OneopsAuthBrokerTest.addConnectionNullUserTest()
test_case.full_signature: @Test(priority=3, expectedExceptions = CmsAuthException.class) /** force result as if null user passed in; should throw*/ public void addConnectionNullUserTest()
test_case.identifier: addConnectionNullUserTest
test_case.invocations: mock thenReturn when getClientId thenReturn when getUserName thenReturn when getPassword addConnection
test_case.modifiers: @Test(priority=3, expectedExceptions = CmsAuthException.class) /** force result as if null user passed in; should throw*/ public
test_case.parameters: ()
test_case.return: void
test_case.signature: void addConnectionNullUserTest()
focal_class.declarator: logger = Logger.getLogger(OneopsAuthBroker.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = Logger.getLogger(OneopsAuthBroker.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: SUPER_USER = "superuser"
focal_class.modifier: private static final
focal_class.original_string: private static final String SUPER_USER = "superuser";
focal_class.type: String
focal_class.var_name: SUPER_USER
focal_class.declarator: SYSTEM_USER = "system"
focal_class.modifier: private static final
focal_class.original_string: private static final String SYSTEM_USER = "system";
focal_class.type: String
focal_class.var_name: SYSTEM_USER
focal_class.declarator: QUEUE_SUFFIX = ".ind-wo"
focal_class.modifier: private static final
focal_class.original_string: private static final String QUEUE_SUFFIX = ".ind-wo";
focal_class.type: String
focal_class.var_name: QUEUE_SUFFIX
focal_class.declarator: superpass = "-"
focal_class.modifier: private
focal_class.original_string: private String superpass = "-";
focal_class.type: String
focal_class.var_name: superpass
focal_class.declarator: cmsClient
focal_class.modifier: private
focal_class.original_string: private CMSClient cmsClient;
focal_class.type: CMSClient
focal_class.var_name: cmsClient
focal_class.declarator: userMap = new HashMap<String, String>()
focal_class.modifier: private
focal_class.original_string: private Map<String, String> userMap = new HashMap<String, String>();
focal_class.type: Map<String, String>
focal_class.var_name: userMap
focal_class.file: amq-plugin/src/main/java/com/oneops/amq/plugins/OneopsAuthBroker.java
focal_class.identifier: OneopsAuthBroker
focal_class.class_method_signature: OneopsAuthBroker.OneopsAuthBroker(Broker next, CMSClient cms)
focal_class.full_signature: public  OneopsAuthBroker(Broker next, CMSClient cms)
focal_class.identifier: OneopsAuthBroker
focal_class.modifiers: public
focal_class.parameters: (Broker next, CMSClient cms)
focal_class.signature:  OneopsAuthBroker(Broker next, CMSClient cms)
focal_class.class_method_signature: OneopsAuthBroker.addConnection(ConnectionContext context, ConnectionInfo info)
focal_class.full_signature: public void addConnection(ConnectionContext context, ConnectionInfo info)
focal_class.identifier: addConnection
focal_class.modifiers: public
focal_class.parameters: (ConnectionContext context, ConnectionInfo info)
focal_class.return: void
focal_class.signature: void addConnection(ConnectionContext context, ConnectionInfo info)
focal_class.class_method_signature: OneopsAuthBroker.addConsumer(ConnectionContext context, ConsumerInfo info)
focal_class.full_signature: public Subscription addConsumer(ConnectionContext context, ConsumerInfo info)
focal_class.identifier: addConsumer
focal_class.modifiers: public
focal_class.parameters: (ConnectionContext context, ConsumerInfo info)
focal_class.return: Subscription
focal_class.signature: Subscription addConsumer(ConnectionContext context, ConsumerInfo info)
focal_class.class_method_signature: OneopsAuthBroker.addProducer(ConnectionContext context, ProducerInfo info)
focal_class.full_signature: public void addProducer(ConnectionContext context, ProducerInfo info)
focal_class.identifier: addProducer
focal_class.modifiers: public
focal_class.parameters: (ConnectionContext context, ProducerInfo info)
focal_class.return: void
focal_class.signature: void addProducer(ConnectionContext context, ProducerInfo info)
focal_class.superclass: extends BrokerFilter
focal_method.body: public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
          String clientId = info.getClientId();
          String usr = info.getUserName();
          String pass = info.getPassword();
  
          logger.info("Add new connection { Remote Address: " + context.getConnection().getRemoteAddress()
                  + ", User: " + usr + ", ClientID: " + clientId + "  } ");
  
          if (usr != null && pass != null) {
              if (SYSTEM_USER.equals(usr) || (SUPER_USER.equals(usr) && superpass.equals(pass))) {
                  userMap.put(clientId, "*");
              } else {
                  String[] parts = usr.split(":");
                  if (parts.length > 1) {
                      String ns = parts[0];/*"/public/packer/providers"*/
                      String cloudName = parts[1]; /*"ec2.us-east-1a"*/
                      CmsCISimple cloud = cmsClient.getCloudCi(ns, cloudName);
                      if (cloud != null) {
                          String authkey = cloud.getCiAttributes().get("auth");
                          if (authkey.equals(pass)) {
                              String queueName = (ns.replaceAll("/", ".") + "." + cloudName + QUEUE_SUFFIX).substring(1);
                              userMap.put(clientId, queueName);
                          } else {
                              logger.error("Got bad password for cloud " + cloudName + ", NsPath: " + ns);
                              throw new CmsAuthException("Bad password for user: " + usr);
                          }
  
                      } else {
                          logger.error("Got null cloud object for user: " + usr);
                          throw new CmsAuthException("Bad user/pass combination");
                      }
                  } else {
                      throw new CmsAuthException("Bad user/pass combination");
                  }
              }
          } else {
              logger.error("Got null user/pass");
              throw new CmsAuthException("Got null user/pass");
          }
          super.addConnection(context, info);
      }
focal_method.class_method_signature: OneopsAuthBroker.addConnection(ConnectionContext context, ConnectionInfo info)
focal_method.full_signature: public void addConnection(ConnectionContext context, ConnectionInfo info)
focal_method.identifier: addConnection
focal_method.invocations: getClientId getUserName getPassword info getRemoteAddress getConnection equals equals equals put split getCloudCi get getCiAttributes equals substring replaceAll put error error error addConnection
focal_method.modifiers: public
focal_method.parameters: (ConnectionContext context, ConnectionInfo info)
focal_method.return: void
focal_method.signature: void addConnection(ConnectionContext context, ConnectionInfo info)