@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } AuthenticationResult that = (AuthenticationResult) o; return Objects.equals(getIdentity(), that.getIdentity()) && Objects.equals(getAuthorizerName(), that.getAuthorizerName()) && Objects.equals(getAuthenticatedBy(), that.getAuthenticatedBy()) && Objects.equals(getContext(), that.getContext()); }
@Override public int hashCode() { return Objects.hash(getIdentity(), getAuthorizerName(), getAuthenticatedBy(), getContext()); } }
private Access doAuthorize(final AuthenticationResult authenticationResult, final Access authorizationResult) { if (!authorizationResult.isAllowed()) { // Not authorized; go straight to Jail, do not pass Go. transition(State.AUTHORIZING, State.UNAUTHORIZED); } else { transition(State.AUTHORIZING, State.AUTHORIZED); } this.authenticationResult = authenticationResult; final QueryMetrics queryMetrics = queryPlus.getQueryMetrics(); if (queryMetrics != null) { queryMetrics.identity(authenticationResult.getIdentity()); } return authorizationResult; }
statsMap.put("success", success); if (authenticationResult != null) { statsMap.put("identity", authenticationResult.getIdentity());
@Override public Access authorize( AuthenticationResult authenticationResult, Resource resource, Action action ) { if (authenticationResult == null) { throw new IAE("WTF? authenticationResult should never be null."); } Map<String, BasicAuthorizerUser> userMap = cacheManager.getUserMap(name); if (userMap == null) { throw new IAE("Could not load userMap for authorizer [%s]", name); } Map<String, BasicAuthorizerRole> roleMap = cacheManager.getRoleMap(name); if (roleMap == null) { throw new IAE("Could not load roleMap for authorizer [%s]", name); } BasicAuthorizerUser user = userMap.get(authenticationResult.getIdentity()); if (user == null) { return new Access(false); } for (String roleName : user.getRoles()) { BasicAuthorizerRole role = roleMap.get(roleName); for (BasicAuthorizerPermission permission : role.getPermissions()) { if (permissionCheck(resource, action, permission)) { return new Access(true); } } } return new Access(false); }