Refactor part 1
parent
0b6aebfefe
commit
c40efda6b5
|
@ -49,7 +49,7 @@ import org.mitre.jwt.signer.JwsAlgorithm;
|
|||
import org.mitre.jwt.signer.JwtSigner;
|
||||
import org.mitre.jwt.signer.impl.RsaSigner;
|
||||
import org.mitre.jwt.signer.service.JwtSigningAndValidationService;
|
||||
import org.mitre.jwt.signer.service.impl.JwtSigningAndValidationServiceDefault;
|
||||
import org.mitre.jwt.signer.service.impl.DefaultJwtSigningAndValidationService;
|
||||
import org.mitre.key.fetch.KeyFetcher;
|
||||
import org.mitre.openid.connect.config.OIDCServerConfiguration;
|
||||
import org.mitre.openid.connect.model.IdToken;
|
||||
|
@ -640,7 +640,7 @@ public class AbstractOIDCAuthenticationFilter extends
|
|||
signers.put(serverConfig.getIssuer() + JwsAlgorithm.RS512.getJwaName(), signer512);
|
||||
}
|
||||
|
||||
JwtSigningAndValidationService signingAndValidationService = new JwtSigningAndValidationServiceDefault(signers);
|
||||
JwtSigningAndValidationService signingAndValidationService = new DefaultJwtSigningAndValidationService(signers);
|
||||
|
||||
validationServices.put(serverConfig, signingAndValidationService);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.bouncycastle.math.ec.ECCurve;
|
|||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class EC extends AbstractJwk{
|
||||
public class EllipticCurveJwk extends AbstractJwk {
|
||||
|
||||
public static final String CURVE = "crv";
|
||||
public static final String X = "x";
|
||||
|
@ -51,7 +51,7 @@ public class EC extends AbstractJwk{
|
|||
this.y = y;
|
||||
}
|
||||
|
||||
public EC(JsonObject object) {
|
||||
public EllipticCurveJwk(JsonObject object) {
|
||||
super(object);
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
package org.mitre.jwt.signer.service.impl;
|
||||
package org.mitre.jwt.encryption.impl;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.security.GeneralSecurityException;
|
|
@ -26,9 +26,9 @@ import java.security.interfaces.RSAPrivateKey;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.mitre.jwt.encryption.impl.KeyStore;
|
||||
import org.mitre.jwt.signer.AbstractJwtSigner;
|
||||
import org.mitre.jwt.signer.JwsAlgorithm;
|
||||
import org.mitre.jwt.signer.service.impl.KeyStore;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class JwtSigningAndValidationServiceDefault implements JwtSigningAndValidationService, InitializingBean {
|
||||
public class DefaultJwtSigningAndValidationService implements JwtSigningAndValidationService, InitializingBean {
|
||||
|
||||
@Autowired
|
||||
private ConfigurationPropertiesBean configBean;
|
||||
|
@ -36,21 +36,21 @@ public class JwtSigningAndValidationServiceDefault implements JwtSigningAndValid
|
|||
// map of identifier to signer
|
||||
private Map<String, ? extends JwtSigner> signers = new HashMap<String, JwtSigner>();
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(JwtSigningAndValidationServiceDefault.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(DefaultJwtSigningAndValidationService.class);
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
public JwtSigningAndValidationServiceDefault() {
|
||||
public DefaultJwtSigningAndValidationService() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create JwtSigningAndValidationServiceDefault
|
||||
* Create DefaultJwtSigningAndValidationService
|
||||
*
|
||||
* @param signer
|
||||
* List of JwtSigners to associate with this service
|
||||
*/
|
||||
public JwtSigningAndValidationServiceDefault(Map<String, ? extends JwtSigner> signer) {
|
||||
public DefaultJwtSigningAndValidationService(Map<String, ? extends JwtSigner> signer) {
|
||||
setSigners(signer);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class JwtSigningAndValidationServiceDefault implements JwtSigningAndValid
|
|||
logger.info(this.toString());
|
||||
}
|
||||
|
||||
logger.info("JwtSigningAndValidationServiceDefault is open for business");
|
||||
logger.info("DefaultJwtSigningAndValidationService is open for business");
|
||||
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class JwtSigningAndValidationServiceDefault implements JwtSigningAndValid
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JwtSigningAndValidationServiceDefault [signers=" + signers + "]";
|
||||
return "DefaultJwtSigningAndValidationService [signers=" + signers + "]";
|
||||
}
|
||||
|
||||
/**
|
|
@ -17,9 +17,9 @@ import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
|||
@Entity
|
||||
@Table(name="authentication_holder")
|
||||
@NamedQueries ({
|
||||
@NamedQuery(name = "AuthenticationHolder.getByAuthentication", query = "select a from AuthenticationHolder a where a.authentication = :authentication")
|
||||
@NamedQuery(name = "AuthenticationHolderEntity.getByAuthentication", query = "select a from AuthenticationHolderEntity a where a.authentication = :authentication")
|
||||
})
|
||||
public class AuthenticationHolder {
|
||||
public class AuthenticationHolderEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class AuthenticationHolder {
|
|||
|
||||
private OAuth2Authentication authentication;
|
||||
|
||||
public AuthenticationHolder() {
|
||||
public AuthenticationHolderEntity() {
|
||||
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
|||
|
||||
private ClientDetailsEntity client;
|
||||
|
||||
private AuthenticationHolder authenticationHolder; // the authentication that made this access
|
||||
private AuthenticationHolderEntity authenticationHolder; // the authentication that made this access
|
||||
|
||||
private Jwt jwtValue; // JWT-encoded access token value
|
||||
|
||||
|
@ -122,14 +122,14 @@ public class OAuth2AccessTokenEntity implements OAuth2AccessToken {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "auth_holder_id")
|
||||
public AuthenticationHolder getAuthenticationHolder() {
|
||||
public AuthenticationHolderEntity getAuthenticationHolder() {
|
||||
return authenticationHolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authentication the authentication to set
|
||||
*/
|
||||
public void setAuthenticationHolder(AuthenticationHolder authenticationHolder) {
|
||||
public void setAuthenticationHolder(AuthenticationHolderEntity authenticationHolder) {
|
||||
this.authenticationHolder = authenticationHolder;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
|||
|
||||
private Long id;
|
||||
|
||||
private AuthenticationHolder authenticationHolder;
|
||||
private AuthenticationHolderEntity authenticationHolder;
|
||||
|
||||
private ClientDetailsEntity client;
|
||||
|
||||
|
@ -98,14 +98,14 @@ public class OAuth2RefreshTokenEntity implements OAuth2RefreshToken {
|
|||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "auth_holder_id")
|
||||
public AuthenticationHolder getAuthenticationHolder() {
|
||||
public AuthenticationHolderEntity getAuthenticationHolder() {
|
||||
return authenticationHolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authentication the authentication to set
|
||||
*/
|
||||
public void setAuthenticationHolder(AuthenticationHolder authenticationHolder) {
|
||||
public void setAuthenticationHolder(AuthenticationHolderEntity authenticationHolder) {
|
||||
this.authenticationHolder = authenticationHolder;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package org.mitre.oauth2.repository;
|
||||
|
||||
import org.mitre.oauth2.model.AuthenticationHolder;
|
||||
import org.mitre.oauth2.model.AuthenticationHolderEntity;
|
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
||||
|
||||
public interface AuthenticationHolderRepository {
|
||||
|
||||
public AuthenticationHolder getById(Long id);
|
||||
public AuthenticationHolderEntity getById(Long id);
|
||||
|
||||
public AuthenticationHolder getByAuthentication(OAuth2Authentication a);
|
||||
public AuthenticationHolderEntity getByAuthentication(OAuth2Authentication a);
|
||||
|
||||
public void removeById(Long id);
|
||||
|
||||
public void remove(AuthenticationHolder a);
|
||||
public void remove(AuthenticationHolderEntity a);
|
||||
|
||||
public AuthenticationHolder save(AuthenticationHolder a);
|
||||
public AuthenticationHolderEntity save(AuthenticationHolderEntity a);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.mitre.oauth2.model.AuthenticationHolder;
|
||||
import org.mitre.oauth2.model.AuthenticationHolderEntity;
|
||||
import org.mitre.oauth2.repository.AuthenticationHolderRepository;
|
||||
import org.mitre.util.jpa.JpaUtil;
|
||||
import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
||||
|
@ -19,13 +19,13 @@ public class JpaAuthenticationHolderRepository implements AuthenticationHolderRe
|
|||
private EntityManager manager;
|
||||
|
||||
@Override
|
||||
public AuthenticationHolder getById(Long id) {
|
||||
return manager.find(AuthenticationHolder.class, id);
|
||||
public AuthenticationHolderEntity getById(Long id) {
|
||||
return manager.find(AuthenticationHolderEntity.class, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationHolder getByAuthentication(OAuth2Authentication a) {
|
||||
TypedQuery<AuthenticationHolder> query = manager.createNamedQuery("AuthenticationHolder.getByAuthentication", AuthenticationHolder.class);
|
||||
public AuthenticationHolderEntity getByAuthentication(OAuth2Authentication a) {
|
||||
TypedQuery<AuthenticationHolderEntity> query = manager.createNamedQuery("AuthenticationHolderEntity.getByAuthentication", AuthenticationHolderEntity.class);
|
||||
query.setParameter("authentication", a);
|
||||
return JpaUtil.getSingleResult(query.getResultList());
|
||||
}
|
||||
|
@ -33,28 +33,28 @@ public class JpaAuthenticationHolderRepository implements AuthenticationHolderRe
|
|||
@Override
|
||||
@Transactional
|
||||
public void removeById(Long id) {
|
||||
AuthenticationHolder found = getById(id);
|
||||
AuthenticationHolderEntity found = getById(id);
|
||||
if (found != null) {
|
||||
manager.remove(found);
|
||||
} else {
|
||||
throw new IllegalArgumentException("AuthenticationHolder not found: " + id);
|
||||
throw new IllegalArgumentException("AuthenticationHolderEntity not found: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void remove(AuthenticationHolder a) {
|
||||
AuthenticationHolder found = getById(a.getId());
|
||||
public void remove(AuthenticationHolderEntity a) {
|
||||
AuthenticationHolderEntity found = getById(a.getId());
|
||||
if (found != null) {
|
||||
manager.remove(found);
|
||||
} else {
|
||||
throw new IllegalArgumentException("AuthenticationHolder not found: " + a);
|
||||
throw new IllegalArgumentException("AuthenticationHolderEntity not found: " + a);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AuthenticationHolder save(AuthenticationHolder a) {
|
||||
public AuthenticationHolderEntity save(AuthenticationHolderEntity a) {
|
||||
return JpaUtil.saveOrUpdate(a.getId(), manager, a);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mitre.oauth2.model.AuthenticationHolder;
|
||||
import org.mitre.oauth2.model.AuthenticationHolderEntity;
|
||||
import org.mitre.oauth2.model.ClientDetailsEntity;
|
||||
import org.mitre.oauth2.model.OAuth2AccessTokenEntity;
|
||||
import org.mitre.oauth2.model.OAuth2RefreshTokenEntity;
|
||||
|
@ -98,7 +98,7 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
|
|||
}
|
||||
|
||||
// attach the authorization so that we can look it up later
|
||||
AuthenticationHolder authHolder = new AuthenticationHolder();
|
||||
AuthenticationHolderEntity authHolder = new AuthenticationHolderEntity();
|
||||
authHolder.setAuthentication(authentication);
|
||||
authHolder = authenticationHolderRepository.save(authHolder);
|
||||
|
||||
|
@ -150,7 +150,7 @@ public class DefaultOAuth2ProviderTokenService implements OAuth2TokenEntityServi
|
|||
|
||||
ClientDetailsEntity client = refreshToken.getClient();
|
||||
|
||||
AuthenticationHolder authHolder = refreshToken.getAuthenticationHolder();
|
||||
AuthenticationHolderEntity authHolder = refreshToken.getAuthenticationHolder();
|
||||
|
||||
//Make sure this client allows access token refreshing
|
||||
if (!client.isAllowRefresh()) {
|
||||
|
|
|
@ -40,9 +40,9 @@ import com.google.gson.JsonPrimitive;
|
|||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
public class TokenIntrospection extends AbstractView {
|
||||
public class TokenIntrospectionView extends AbstractView {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(TokenIntrospection.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(TokenIntrospectionView.class);
|
||||
|
||||
@Override
|
||||
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {
|
||||
|
@ -118,7 +118,7 @@ public class TokenIntrospection extends AbstractView {
|
|||
|
||||
} catch (IOException e) {
|
||||
|
||||
logger.error("IOException occurred in TokenIntrospection.java: ", e);
|
||||
logger.error("IOException occurred in TokenIntrospectionView.java: ", e);
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
<class>org.mitre.oauth2.model.ClientDetailsEntity</class>
|
||||
<class>org.mitre.oauth2.model.OAuth2AccessTokenEntity</class>
|
||||
<class>org.mitre.oauth2.model.OAuth2RefreshTokenEntity</class>
|
||||
<class>org.mitre.oauth2.model.AuthenticationHolder</class>
|
||||
<class>org.mitre.oauth2.model.AuthenticationHolderEntity</class>
|
||||
<class>org.mitre.oauth2.model.AuthorizationCodeEntity</class>
|
||||
<class>org.mitre.openid.connect.model.Address</class>
|
||||
<class>org.mitre.openid.connect.model.ApprovedSite</class>
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="defaultKeystore" class="org.mitre.jwt.signer.service.impl.KeyStore">
|
||||
<bean id="defaultKeystore" class="org.mitre.jwt.encryption.impl.KeyStore">
|
||||
<constructor-arg name="location" value="classpath:keystore.jks" />
|
||||
<constructor-arg name="password" value="changeit" />
|
||||
</bean>
|
||||
|
||||
<bean id="defaultsignerService"
|
||||
class="org.mitre.jwt.signer.service.impl.JwtSigningAndValidationServiceDefault">
|
||||
class="org.mitre.jwt.signer.service.impl.DefaultJwtSigningAndValidationService">
|
||||
<property name="signers">
|
||||
<map>
|
||||
<entry key="rsa1">
|
||||
|
|
|
@ -33,13 +33,13 @@ import org.bouncycastle.jce.X509Principal;
|
|||
import org.bouncycastle.x509.X509V3CertificateGenerator;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mitre.jwt.encryption.impl.KeyStore;
|
||||
import org.mitre.jwt.model.Jwt;
|
||||
import org.mitre.jwt.signer.JwsAlgorithm;
|
||||
import org.mitre.jwt.signer.JwtSigner;
|
||||
import org.mitre.jwt.signer.impl.HmacSigner;
|
||||
import org.mitre.jwt.signer.impl.PlaintextSigner;
|
||||
import org.mitre.jwt.signer.impl.RsaSigner;
|
||||
import org.mitre.jwt.signer.service.impl.KeyStore;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|||
import org.bouncycastle.x509.X509V3CertificateGenerator;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mitre.jwt.encryption.impl.KeyStore;
|
||||
import org.mitre.jwt.signer.impl.RsaSigner;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
</bean>
|
||||
|
||||
|
||||
<bean id="testKeystore" class="org.mitre.jwt.signer.service.impl.KeyStore">
|
||||
<bean id="testKeystore" class="org.mitre.jwt.encryption.impl.KeyStore">
|
||||
<constructor-arg name="location" value="file:src/test/resources/keystore.jks" />
|
||||
<constructor-arg name="password" value="changeit" />
|
||||
</bean>
|
||||
|
|
Loading…
Reference in New Issue