Skip to content

Commit

Permalink
Rebase to develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
rmiccoli committed Oct 16, 2024
1 parent f5e6362 commit 7d5d5f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void linkX509Certificate(Principal authenticatedUser,
IamAccount userAccount = findAccount(authenticatedUser);

Optional<IamAccount> linkedAccount =
certificateRepository.findBySubject(x509Credential.getSubject()).stream().findFirst();
certificateRepository.findBySubjectDn(x509Credential.getSubject()).stream().findFirst();

// check if the x509Credential is linked to another user
if (linkedAccount.isPresent() && !linkedAccount.get().getUuid().equals(userAccount.getUuid())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void testx509AccountLinking() throws Exception {
flash().attribute(ACCOUNT_LINKING_DASHBOARD_MESSAGE_KEY, equalTo(confirmationMessage)));

Optional<IamAccount> linkedUser =
iamX509CertificateRepo.findBySubject(TEST_0_SUBJECT).stream().findFirst();
iamX509CertificateRepo.findBySubjectDn(TEST_0_SUBJECT).stream().findFirst();
assertThat(linkedUser.isPresent(), is(true));
assertThat(linkedUser.get().getUsername(), is("test"));

Expand Down Expand Up @@ -283,7 +283,7 @@ public void testUpdateCertWithSameIssuerAndSubjectButDifferentPem() throws Excep
flash().attribute(ACCOUNT_LINKING_DASHBOARD_MESSAGE_KEY, equalTo(confirmationMessage)));

Optional<IamX509Certificate> testCert =
iamX509CertificateRepo.findBySubjectAndIssuer(TEST_0_SUBJECT, TEST_0_ISSUER);
iamX509CertificateRepo.findBySubjectDnAndIssuerDn(TEST_0_SUBJECT, TEST_0_ISSUER);
assertThat(testCert.isPresent(), is(true));
assertThat(
account.getX509Certificates()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@
*/
package it.infn.mw.iam.persistence.repository;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import it.infn.mw.iam.persistence.model.IamAccount;
import it.infn.mw.iam.persistence.model.IamX509Certificate;

public interface IamX509CertificateRepository
extends PagingAndSortingRepository<IamX509Certificate, Long> {
extends PagingAndSortingRepository<IamX509Certificate, Long> {

public Optional<IamX509Certificate> findBySubjectDnAndIssuerDn(String subjectDn, String issuerDn);
@Query("select c.account from IamX509Certificate c where c.subjectDn = :subject")
List<IamAccount> findBySubjectDn(@Param("subject") String subject);

public Optional<IamX509Certificate> findBySubjectDnAndIssuerDn(String subjectDn, String issuerDn);

}

0 comments on commit 7d5d5f6

Please sign in to comment.