This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects

Resolve "Die Statistiken sollten auch in ElasticSearch hinterlegt werden."

Compare and Show latest version
3 files
+ 114
5
Compare changes
  • Side-by-side
  • Inline
Files
3
package at.ac.uibk.gitsearch.security.oauth2;
import java.util.Collection;
import java.util.Objects;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
import org.springframework.security.oauth2.client.authentication.OAuth2LoginAuthenticationToken;
@@ -33,7 +35,26 @@ public class GitSearchOAuth2AuthenticationToken extends OAuth2AuthenticationToke
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
int code = 31;
final Collection<GrantedAuthority> authorities = this.getAuthorities();
if (authorities != null) {
for (GrantedAuthority authority : authorities) {
code ^= authority.hashCode();
}
}
if (this.getPrincipal() != null) {
code ^= this.getPrincipal().hashCode();
}
if (this.getCredentials() != null) {
code ^= this.getCredentials().hashCode();
}
if (this.getDetails() != null) {
code ^= this.getDetails().hashCode();
}
if (this.isAuthenticated()) {
code ^= -37;
}
int result = code;
result = prime * result + Objects.hash(redirectURL);
return result;
}
@@ -43,13 +64,18 @@ public class GitSearchOAuth2AuthenticationToken extends OAuth2AuthenticationToke
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
if (obj == null) return false;
if (!getClass().isAssignableFrom(obj.getClass())) {
return false;
}
if (getClass() != obj.getClass()) {
GitSearchOAuth2AuthenticationToken other = (GitSearchOAuth2AuthenticationToken) obj;
if (this.getAuthorities() == null) {
return other.getAuthorities() == null;
}
if (!super.equals(obj)) {
return false;
}
GitSearchOAuth2AuthenticationToken other = (GitSearchOAuth2AuthenticationToken) obj;
return Objects.equals(redirectURL, other.redirectURL);
}
}