Added IdTokenGeneratorService interface and DummyIdTokenGeneratorService.java, a dumb implementation of that interface. IdTokenGeneratorService is responsible for generating an IdToken for the ConnectAuthCodeTokenGranter when requested.
parent
46e0673d0e
commit
bf6408c671
|
@ -9,6 +9,7 @@ import java.util.Set;
|
|||
import org.mitre.oauth2.model.OAuth2AccessTokenEntity;
|
||||
import org.mitre.oauth2.service.impl.DefaultOAuth2ProviderTokenService;
|
||||
import org.mitre.openid.connect.model.IdToken;
|
||||
import org.mitre.util.Utility;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
||||
|
@ -50,6 +51,9 @@ public class ConnectAuthCodeTokenGranter implements TokenGranter {
|
|||
@Autowired
|
||||
private DefaultOAuth2ProviderTokenService tokenServices;
|
||||
|
||||
@Autowired
|
||||
private IdTokenGeneratorService idTokenService;
|
||||
|
||||
|
||||
/**
|
||||
* Default empty constructor
|
||||
|
@ -136,11 +140,13 @@ public class ConnectAuthCodeTokenGranter implements TokenGranter {
|
|||
* has the proper scope, we can consider this a valid OpenID Connect request.
|
||||
*/
|
||||
if (authorizationRequest.getScope().contains("openid")) {
|
||||
IdToken idToken = new IdToken();
|
||||
|
||||
//TODO: build IdToken
|
||||
String userId = parameters.get("user_id");
|
||||
|
||||
//TODO: need to get base url, but Utility.findBaseUrl() needs access to a request object, which we don't have
|
||||
//See github issue #1
|
||||
IdToken idToken = idTokenService.generateIdToken(userId, "http://id.mitre.org/openidconnect");
|
||||
|
||||
//Where does the data for the IdToken come from?
|
||||
|
||||
//TODO: insert IdToken into OAuth2AccessTokenEntity
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.mitre.openid.connect.token;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.mitre.openid.connect.model.IdToken;
|
||||
import org.mitre.openid.connect.model.IdTokenClaims;
|
||||
import org.mitre.util.Utility;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Dummy implementation of the IdTokenGeneratorService.
|
||||
*
|
||||
* A concrete implementation would need access to a data service that
|
||||
* would provide information / claims about the users in the system. This
|
||||
* information would be pulled up by the given userId and inserted into
|
||||
* a new IdToken.
|
||||
*
|
||||
* @author AANGANES
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class DummyIdTokenGeneratorService implements IdTokenGeneratorService {
|
||||
|
||||
@Override
|
||||
public IdToken generateIdToken(String userId, String issuer) {
|
||||
IdToken token = new IdToken();
|
||||
|
||||
IdTokenClaims claims = new IdTokenClaims();
|
||||
claims.setAuthTime(new Date());
|
||||
claims.setIssuer(issuer);
|
||||
claims.setUserId(userId);
|
||||
|
||||
token.setClaims(claims);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.mitre.openid.connect.token;
|
||||
|
||||
import org.mitre.openid.connect.model.IdToken;
|
||||
|
||||
public interface IdTokenGeneratorService {
|
||||
|
||||
public IdToken generateIdToken(String userId, String issuer);
|
||||
|
||||
}
|
Loading…
Reference in New Issue