Skip to content

Commit

Permalink
Revert "[Issue apache#554] Removing hardcoded username and password i…
Browse files Browse the repository at this point in the history
…n the project code (apache#555)" (apache#559)

This reverts commit e2adda8.
  • Loading branch information
xwm1992 committed Dec 27, 2021
1 parent 37fbff2 commit e130143
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 54 deletions.
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

0 comments on commit e130143

Please sign in to comment.