Browse Source

Merge branch 'fbp/release' of ssh://code.fineres.com:7999/~vito/c-design into fbp/release

fbp/release
vito 3 months ago
parent
commit
3b5a9dc270
  1. 26
      designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java
  2. 10
      designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java
  3. 3
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

26
designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java

@ -4,11 +4,13 @@ import com.fanruan.carina.Carina;
import com.fanruan.config.realm.ConfigRepositoryFactory;
import com.fanruan.config.realm.local.LocalConfigRepositoryBuilder;
import com.fr.design.ConfigHelper;
import com.fr.design.env.RemoteWorkspace;
import com.fr.design.mem.MemConfigBackupManager;
import com.fr.design.mem.MemConfigRepositoryBuilder;
import com.fr.log.FineLoggerFactory;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.server.repository.connect.FineWorkspaceHttpClient;
import java.util.Properties;
@ -42,11 +44,13 @@ public class EnvBackupHelper {
FineLoggerFactory.getLogger().info("[EnvBackup] 1.back start...");
this.swtiching = true;
local = WorkContext.getCurrent().isLocal();
origin = WorkContext.getCurrent();
if (local) {
properties = ConfigHelper.getEnvProperties();
path = ConfigHelper.getEnvPropertiesPath();
} else {
closeEnv();
}
origin = WorkContext.getCurrent();
}
/**
@ -107,10 +111,30 @@ public class EnvBackupHelper {
} else {
// 如果是远程,则新环境的配置全部弃用,直接走老的
MemConfigBackupManager.getInstance().failed();
rollbackEnv();
}
}
/**
* 关闭环境
*/
public void closeEnv() {
// 如果原来是远程,要先发请求告诉原来的环境我这边要断开
if (origin instanceof RemoteWorkspace) {
origin.close();
}
}
/**
* 重新进入老环境
*/
public void rollbackEnv() {
if (origin instanceof RemoteWorkspace && ((RemoteWorkspace) origin).getClient() instanceof FineWorkspaceHttpClient) {
((FineWorkspaceHttpClient) ((RemoteWorkspace) origin).getClient()).startHeartBeat();
}
}
public boolean isSwtiching() {
return swtiching;
}

10
designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java

@ -157,7 +157,7 @@ public class ConnectionInfoBeanHelper {
.user(jdbcConnection.getUser())
.driver(jdbcConnection.getDriver())
// 关键中的关键,由设计器发出的请求如果要携带密码,不能传明文,必须必须必须传加密后的密码
.password(withPassword ? encrypt(jdbcConnection.getPassword()) : DecisionServiceConstants.DEFAULT_PASSWORD)
.password(withPassword ? DataEncryptionHelper.encrypt(jdbcConnection.getPassword()) : DecisionServiceConstants.DEFAULT_PASSWORD)
.schema(jdbcConnection.getSchema())
.url(jdbcConnection.getURL())
.creator(jdbcConnection.getCreator())
@ -188,14 +188,6 @@ public class ConnectionInfoBeanHelper {
.verifyCa(jdbcConnection.getSsl().getSslType() == SslType.NORMAL && ((NormalSsl) jdbcConnection.getSsl()).isVerifyCa());
}
private static String encrypt(String password) {
// 如果是空密码或者默认密码,就返回默认的星号回去
if (StringUtils.isEmpty(password) || StringUtils.equals(password, DecisionServiceConstants.DEFAULT_PASSWORD)) {
return DecisionServiceConstants.DEFAULT_PASSWORD;
}
return TransmissionEncryptionManager.getInstance().getEncryption(WorkplaceConstants.getEncryptionMode()).encrypt(password, WorkplaceConstants.getEncryptionKey());
}
private static Connection createJDBCConnection(ConnectionInfoBean connectionInfoBean) throws Exception {
String name = connectionInfoBean.getConnectionName();

3
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -1751,6 +1751,9 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
}
private boolean checkJTemplateAuthority() {
if (WorkContext.getCurrent().isRoot()) {
return true;
}
ConnectionAuthorityConfigBean bean = ConnectionRepository.getInstance().getConnectionAuthorityConfig();
if (!(bean !=null && bean.isConnectionEditAuth())) {
return true;

Loading…
Cancel
Save