|
|
@ -22,6 +22,7 @@ import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.mitre.discovery.util.WebfingerURLNormalizer;
|
|
|
|
import org.mitre.jwt.signer.service.JwtSigningAndValidationService;
|
|
|
|
import org.mitre.jwt.signer.service.JwtSigningAndValidationService;
|
|
|
|
import org.mitre.oauth2.service.SystemScopeService;
|
|
|
|
import org.mitre.oauth2.service.SystemScopeService;
|
|
|
|
import org.mitre.openid.connect.config.ConfigurationPropertiesBean;
|
|
|
|
import org.mitre.openid.connect.config.ConfigurationPropertiesBean;
|
|
|
@ -35,6 +36,7 @@ import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
|
|
import org.springframework.web.util.UriComponents;
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.base.Function;
|
|
|
|
import com.google.common.base.Function;
|
|
|
|
import com.google.common.base.Splitter;
|
|
|
|
import com.google.common.base.Splitter;
|
|
|
@ -86,20 +88,14 @@ public class DiscoveryEndpoint {
|
|
|
|
if (!resource.equals(config.getIssuer())) {
|
|
|
|
if (!resource.equals(config.getIssuer())) {
|
|
|
|
// it's not the issuer directly, need to check other methods
|
|
|
|
// it's not the issuer directly, need to check other methods
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
UriComponents resourceUri = WebfingerURLNormalizer.normalizeResource(resource);
|
|
|
|
URI resourceUri = new URI(resource);
|
|
|
|
|
|
|
|
if (resourceUri != null
|
|
|
|
if (resourceUri != null
|
|
|
|
&& resourceUri.getScheme() != null
|
|
|
|
&& resourceUri.getScheme() != null
|
|
|
|
&& resourceUri.getScheme().equals("acct")) {
|
|
|
|
&& resourceUri.getScheme().equals("acct")) {
|
|
|
|
// acct: URI
|
|
|
|
// acct: URI
|
|
|
|
|
|
|
|
|
|
|
|
// split out the user and host parts
|
|
|
|
|
|
|
|
List<String> parts = Lists.newArrayList(Splitter.on("@").split(resourceUri.getSchemeSpecificPart()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserInfo user = null;
|
|
|
|
UserInfo user = null;
|
|
|
|
if (parts.size() > 0) {
|
|
|
|
user = userService.getByUsername(resourceUri.getUserInfo()); // first part is the username
|
|
|
|
user = userService.getByUsername(parts.get(0)); // first part is the username
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user == null) {
|
|
|
|
if (user == null) {
|
|
|
|
logger.info("User not found: " + resource);
|
|
|
|
logger.info("User not found: " + resource);
|
|
|
@ -113,11 +109,6 @@ public class DiscoveryEndpoint {
|
|
|
|
model.addAttribute("code", HttpStatus.NOT_FOUND);
|
|
|
|
model.addAttribute("code", HttpStatus.NOT_FOUND);
|
|
|
|
return "httpCodeView";
|
|
|
|
return "httpCodeView";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (URISyntaxException e) {
|
|
|
|
|
|
|
|
logger.info("URI parsing exception: " + resource, e);
|
|
|
|
|
|
|
|
model.addAttribute("code", HttpStatus.NOT_FOUND);
|
|
|
|
|
|
|
|
return "httpCodeView";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// if we got here, then we're good
|
|
|
|
// if we got here, then we're good
|
|
|
|