-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from rglauco/main
- added federation_entity metadata parameters - added policy page - add federation resolve endpoint in example module - renamed "trust_mark_issuers"
- Loading branch information
Showing
22 changed files
with
1,351 additions
and
649 deletions.
There are no files selected for viewing
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
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
76 changes: 76 additions & 0 deletions
76
...java/it/spid/cie/oidc/spring/boot/relying/party/controller/EntityStatementController.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,76 @@ | ||
package it.spid.cie.oidc.spring.boot.relying.party.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.json.JSONObject; | ||
import org.json.JSONArray; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import it.spid.cie.oidc.config.RelyingPartyOptions; | ||
import it.spid.cie.oidc.exception.OIDCException; | ||
import it.spid.cie.oidc.model.FederationEntity; | ||
import it.spid.cie.oidc.spring.boot.relying.party.RelyingPartyWrapper; | ||
import it.spid.cie.oidc.spring.boot.relying.party.config.OidcConfig; | ||
import it.spid.cie.oidc.spring.boot.relying.party.persistence.H2PersistenceImpl; | ||
import it.spid.cie.oidc.model.TrustChain; | ||
import it.spid.cie.oidc.helper.JWTHelper; | ||
|
||
@RestController | ||
@RequestMapping("/oidc/rp") | ||
public class EntityStatementController { | ||
private static final Logger logger = LoggerFactory.getLogger(RelyingPartyWrapper.class); | ||
@Autowired | ||
private OidcConfig oidcConfig; | ||
@Autowired | ||
private H2PersistenceImpl persistenceImpl; | ||
|
||
@GetMapping("/resolve") | ||
public ResponseEntity<String> resolveEntityStatement( | ||
@RequestParam String sub, | ||
@RequestParam String anchor, | ||
@RequestParam(defaultValue = "jose") String format | ||
) throws OIDCException { | ||
|
||
if (sub == null || anchor == null) { | ||
return new ResponseEntity<>("sub and anchor parameters are REQUIRED.", HttpStatus.NOT_FOUND); | ||
} | ||
String iss = oidcConfig.getRelyingParty().getClientId(); | ||
|
||
FederationEntity entityConfiguration = persistenceImpl.fetchFederationEntity(iss, true); | ||
|
||
TrustChain entity = persistenceImpl.fetchTrustChain(sub, anchor); | ||
|
||
if (entity == null) { | ||
return new ResponseEntity<>("entity not found.", HttpStatus.NOT_FOUND); | ||
} | ||
JSONObject metadata = new JSONObject(entity.getMetadata()); | ||
JSONArray trust_chain = new JSONArray(entity.getChain()); | ||
|
||
JSONObject response = new JSONObject(); | ||
response.put("iss", iss); | ||
response.put("sub", sub); | ||
response.put("iat", entity.getIssuedAt()); | ||
response.put("exp", entity.getExpiresOn()); | ||
response.put("trust_marks", entity.getTrustMarks()); | ||
response.put("metadata", metadata); | ||
response.put("trust_chain",trust_chain); | ||
|
||
logger.info("resolve endpoint for {}, {}", sub, anchor); | ||
|
||
if ("json".equals(format)) { | ||
return ResponseEntity.ok() | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.body(response.toString()); | ||
} else { | ||
JWTHelper jws = new JWTHelper(new RelyingPartyOptions()); | ||
return new ResponseEntity<>(jws.createJWS(response, JWTHelper.getJWKSetFromJSON(entityConfiguration.getJwks())), HttpStatus.OK); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...src/main/java/it/spid/cie/oidc/spring/boot/relying/party/controller/PolicyController.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,29 @@ | ||
package it.spid.cie.oidc.spring.boot.relying.party.controller; | ||
|
||
import java.util.List; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
import it.spid.cie.oidc.schemas.OIDCProfile; | ||
import it.spid.cie.oidc.schemas.ProviderButtonInfo; | ||
import it.spid.cie.oidc.spring.boot.relying.party.RelyingPartyWrapper; | ||
|
||
@RestController | ||
@RequestMapping("/oidc/rp") | ||
public class PolicyController { | ||
@GetMapping("/policy") | ||
public ModelAndView home(HttpServletRequest request) | ||
throws Exception { | ||
|
||
ModelAndView mav = new ModelAndView("policy"); | ||
|
||
return mav; | ||
} | ||
|
||
} |
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
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
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 |
---|---|---|
|
@@ -66,6 +66,14 @@ oidc: | |
userinfo-encrypted-response-alg: "RSA-OAEP" | ||
userinfo-encrypted-response-enc: "A128CBC-HS256" | ||
|
||
federation-resolve-endpoint: "http://${oidc.hosts.relying-party}:8080/resolve" | ||
organization-name: "PA OIDC Relying Party" | ||
homepage-uri: "http://${oidc.hosts.relying-party}:8080/oidc/rp/landing" | ||
policy-uri: "http://${oidc.hosts.relying-party}:8080/oidc/rp/policy" | ||
logo-uri: "http://${oidc.hosts.relying-party}:8080/static/images/logo-it.svg" | ||
federation-contacts: | ||
- "[email protected]" | ||
|
||
client-id: "http://${oidc.hosts.relying-party}:8080/oidc/rp/" | ||
redirect-uris: | ||
- "http://${oidc.hosts.relying-party}:8080/oidc/rp/callback" | ||
|
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
Oops, something went wrong.