use of org.wso2.carbon.base.ServerConfigurationException in project identity-inbound-auth-oauth by wso2-extensions.
the class OIDCDiscoveryEndpoint method getResponse.
private Response getResponse(HttpServletRequest request, String tenant) {
String response;
OIDCProcessor processor = EndpointUtil.getOIDCService();
try {
OIDProviderResponseBuilder responseBuilder = getOidProviderResponseBuilder();
response = responseBuilder.getOIDProviderConfigString(processor.getResponse(request, tenant));
} catch (OIDCDiscoveryEndPointException e) {
Response.ResponseBuilder errorResponse = Response.status(processor.handleError(e));
return errorResponse.entity(e.getMessage()).build();
} catch (ServerConfigurationException e) {
log.error("Server Configuration error occurred.", e);
Response.ResponseBuilder errorResponse = Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return errorResponse.entity("Error in reading configuration.").build();
}
Response.ResponseBuilder responseBuilder = Response.status(HttpServletResponse.SC_OK);
return responseBuilder.entity(response).build();
}
use of org.wso2.carbon.base.ServerConfigurationException in project identity-inbound-auth-oauth by wso2-extensions.
the class DefaultOIDCProcessor method getResponse.
public OIDProviderConfigResponse getResponse(HttpServletRequest request, String tenantDomain) throws OIDCDiscoveryEndPointException, ServerConfigurationException {
OIDCProviderRequestBuilder requestBuilder = new DefaultOIDCProviderRequestBuilder();
OIDProviderRequest requestObject = requestBuilder.buildRequest(request, tenantDomain);
ProviderConfigBuilder responseBuilder = new ProviderConfigBuilder();
return responseBuilder.buildOIDProviderConfig(requestObject);
}
use of org.wso2.carbon.base.ServerConfigurationException in project identity-inbound-auth-oauth by wso2-extensions.
the class WebFingerOIDCResponseBuilderTest method testBuildWebFingerException.
@Test(expectedExceptions = ServerConfigurationException.class)
public void testBuildWebFingerException() throws WebFingerEndpointException, ServerConfigurationException, IdentityException {
when(OAuth2Util.getIssuerLocation(any(String.class))).thenThrow(new IdentityOAuth2Exception("Error"));
webFingerOIDCResponseBuilder.buildWebFingerResponse(webFingerRequest);
}
use of org.wso2.carbon.base.ServerConfigurationException in project identity-inbound-auth-oauth by wso2-extensions.
the class WebFingerOIDCResponseBuilder method buildWebFingerResponse.
public WebFingerResponse buildWebFingerResponse(WebFingerRequest request) throws WebFingerEndpointException, ServerConfigurationException {
WebFingerResponse response;
String oidcIssuerLocation;
try {
oidcIssuerLocation = getOidcIssuerLocation(request.getTenant());
} catch (URISyntaxException | IdentityOAuth2Exception e) {
throw new ServerConfigurationException("Error while building discovery endpoint", e);
}
response = new WebFingerResponse();
response.setSubject(request.getResource());
response.addLink(WebFingerConstants.OPENID_CONNETCT_ISSUER_REL, oidcIssuerLocation);
return response;
}
use of org.wso2.carbon.base.ServerConfigurationException in project identity-inbound-auth-oauth by wso2-extensions.
the class WebFingerServlet method getOIDProviderIssuer.
public void getOIDProviderIssuer(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
WebFingerProcessor processor = WebFingerServiceComponentHolder.getWebFingerProcessor();
String response = "";
try {
WebFingerResponseBuilder webFingerResponseBuilder = new JSONResponseBuilder();
response = webFingerResponseBuilder.getOIDProviderIssuerString(processor.getResponse(httpServletRequest));
} catch (WebFingerEndpointException e) {
httpServletResponse.setStatus(processor.handleError(e));
return;
} catch (ServerConfigurationException e) {
log.error("Server Configuration error occurred.", e);
httpServletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
httpServletResponse.setContentType(WebFingerConstants.RESPONSE_CONTENT_TYPE);
PrintWriter out = httpServletResponse.getWriter();
out.print(response);
}
Aggregations