forked from spring-projects/spring-authorization-server
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
...rity/oauth2/server/authorization/oidc/authentication/OidcLogoutAuthenticationContext.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,90 @@ | ||
package org.springframework.security.oauth2.server.authorization.oidc.authentication; | ||
|
||
import java.util.Map; | ||
|
||
import org.springframework.lang.Nullable; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.oauth2.server.authorization.OAuth2Authorization; | ||
import org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthenticationContext; | ||
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; | ||
import org.springframework.util.Assert; | ||
|
||
/** | ||
* TODO | ||
*/ | ||
public final class OidcLogoutAuthenticationContext implements OAuth2AuthenticationContext { | ||
|
||
private final Map<Object, Object> context; | ||
|
||
private OidcLogoutAuthenticationContext(Map<Object, Object> context) { | ||
this.context = context; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Nullable | ||
@Override | ||
public <V> V get(Object key) { | ||
return hasKey(key) ? (V) this.context.get(key) : null; | ||
} | ||
|
||
@Override | ||
public boolean hasKey(Object key) { | ||
Assert.notNull(key, "key cannot be null"); | ||
return this.context.containsKey(key); | ||
} | ||
|
||
/** | ||
* Returns the {@link RegisteredClient registered client}. | ||
* @return the {@link RegisteredClient} | ||
*/ | ||
public RegisteredClient getRegisteredClient() { | ||
return get(RegisteredClient.class); | ||
} | ||
|
||
/** | ||
* Returns the {@link OAuth2Authorization authorization request}. | ||
* @return the {@link OAuth2Authorization} | ||
*/ | ||
public OAuth2Authorization getAuthorizationRequest() { | ||
return get(OAuth2Authorization.class); | ||
} | ||
|
||
/** | ||
* A builder for {@link OidcLogoutAuthenticationContext}. | ||
*/ | ||
public static final class Builder extends AbstractBuilder<OidcLogoutAuthenticationContext, Builder> { | ||
|
||
private Builder(Authentication authentication) { | ||
super(authentication); | ||
} | ||
|
||
/** | ||
* Sets the {@link RegisteredClient registered client}. | ||
* @param registeredClient the {@link RegisteredClient} | ||
* @return the {@link Builder} for further configuration | ||
*/ | ||
public Builder registeredClient(RegisteredClient registeredClient) { | ||
return put(RegisteredClient.class, registeredClient); | ||
} | ||
|
||
/** | ||
* Sets the {@link OAuth2Authorization registered client}. | ||
* @param authorization the {@link OAuth2Authorization} | ||
* @return the {@link Builder} for further configuration | ||
*/ | ||
public Builder authorization(OAuth2Authorization authorization) { | ||
return put(OAuth2Authorization.class, authorization); | ||
} | ||
|
||
/** | ||
* Builds a new {@link OidcLogoutAuthenticationContext}. | ||
* @return the {@link OidcLogoutAuthenticationContext} | ||
*/ | ||
@Override | ||
public OidcLogoutAuthenticationContext build() { | ||
return new OidcLogoutAuthenticationContext(getContext()); | ||
} | ||
|
||
} | ||
|
||
} |
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