Browse Source

signers turned into a map

pull/59/head
Justin Richer 13 years ago
parent
commit
524a8e153e
  1. 14
      openid-connect-server/src/main/java/org/mitre/jwt/signer/service/impl/JwtSigningAndValidationServiceDefault.java
  2. 7
      openid-connect-server/src/main/java/org/mitre/jwt/signer/service/impl/KeyStore.java
  3. 38
      openid-connect-server/src/main/webapp/WEB-INF/spring/application-context.xml

14
openid-connect-server/src/main/java/org/mitre/jwt/signer/service/impl/JwtSigningAndValidationServiceDefault.java

@ -20,8 +20,8 @@ import org.springframework.beans.factory.InitializingBean;
public class JwtSigningAndValidationServiceDefault implements
JwtSigningAndValidationService, InitializingBean {
private List<? extends JwtSigner> signers = new ArrayList<JwtSigner>();
// map of identifier to signer
private Map<String, ? extends JwtSigner> signers = new HashMap<String, JwtSigner>();
private static Log logger = LogFactory
.getLog(JwtSigningAndValidationServiceDefault.class);
@ -39,7 +39,7 @@ public class JwtSigningAndValidationServiceDefault implements
* List of JwtSigners to associate with this service
*/
public JwtSigningAndValidationServiceDefault(
List<? extends JwtSigner> signer) {
Map<String, ? extends JwtSigner> signer) {
setSigners(signer);
}
@ -74,7 +74,7 @@ public class JwtSigningAndValidationServiceDefault implements
PublicKey publicKey;
for (JwtSigner signer : signers) {
for (JwtSigner signer : signers.values()) {
if (signer instanceof RsaSigner) {
@ -101,7 +101,7 @@ public class JwtSigningAndValidationServiceDefault implements
*
* @return
*/
public List<? extends JwtSigner> getSigners() {
public Map<String, ? extends JwtSigner> getSigners() {
return signers;
}
@ -130,7 +130,7 @@ public class JwtSigningAndValidationServiceDefault implements
* @param signers
* List of JwtSigners to associate with this service
*/
public void setSigners(List<? extends JwtSigner> signers) {
public void setSigners(Map<String, ? extends JwtSigner> signers) {
this.signers = signers;
}
@ -169,7 +169,7 @@ public class JwtSigningAndValidationServiceDefault implements
@Override
public boolean validateSignature(String jwtString) {
for (JwtSigner signer : signers) {
for (JwtSigner signer : signers.values()) {
if (signer.verify(jwtString))
return true;
}

7
openid-connect-server/src/main/java/org/mitre/jwt/signer/service/impl/KeyStore.java

@ -32,13 +32,6 @@ public class KeyStore implements InitializingBean {
private java.security.KeyStore keystore;
/**
* default constructor
*/
public KeyStore() {
this(PASSWORD, null);
}
/**
* KeyStore constructor
*

38
openid-connect-server/src/main/webapp/WEB-INF/spring/application-context.xml

@ -109,12 +109,40 @@
<!-- TODO: working remove red X's see: http://forum.springsource.org/showthread.php?123193-STS-not-respecting-META-INF-spring-schemas-for-validation&p=401926#post401926 -->
<jwt-signer:keystore id="defaultKeystore" location="classpath:keystore.jks" password="changeit" />
<jwt-signer:service id="defaultSignerService">
<jwt-signer:rsa bits="256" keystore-ref="defaultKeystore" key-alias="rsa" password="changeit" />
<jwt-signer:hmac bits="256" passphrase="changeit" />
</jwt-signer:service>
<bean id="defaultKeystore" class="org.mitre.jwt.signer.service.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">
<property name="signers">
<map>
<entry key="rsa1">
<bean id="rsaSigner" class="org.mitre.jwt.signer.impl.RsaSigner">
<property name="algorithm" value="RS256" />
<property name="keystore" ref="defaultKeystore" />
<property name="alias" value="rsa" />
<property name="password" value="changeit" />
</bean>
</entry>
<entry key="hmac1">
<bean id="hmacSigner" class="org.mitre.jwt.signer.impl.HmacSigner">
<property name="algorithm" value="HMACSHA256" />
<property name="passphrase" value="changeit" />
</bean>
</entry>
</map>
</property>
</bean>
<!-- <jwt-signer:keystore id="defaultKeystore" location="classpath:keystore.jks" password="changeit" /> -->
<!-- <jwt-signer:service id="defaultSignerService"> -->
<!-- <jwt-signer:rsa bits="256" keystore-ref="defaultKeystore" key-alias="rsa" password="changeit" /> -->
<!-- <jwt-signer:hmac bits="256" passphrase="changeit" /> -->
<!-- </jwt-signer:service> -->
<!-- scheduled tasks -->
<!-- <task:scheduler id="taskScheduler" pool-size="10" /> -->

Loading…
Cancel
Save