mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-30 00:32:14 +00:00
Remove ProviderJwtDecoderRegistry
Fixes gh-4581
This commit is contained in:
parent
8448a54678
commit
52f495a5ec
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.security.oauth2.client.authentication.jwt;
|
||||
|
||||
import org.springframework.security.jwt.JwtDecoder;
|
||||
import org.springframework.security.oauth2.core.provider.ProviderMetadata;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The default implementation of a {@link ProviderJwtDecoderRegistry} that associates
|
||||
* a {@link JwtDecoder} to a {@link ProviderMetadata}. The <code>ProviderMetadata</code>
|
||||
* is matched against the <code>providerIdentifier</code> parameter passed to {@link #getJwtDecoder(String)}.
|
||||
*
|
||||
* @author Joe Grandja
|
||||
* @since 5.0
|
||||
*/
|
||||
public class DefaultProviderJwtDecoderRegistry implements ProviderJwtDecoderRegistry {
|
||||
private final Map<ProviderMetadata, JwtDecoder> jwtDecoders;
|
||||
|
||||
public DefaultProviderJwtDecoderRegistry(Map<ProviderMetadata, JwtDecoder> jwtDecoders) {
|
||||
Assert.notNull(jwtDecoders, "jwtDecoders cannot be null");
|
||||
this.jwtDecoders = Collections.unmodifiableMap(new HashMap<>(jwtDecoders));
|
||||
}
|
||||
|
||||
@Override
|
||||
public JwtDecoder getJwtDecoder(String providerIdentifier) {
|
||||
Assert.hasText(providerIdentifier, "providerIdentifier cannot be empty");
|
||||
Optional<ProviderMetadata> providerMetadataKey = this.jwtDecoders.keySet().stream().filter(providerMetadata ->
|
||||
providerIdentifier.equals(providerMetadata.getIssuer().toString()) ||
|
||||
providerIdentifier.equals(providerMetadata.getAuthorizationEndpoint().toString()) ||
|
||||
providerIdentifier.equals(providerMetadata.getTokenEndpoint().toString()) ||
|
||||
providerIdentifier.equals(providerMetadata.getUserInfoEndpoint().toString()) ||
|
||||
providerIdentifier.equals(providerMetadata.getJwkSetUri().toString())
|
||||
).findFirst();
|
||||
return (providerMetadataKey.isPresent() ? this.jwtDecoders.get(providerMetadataKey.get()) : null);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.security.oauth2.client.authentication.jwt;
|
||||
|
||||
import org.springframework.security.jwt.JwtDecoder;
|
||||
|
||||
/**
|
||||
* A registry for {@link JwtDecoder}'s that are associated to an <i>OAuth 2.0 Provider</i>.
|
||||
*
|
||||
* @author Joe Grandja
|
||||
* @since 5.0
|
||||
*/
|
||||
public interface ProviderJwtDecoderRegistry {
|
||||
|
||||
JwtDecoder getJwtDecoder(String providerIdentifier);
|
||||
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.security.oauth2.core.provider;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link ProviderMetadata}.
|
||||
*
|
||||
* @author Joe Grandja
|
||||
* @since 5.0
|
||||
*/
|
||||
public class DefaultProviderMetadata implements ProviderMetadata {
|
||||
private URL issuer;
|
||||
private URL authorizationEndpoint;
|
||||
private URL tokenEndpoint;
|
||||
private URL userInfoEndpoint;
|
||||
private URL jwkSetUri;
|
||||
|
||||
public DefaultProviderMetadata() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getIssuer() {
|
||||
return issuer;
|
||||
}
|
||||
|
||||
public void setIssuer(URL issuer) {
|
||||
this.issuer = issuer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getAuthorizationEndpoint() {
|
||||
return authorizationEndpoint;
|
||||
}
|
||||
|
||||
public void setAuthorizationEndpoint(URL authorizationEndpoint) {
|
||||
this.authorizationEndpoint = authorizationEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getTokenEndpoint() {
|
||||
return tokenEndpoint;
|
||||
}
|
||||
|
||||
public void setTokenEndpoint(URL tokenEndpoint) {
|
||||
this.tokenEndpoint = tokenEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getUserInfoEndpoint() {
|
||||
return userInfoEndpoint;
|
||||
}
|
||||
|
||||
public void setUserInfoEndpoint(URL userInfoEndpoint) {
|
||||
this.userInfoEndpoint = userInfoEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getJwkSetUri() {
|
||||
return jwkSetUri;
|
||||
}
|
||||
|
||||
public void setJwkSetUri(URL jwkSetUri) {
|
||||
this.jwkSetUri = jwkSetUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DefaultProviderMetadata that = (DefaultProviderMetadata) obj;
|
||||
|
||||
if (!this.getIssuer().equals(that.getIssuer())) {
|
||||
return false;
|
||||
}
|
||||
if (!this.getAuthorizationEndpoint().equals(that.getAuthorizationEndpoint())) {
|
||||
return false;
|
||||
}
|
||||
if (!this.getTokenEndpoint().equals(that.getTokenEndpoint())) {
|
||||
return false;
|
||||
}
|
||||
return this.getUserInfoEndpoint().equals(that.getUserInfoEndpoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.getIssuer().hashCode();
|
||||
result = 31 * result + this.getAuthorizationEndpoint().hashCode();
|
||||
result = 31 * result + this.getTokenEndpoint().hashCode();
|
||||
result = 31 * result + this.getUserInfoEndpoint().hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.security.oauth2.core.provider;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Metadata describing the configuration information for an <i>OAuth 2.0 Provider</i>.
|
||||
*
|
||||
* @author Joe Grandja
|
||||
* @since 5.0
|
||||
*/
|
||||
public interface ProviderMetadata {
|
||||
|
||||
URL getIssuer();
|
||||
|
||||
URL getAuthorizationEndpoint();
|
||||
|
||||
URL getTokenEndpoint();
|
||||
|
||||
URL getUserInfoEndpoint();
|
||||
|
||||
URL getJwkSetUri();
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user