Interface AuthService
-
- All Known Implementing Classes:
RedisAuthService,SessionAuthService,TokenAuthService
public interface AuthService
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTH_HEADER_NAME
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication)Add the authentication on the response after performs other operations like persistence server sidedefault StringcreateTokenForUser(TokenUser user, String secret)Collection<String>extractUserAppRoles(Collection<String> roles)default TokenUserfromJSON(String userJSON)org.springframework.security.core.AuthenticationgetAuthentication(javax.servlet.http.HttpServletRequest request)longgetTokenTimeout()default TokenUsergetTokenUser(org.springframework.security.core.Authentication authentication)default TokenUserparseUserFromToken(String token, String secret)default StringtoJSON(TokenUser user)
-
-
-
Field Detail
-
AUTH_HEADER_NAME
static final String AUTH_HEADER_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAuthentication
org.springframework.security.core.Authentication getAuthentication(javax.servlet.http.HttpServletRequest request)
-
addAuthentication
void addAuthentication(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authentication)Add the authentication on the response after performs other operations like persistence server side- Parameters:
request- the http requestresponse- the http responseauthentication- the authentication
-
extractUserAppRoles
Collection<String> extractUserAppRoles(Collection<String> roles)
- Parameters:
roles- a collection of roles- Returns:
- the intersection between aplication defined roles and the one from the collection
-
getTokenUser
default TokenUser getTokenUser(org.springframework.security.core.Authentication authentication)
- Parameters:
authentication- the spring security Authentication- Returns:
- the Token user
-
fromJSON
default TokenUser fromJSON(String userJSON)
- Parameters:
userJSON- representation of the TokenUser- Returns:
- the TokenUser
-
toJSON
default String toJSON(TokenUser user)
- Parameters:
user- the TokenUser to be serializes- Returns:
- the json string representing TokenUser
-
parseUserFromToken
default TokenUser parseUserFromToken(String token, String secret)
- Parameters:
token- the encoded tokensecret- secret phrase to decode- Returns:
- parsed TokenUser
-
createTokenForUser
default String createTokenForUser(TokenUser user, String secret)
- Parameters:
user- the user to create token forsecret- the secret for signature- Returns:
- jwt token
-
getTokenTimeout
long getTokenTimeout()
- Returns:
- milliseconds until expiration
-
-