Skip to content

Commit 8738523

Browse files
authored
Merge pull request #136 from jumpserver/pr@dev@feat_locked_session
feat: locked session can not download
2 parents b5f9832 + c214338 commit 8738523

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

backend/framework/src/main/java/org/jumpserver/chen/framework/console/dataview/DataView.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ public void export(String scope, String format) throws SQLException {
141141
SessionManager.getCurrentSession().getController().showMessage(MessageLevel.ERROR, MessageUtils.get("DownloadNotAllowed"));
142142
return;
143143
}
144+
145+
if (SessionManager.getCurrentSession().isLocked()) {
146+
SessionManager.getCurrentSession().getController().showMessage(MessageLevel.ERROR, MessageUtils.get("SessionLockedMessage", SessionManager.getCurrentSession().getLockCreator()));
147+
return;
148+
}
149+
144150
File f = null;
145151
switch (scope) {
146152
case "current":

backend/framework/src/main/java/org/jumpserver/chen/framework/session/Session.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
public interface Session {
2323

24+
String getLockCreator();
25+
26+
boolean isLocked();
27+
2428
List<Common.DataMaskingRule> getDataMaskingRules();
2529

2630
void refreshLastActiveTime();

backend/framework/src/main/java/org/jumpserver/chen/framework/session/impl/BaseSession.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ public class BaseSession implements Session {
6363
@Getter
6464
private LocalDateTime lastActiveTime;
6565

66+
@Getter
67+
private boolean locked = false;
68+
69+
@Getter
70+
private String lockCreator;
71+
6672

6773
public BaseSession(Datasource datasource, String remoteAddr) {
6874
this.datasource = datasource;

backend/framework/src/main/java/org/jumpserver/chen/framework/session/impl/JMSSession.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ public class JMSSession extends BaseSession {
6262
@Setter
6363
private String gatewayId;
6464

65+
66+
@Getter
6567
private boolean locked = false;
6668

69+
@Getter
70+
private String lockCreator;
71+
6772
private boolean canUpload = false;
6873
private boolean canDownload = false;
6974

@@ -72,16 +77,21 @@ public class JMSSession extends BaseSession {
7277

7378
private boolean closed = false;
7479

80+
7581
public void lockSession(String creator) {
7682
SessionManager.setContext(this.getWebToken());
77-
this.getController().showMessage(MessageLevel.ERROR, MessageUtils.get("SessionLockedMessage", creator));
83+
84+
this.lockCreator = creator;
7885
this.locked = true;
86+
this.getController().showMessage(MessageLevel.ERROR, MessageUtils.get("SessionLockedMessage", this.lockCreator));
7987
}
8088

8189
public void unloadSession(String creator) {
8290
SessionManager.setContext(this.getWebToken());
91+
8392
this.getController().showMessage(MessageLevel.SUCCESS, MessageUtils.get("SessionUnlockedMessage", creator));
8493
this.locked = false;
94+
this.lockCreator = null;
8595
}
8696

8797

0 commit comments

Comments
 (0)