oidc.issuer is loaded from properties + success session check for success.jsp
This commit is contained in:
parent
79407a4555
commit
85a582f48b
|
@ -17,11 +17,20 @@ import eu.dnetlib.openaire.usermanagement.security.JWTGenerator;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.mitre.openid.connect.model.UserInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.client.DefaultResponseErrorHandler;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
@ -45,6 +54,9 @@ public class Test3Service {
|
|||
@Autowired
|
||||
private DataSourceConnector dataSourceConnector;
|
||||
|
||||
@Value("${oidc.issuer}")
|
||||
private String issuer;
|
||||
|
||||
@GET
|
||||
@Path("/{userId}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
|
@ -213,17 +225,19 @@ public class Test3Service {
|
|||
@Path("/getUserInfo")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response getUserInfo(@QueryParam("accessToken") String accessToken) throws JsonProcessingException {
|
||||
|
||||
//return Response.status(404).entity(compose404Message("This is a test message.")).type(MediaType.APPLICATION_JSON).build();
|
||||
|
||||
// call aai with accessToken
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.setErrorHandler(new DefaultResponseErrorHandler(){
|
||||
protected boolean hasError(HttpStatus statusCode) {
|
||||
return false;
|
||||
}});
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("Authorization","Bearer " + accessToken);
|
||||
HttpEntity request = new HttpEntity(null, headers);
|
||||
String fooResourceUrl = "https://aai.openminted.eu/oidc/userinfo";
|
||||
String fooResourceUrl = issuer +"userinfo";
|
||||
|
||||
logger.info(restTemplate.exchange(fooResourceUrl, HttpMethod.GET, request, Object.class));
|
||||
//logger.info(restTemplate.exchange(fooResourceUrl, HttpMethod.GET, request, Object.class));
|
||||
ResponseEntity response1 = restTemplate.exchange(fooResourceUrl, HttpMethod.GET, request, Object.class);
|
||||
logger.info(response1.getBody().toString());
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
@ -267,4 +281,12 @@ public class Test3Service {
|
|||
private String composeDataResponse(String fullname) {
|
||||
return " { \"status\" : \"success\", \"code\": \"200\", " + "\"data\" : " + new Gson().toJson(fullname) + " }";
|
||||
}
|
||||
|
||||
public String getIssuer() {
|
||||
return issuer;
|
||||
}
|
||||
|
||||
public void setIssuer(String issuer) {
|
||||
this.issuer = issuer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
http://www.springframework.org/schema/context/spring-context-4.2.xsd">
|
||||
|
||||
|
||||
<context:component-scan base-package="eu.dnetlib.openaire.usermanagement.registry.beans"/>
|
||||
<context:component-scan base-package="eu.dnetlib.openaire.usermanagement.*"/>
|
||||
<context:annotation-config />
|
||||
|
||||
|
||||
|
||||
<import resource="classpath*:/eu/dnetlib/openaire/user/springContext-userManagementService.xml" />
|
||||
|
||||
<!--<bean id="webexpressionHandler"-->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
log4j.rootLogger = WARN, R
|
||||
log4j.rootLogger = DEBUG, R
|
||||
|
||||
log4j.logger.eu.dnetlib = INFO
|
||||
log4j.logger.eu.dnetlib = DEBUG
|
||||
log4j.logger.org.mitre.openid = INFO
|
||||
log4j.logger.org.springframework = INFO, S
|
||||
|
||||
|
|
|
@ -11,7 +11,11 @@
|
|||
<% if (session.getAttribute("success") == null) {
|
||||
String redirectURL = request.getContextPath() + "/error404.jsp";
|
||||
response.sendRedirect(redirectURL);
|
||||
}%>
|
||||
|
||||
} else if (session.getAttribute("success")!=null) {
|
||||
session.removeAttribute("success");
|
||||
}
|
||||
%>
|
||||
<META HTTP-EQUIV=Refresh CONTENT="0.5; URL=http://beta.services.openaire.eu/uoa-user-management/openid_connect_login">
|
||||
<html lang="en-gb" dir="ltr" vocab="http://schema.org/">
|
||||
<head>
|
||||
|
|
Loading…
Reference in New Issue