main
|
Last change
on this file was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago |
|
Init
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Rev | Line | |
|---|
| [700e2f9] | 1 | package com.finki.icare.config;
|
|---|
| 2 |
|
|---|
| 3 | import lombok.Getter;
|
|---|
| 4 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|---|
| 5 | import org.springframework.security.core.GrantedAuthority;
|
|---|
| 6 |
|
|---|
| 7 | import java.util.Collection;
|
|---|
| 8 | import java.util.Objects;
|
|---|
| 9 |
|
|---|
| 10 | @Getter
|
|---|
| 11 | public class JwtAuthenticationToken extends UsernamePasswordAuthenticationToken {
|
|---|
| 12 |
|
|---|
| 13 | private final Integer userId;
|
|---|
| 14 | private final String userType;
|
|---|
| 15 |
|
|---|
| 16 | public JwtAuthenticationToken(
|
|---|
| 17 | Object principal,
|
|---|
| 18 | Object credentials,
|
|---|
| 19 | Collection<? extends GrantedAuthority> authorities,
|
|---|
| 20 | Integer userId,
|
|---|
| 21 | String userType
|
|---|
| 22 | ) {
|
|---|
| 23 | super(principal, credentials, authorities);
|
|---|
| 24 | this.userId = userId;
|
|---|
| 25 | this.userType = userType;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | @Override
|
|---|
| 29 | public boolean equals(Object obj) {
|
|---|
| 30 | if (this == obj) {
|
|---|
| 31 | return true;
|
|---|
| 32 | }
|
|---|
| 33 | if (!(obj instanceof JwtAuthenticationToken other)) {
|
|---|
| 34 | return false;
|
|---|
| 35 | }
|
|---|
| 36 | if (!super.equals(obj)) {
|
|---|
| 37 | return false;
|
|---|
| 38 | }
|
|---|
| 39 | return Objects.equals(this.userId, other.userId) && Objects.equals(this.userType, other.userType);
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | @Override
|
|---|
| 43 | public int hashCode() {
|
|---|
| 44 | return Objects.hash(super.hashCode(), userId, userType);
|
|---|
| 45 | }
|
|---|
| 46 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.