forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- b2c optimization - update readme file - code refactor
- Loading branch information
1 parent
81ba0b9
commit c92f807
Showing
9 changed files
with
137 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../src/main/java/com/azure/spring/autoconfigure/b2c/AADB2CClientRegistrationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
package com.azure.spring.autoconfigure.b2c; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.security.oauth2.client.registration.ClientRegistration; | ||
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; | ||
import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository; | ||
|
||
import java.util.Collection; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* <p> | ||
* ClientRegistrationRepository for aad b2c | ||
* </p> | ||
*/ | ||
public class AADB2CClientRegistrationRepository implements ClientRegistrationRepository, Iterable<ClientRegistration> { | ||
|
||
private final InMemoryClientRegistrationRepository clientRegistrations; | ||
private final List<ClientRegistration> signUpOrSignInRegistrations; | ||
|
||
|
||
AADB2CClientRegistrationRepository(List<ClientRegistration> signUpOrSignInRegistrations, | ||
List<ClientRegistration> otherRegistrations) { | ||
this.signUpOrSignInRegistrations = signUpOrSignInRegistrations; | ||
List<ClientRegistration> allRegistrations = Stream.of(signUpOrSignInRegistrations, otherRegistrations) | ||
.flatMap(Collection::stream) | ||
.collect(Collectors.toList()); | ||
this.clientRegistrations = new InMemoryClientRegistrationRepository(allRegistrations); | ||
} | ||
|
||
@Override | ||
public ClientRegistration findByRegistrationId(String registrationId) { | ||
return this.clientRegistrations.findByRegistrationId(registrationId); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Iterator<ClientRegistration> iterator() { | ||
return this.signUpOrSignInRegistrations.iterator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters