Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[Issue #554] Removing hardcoded username and password in the project code " #559

Merged
merged 1 commit into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public static class ClientInstanceKey {
public static final String SYS = "Sys";
public static final String PID = "Pid";
public static final String IP = "Ip";
public static final String USERNAME = "";
public static final String PASSWD = "";
public static final String USERNAME = "Username";
public static final String PASSWD = "Passwd";
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

package org.apache.eventmesh.common.protocol.http.header.client;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;

import java.util.HashMap;
import java.util.Map;

public class RegRequestHeader extends Header {

private String code;
Expand All @@ -45,9 +45,9 @@ public class RegRequestHeader extends Header {

private String ip;

private String username;
private String username = "username";

private String passwd;
private String passwd = "user@123";

public static RegRequestHeader buildHeader(Map<String, Object> headerParam) {
RegRequestHeader header = new RegRequestHeader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

package org.apache.eventmesh.common.protocol.http.header.client;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;

import java.util.HashMap;
import java.util.Map;

public class SubscribeRequestHeader extends Header {

private String code;
Expand All @@ -45,9 +45,9 @@ public class SubscribeRequestHeader extends Header {

private String ip;

private String username;
private String username = "username";

private String passwd;
private String passwd = "user@123";

public static SubscribeRequestHeader buildHeader(Map<String, Object> headerParam) {
SubscribeRequestHeader header = new SubscribeRequestHeader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

package org.apache.eventmesh.common.protocol.http.header.client;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;

import java.util.HashMap;
import java.util.Map;

public class UnSubscribeRequestHeader extends Header {

private String code;
Expand All @@ -45,9 +45,9 @@ public class UnSubscribeRequestHeader extends Header {

private String ip;

private String username;
private String username = "username";

private String passwd;
private String passwd = "user@123";

public static UnSubscribeRequestHeader buildHeader(Map<String, Object> headerParam) {
UnSubscribeRequestHeader header = new UnSubscribeRequestHeader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
package org.apache.eventmesh.common.protocol.http.header.message;


import java.util.HashMap;
import java.util.Map;

import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;

import java.util.HashMap;
import java.util.Map;

public class PushMessageResponseHeader extends Header {

//response code
Expand Down Expand Up @@ -53,10 +53,10 @@ public class PushMessageResponseHeader extends Header {
private String ip;

//USERNAME of the requester
private String username;
private String username = "username";

//PASSWD of the requester
private String passwd;
private String passwd = "user@123";

public String getUsername() {
return username;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

package org.apache.eventmesh.common.protocol.http.header.message;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;

import java.util.HashMap;
import java.util.Map;

public class ReplyMessageRequestHeader extends Header {

//request code
Expand Down Expand Up @@ -54,10 +54,10 @@ public class ReplyMessageRequestHeader extends Header {
private String ip;

//USERNAME of the requester
private String username;
private String username = "username";

//PASSWD of the requester
private String passwd;
private String passwd = "user@123";

public String getUsername() {
return username;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
package org.apache.eventmesh.common.protocol.http.header.message;


import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;

import java.util.HashMap;
import java.util.Map;

public class SendMessageBatchRequestHeader extends Header {

//request code
Expand Down Expand Up @@ -55,10 +55,10 @@ public class SendMessageBatchRequestHeader extends Header {
private String ip;

//USERNAME of the requester
private String username;
private String username = "username";

//PASSWD of the requester
private String passwd;
private String passwd = "user@123";

public String getUsername() {
return username;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

package org.apache.eventmesh.common.protocol.http.header.message;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;

import java.util.HashMap;
import java.util.Map;

public class SendMessageBatchV2RequestHeader extends Header {

//request code
Expand Down Expand Up @@ -54,10 +54,10 @@ public class SendMessageBatchV2RequestHeader extends Header {
private String ip;

//USERNAME of the requester
private String username;
private String username = "username";

//PASSWD of the requester
private String passwd;
private String passwd = "user@123";

public String getUsername() {
return username;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

package org.apache.eventmesh.common.protocol.http.header.message;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;

import java.util.HashMap;
import java.util.Map;

public class SendMessageRequestHeader extends Header {

//request code
Expand Down Expand Up @@ -54,10 +54,10 @@ public class SendMessageRequestHeader extends Header {
private String ip;

//USERNAME of the requester
private String username;
private String username = "username";

//PASSWD of the requester
private String passwd;
private String passwd = "user@123";

public String getUsername() {
return username;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import static org.hamcrest.CoreMatchers.is;

public class PushMessageResponseHeaderTest {
Expand All @@ -39,5 +42,7 @@ public void testToMap() {
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.SYS), is("SYSID"));
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.PID), is("PID"));
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.IP), is("127.0.0.1"));
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.USERNAME), is("username"));
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.PASSWD), is("user@123"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public void before() {
headerParam.put(ProtocolKey.ClientInstanceKey.SYS, "SYS");
headerParam.put(ProtocolKey.ClientInstanceKey.PID, "PID");
headerParam.put(ProtocolKey.ClientInstanceKey.IP, "127.0.0.1");
headerParam.put(ProtocolKey.ClientInstanceKey.USERNAME, "username");
headerParam.put(ProtocolKey.ClientInstanceKey.PASSWD, "user@123");
header = ReplyMessageRequestHeader.buildHeader(headerParam);
}

Expand All @@ -57,5 +59,7 @@ public void testToMap() {
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.SYS), is("SYS"));
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.PID), is("PID"));
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.IP), is("127.0.0.1"));
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.USERNAME), is("username"));
Assert.assertThat(header.toMap().get(ProtocolKey.ClientInstanceKey.PASSWD), is("user@123"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public class LiteClientConfig {

private String sys;

private String userName;
private String userName = "userName";

private String password;
private String password = "password";

private boolean useTls = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@

package org.apache.eventmesh.client.http.ssl;

import org.apache.commons.lang3.StringUtils;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.security.KeyStore;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;

import org.apache.commons.lang3.StringUtils;

public class MyX509TrustManager implements X509TrustManager {
X509TrustManager myTrustManager;

public MyX509TrustManager() throws Exception {
KeyStore keyStore = KeyStore.getInstance("JKS");
String fileName = System.getProperty("ssl.client.cer", "");
String pass = System.getProperty("ssl.client.pass", "");
String fileName = System.getProperty("ssl.client.cer", "sChat2.jks");
String pass = System.getProperty("ssl.client.pass", "sNetty");
char[] filePass = null;
if (StringUtils.isNotBlank(pass)) {
filePass = pass.toCharArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public class EventMeshCommon {
/**
* Username used for EventMesh verification
*/
public static String EventMesh_USER = "";
public static String EventMesh_USER = "EventMesh";

/**
* Password used for EventMesh verification
*/
public static String EventMesh_PASS = "";
public static String EventMesh_PASS = "EventMesh@123";

/**
* Timeout time shared by the server
Expand Down