Skip to content

Commit

Permalink
fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
siewer committed Dec 13, 2024
1 parent 7cb71ad commit a5fd880
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.security.oauth2.jwt.JwtValidationException;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public interface TeamRepository extends CrudRepository<Team, Long> {
Optional<Team> findByName(String name);
Optional<Team> findById(Long id);

Optional<Team> findByRemoteIdentifier(String remoteIdentifier);
List<Team> findByRemoteIdentifier(String remoteIdentifier);
List<Team> findAll();
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ public ItemListResponse getThreatIntelFindings(Principal principal){
}

public ItemListResponse getThreatIntelFindingsForTeam(Principal principal, String remoteId){
Team team = findTeamService.findByRemoteId(remoteId);
if (team == null){
List<Team> teams = findTeamService.findByRemoteId(remoteId);
if (teams == null){
throw new TeamNotFoundException("[Threat Intell] Trying to find not existing team " + remoteId);
}
List<ItemProjection> combinedProjections = new ArrayList<>();

combinedProjections = findingRepository.findCombinedItems(findCodeRepoService.findByTeam(team).stream().map(CodeRepo::getId).toList());
combinedProjections = findingRepository.findCombinedItems(
teams.stream()
.flatMap(team -> findCodeRepoService.findByTeam(team).stream())
.map(CodeRepo::getId).toList()
);

return mapProjectionsToItems(combinedProjections);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public List<Team> findAll(){
return teamRepository.findAll();
}

public Team findByRemoteId(String remoteId) {
return teamRepository.findByRemoteIdentifier(remoteId).orElse(null);
public List<Team> findByRemoteId(String remoteId) {
return teamRepository.findByRemoteIdentifier(remoteId);
}
}

0 comments on commit a5fd880

Please sign in to comment.