SimpUser exposes Principal
Closes gh-25191
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -114,7 +114,7 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
|
||||
synchronized (this.sessionLock) {
|
||||
LocalSimpUser simpUser = this.users.get(name);
|
||||
if (simpUser == null) {
|
||||
simpUser = new LocalSimpUser(name);
|
||||
simpUser = new LocalSimpUser(name, user);
|
||||
this.users.put(name, simpUser);
|
||||
}
|
||||
LocalSimpSession session = new LocalSimpSession(sessionId, simpUser);
|
||||
@@ -193,11 +193,14 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Principal user;
|
||||
|
||||
private final Map<String, SimpSession> userSessions = new ConcurrentHashMap<>(1);
|
||||
|
||||
public LocalSimpUser(String userName) {
|
||||
public LocalSimpUser(String userName, Principal user) {
|
||||
Assert.notNull(userName, "User name must not be null");
|
||||
this.name = userName;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,6 +208,12 @@ public class DefaultSimpUserRegistry implements SimpUserRegistry, SmartApplicati
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Principal getPrincipal() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSessions() {
|
||||
return !this.userSessions.isEmpty();
|
||||
|
||||
Reference in New Issue
Block a user