mirror of https://github.com/OpenVidu/openvidu.git
Fixes token check
parent
5287ed631f
commit
9e57a9db7a
|
@ -18,6 +18,7 @@ public class TokenRegister {
|
||||||
private final ConcurrentHashMap<String, Participant> participantsByTokens = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<String, Participant> participantsByTokens = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* O(1)
|
||||||
* Register a token of an specific active session
|
* Register a token of an specific active session
|
||||||
* @param sessionId Id of the sessions where the token is generated
|
* @param sessionId Id of the sessions where the token is generated
|
||||||
* @param token Token to register
|
* @param token Token to register
|
||||||
|
@ -31,6 +32,7 @@ public class TokenRegister {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* O(n)
|
||||||
* Deregister all tokens of an specific session which is not active
|
* Deregister all tokens of an specific session which is not active
|
||||||
* @param sessionId Id of the session which is no longer active
|
* @param sessionId Id of the session which is no longer active
|
||||||
*/
|
*/
|
||||||
|
@ -45,6 +47,7 @@ public class TokenRegister {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* O(1)
|
||||||
* Check if the current token string was registered in an active session
|
* Check if the current token string was registered in an active session
|
||||||
* @param token Token string to check if it is registered
|
* @param token Token string to check if it is registered
|
||||||
* @param connectionId Id of the connection to check
|
* @param connectionId Id of the connection to check
|
||||||
|
@ -67,17 +70,20 @@ public class TokenRegister {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.participantsByTokens.containsKey(connectionId)) {
|
if (!this.participantsByTokens.containsKey(token)) {
|
||||||
// Participant is not registered for specific token
|
// Participant is not registered for specific token
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In this final state, if connectionId is equal to participant public id, the token is registered
|
// In this final state, if connectionId is equal to participant public id and session Id is the same,
|
||||||
return participantsByTokens.get(connectionId).getParticipantPublicId().equals(connectionId);
|
// the token is registered correctly in the specific connectionId and sessionId
|
||||||
|
return participantsByTokens.get(token).getParticipantPublicId().equals(connectionId)
|
||||||
|
&& participantsByTokens.get(token).getSessionId().equals(sessionId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* O(1)
|
||||||
* Get registered token from token string
|
* Get registered token from token string
|
||||||
* @param tokenKey string key which represents the token
|
* @param tokenKey string key which represents the token
|
||||||
* @return
|
* @return
|
||||||
|
@ -90,5 +96,4 @@ public class TokenRegister {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue