UsernamePasswordCredentials extends AbstractDeviceCredentials { public static final UsernamePasswordCredentials create(final String username, final String password) { Objects.requireNonNull(username); Objects.requireNonNull(password); final String[] userComponents = username.split("@", 2); if (userComponents.length != 2) { LOG.trace("username [{}] does not comply with expected pattern [<authId>@<tenantId>]", username); return null; } final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(userComponents[1], userComponents[0]); credentials.password = password; return credentials; } private  UsernamePasswordCredentials(final String tenantId, final String authId); static final UsernamePasswordCredentials create(final String username, final String password); @Override final String getType(); final String getPassword();  }
@Test public void testTenantFromUserMultiTenantWrongUsername() { final UsernamePasswordCredentials mqttUserNamePassword = UsernamePasswordCredentials.create(TEST_USER, TEST_PASSWORD); assertNull(mqttUserNamePassword); }
@Test public void testTenantFromUserMultiTenantWrongUsernameStructure() { final UsernamePasswordCredentials mqttUserNamePassword = UsernamePasswordCredentials.create("user/tenant", TEST_PASSWORD); assertNull(mqttUserNamePassword); }