Package io.antmedia.security
Class MockTokenService
java.lang.Object
io.antmedia.security.MockTokenService
- All Implemented Interfaces:
ITokenService,IStreamPlaybackSecurity,IStreamPublishSecurity
public class MockTokenService
extends Object
implements IStreamPublishSecurity, IStreamPlaybackSecurity, ITokenService
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.antmedia.security.ITokenService
ITokenService.BeanName -
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from interface io.antmedia.security.ITokenService
HMAC_SHA1, logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompare hash string with computed one which is based on streamId,type and secretbooleancheckJwtToken(String jwtTokenId, String streamId, String sessionId, String type) Checks the JWT token validitybooleancheckTimeBasedSubscriber(String subscriberId, String streamId, String sessionId, String subscriberCode, String tokenType) Checks the time based token validitybooleancheckToken(String tokenId, String streamId, String sessionId, String type) Checks the token validitycreateJwtToken(String streamId, long exprireDate, String type, String roomId) creates token according to the provided parameterscreateToken(String streamId, long exprireDate, String type, String roomId) creates token according to the provided parametersgets map of authenticated sessionsgets map of authenticated subscriber sessionsbooleanisJwtTokenValid(String jwtTokenId, String tokenSecret, String streamId, String type) Check the JWT token if it's valid.booleanisPlayAllowed(IScope scope, String name, String mode, Map<String, String> queryParams, String metaData, String token, String subscriberId, String subscriberCode) booleanisPlaybackAllowed(IScope scope, String name, int start, int length, boolean flushPlaylist) Check if playback of a stream with the given name is allowed.booleanisPublishAllowed(IScope scope, String name, String mode, Map<String, String> queryParams, String metaData, String token, String subscriberId, String subscriberCode) Check if publishing a stream with the given name is allowed.
-
Field Details
-
authenticatedMap
-
subscriberAuthenticatedMap
-
-
Constructor Details
-
MockTokenService
public MockTokenService()
-
-
Method Details
-
checkToken
Description copied from interface:ITokenServiceChecks the token validity- Specified by:
checkTokenin interfaceITokenService- Parameters:
tokenId- - requested token idstreamId- - id of the streamsessionId- - id of the current sessiontype- - type of the token (play/publish)- Returns:
- true or false
-
isPublishAllowed
public boolean isPublishAllowed(IScope scope, String name, String mode, Map<String, String> queryParams, String metaData, String token, String subscriberId, String subscriberCode) Description copied from interface:IStreamPublishSecurityCheck if publishing a stream with the given name is allowed.- Specified by:
isPublishAllowedin interfaceIStreamPublishSecurity- Parameters:
scope- Scope the stream is about to be published in.name- Name of the stream to publish.mode- Publishing mode.- Returns:
True
if publishing is allowed, otherwise
False
-
createToken
Description copied from interface:ITokenServicecreates token according to the provided parameters- Specified by:
createTokenin interfaceITokenService- Parameters:
streamId- - id of the requested stream for token creationexprireDate- - expire date of the tokentype- type of the token (play/publish)roomId- - id of the room for playing streams in the room- Returns:
- token
-
createJwtToken
Description copied from interface:ITokenServicecreates token according to the provided parameters- Specified by:
createJwtTokenin interfaceITokenService- Parameters:
streamId- - id of the requested stream for token creationexprireDate- - expire date of the token (unix timestamp)type- type of the token (play/publish)roomId- - id of the room for playing streams in the room- Returns:
- token
-
getAuthenticatedMap
Description copied from interface:ITokenServicegets map of authenticated sessions- Specified by:
getAuthenticatedMapin interfaceITokenService- Returns:
- list
-
getSubscriberAuthenticatedMap
Description copied from interface:ITokenServicegets map of authenticated subscriber sessions- Specified by:
getSubscriberAuthenticatedMapin interfaceITokenService- Returns:
- list
-
checkHash
Description copied from interface:ITokenServiceCompare hash string with computed one which is based on streamId,type and secret- Specified by:
checkHashin interfaceITokenService- Parameters:
hash- - client hashstreamId- - id of the streamsessionId- - session of the requesttype- - type of the request (publish/play)- Returns:
-
checkTimeBasedSubscriber
public boolean checkTimeBasedSubscriber(String subscriberId, String streamId, String sessionId, String subscriberCode, String tokenType) Description copied from interface:ITokenServiceChecks the time based token validity- Specified by:
checkTimeBasedSubscriberin interfaceITokenService- Parameters:
subscriberId- - requested subscriberIdstreamId- - id of the streamsessionId- - id of the current sessionsubscriberCode- - with TOTP generated codetokenType- -or @link Subscriber#PUBLISH_TYPE or @link Subscriber#PLAY_TYPE- Returns:
- true or false
-
isJwtTokenValid
Description copied from interface:ITokenServiceCheck the JWT token if it's valid. It accepts the secret key to check the validity;- Specified by:
isJwtTokenValidin interfaceITokenService- Returns:
-
checkJwtToken
Description copied from interface:ITokenServiceChecks the JWT token validity- Specified by:
checkJwtTokenin interfaceITokenService- Parameters:
jwtTokenId- - requested token idstreamId- - id of the streamtype- - type of the token (play/publish)- Returns:
- true or false
-
isPlaybackAllowed
public boolean isPlaybackAllowed(IScope scope, String name, int start, int length, boolean flushPlaylist) Description copied from interface:IStreamPlaybackSecurityCheck if playback of a stream with the given name is allowed.- Specified by:
isPlaybackAllowedin interfaceIStreamPlaybackSecurity- Parameters:
scope- Scope the stream is about to be played back from.name- Name of the stream to play.start- Position to start playback from (in milliseconds).length- Duration to play (in milliseconds).flushPlaylist- Flush playlist?- Returns:
True
if playback is allowed, otherwiseFalse
-
isPlayAllowed
public boolean isPlayAllowed(IScope scope, String name, String mode, Map<String, String> queryParams, String metaData, String token, String subscriberId, String subscriberCode) - Specified by:
isPlayAllowedin interfaceIStreamPlaybackSecurity
-