Search in sources :

Example 1 with WebFingerProcessor

use of org.wso2.carbon.identity.webfinger.WebFingerProcessor in project identity-inbound-auth-oauth by wso2-extensions.

the class WebFingerServiceComponent method activate.

protected void activate(ComponentContext context) {
    try {
        BundleContext bundleContext = context.getBundleContext();
        WebFingerProcessor webFingerProcessor = DefaultWebFingerProcessor.getInstance();
        bundleContext.registerService(WebFingerProcessor.class.getName(), webFingerProcessor, null);
        WebFingerServiceComponentHolder.setWebFingerProcessor(webFingerProcessor);
        if (log.isDebugEnabled()) {
            log.debug("OpenID WebFinger bundle is activated.");
        }
        // Register OpenID Connect WebFinger servlet
        HttpService httpService = WebFingerServiceComponentHolder.getHttpService();
        Servlet webFingerServlet = new ContextPathServletAdaptor(new WebFingerServlet(), "/.well-known/webfinger");
        try {
            httpService.registerServlet("/.well-known/webfinger", webFingerServlet, null, null);
        } catch (Exception e) {
            String errMsg = "Error when registering Web Finger Servlet via the HttpService.";
            log.error(errMsg, e);
            throw new RuntimeException(errMsg, e);
        }
    } catch (Throwable e) {
        log.error("Error while activating the WebFingerServiceComponent", e);
    }
}
Also used : HttpService(org.osgi.service.http.HttpService) WebFingerServlet(org.wso2.carbon.identity.webfinger.servlet.WebFingerServlet) DefaultWebFingerProcessor(org.wso2.carbon.identity.webfinger.DefaultWebFingerProcessor) WebFingerProcessor(org.wso2.carbon.identity.webfinger.WebFingerProcessor) WebFingerServlet(org.wso2.carbon.identity.webfinger.servlet.WebFingerServlet) Servlet(javax.servlet.Servlet) BundleContext(org.osgi.framework.BundleContext) ContextPathServletAdaptor(org.eclipse.equinox.http.helper.ContextPathServletAdaptor)

Example 2 with WebFingerProcessor

use of org.wso2.carbon.identity.webfinger.WebFingerProcessor 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);
}
Also used : ServerConfigurationException(org.wso2.carbon.base.ServerConfigurationException) WebFingerResponseBuilder(org.wso2.carbon.identity.webfinger.builders.WebFingerResponseBuilder) WebFingerProcessor(org.wso2.carbon.identity.webfinger.WebFingerProcessor) WebFingerEndpointException(org.wso2.carbon.identity.webfinger.WebFingerEndpointException) PrintWriter(java.io.PrintWriter)

Aggregations

WebFingerProcessor (org.wso2.carbon.identity.webfinger.WebFingerProcessor)2 PrintWriter (java.io.PrintWriter)1 Servlet (javax.servlet.Servlet)1 ContextPathServletAdaptor (org.eclipse.equinox.http.helper.ContextPathServletAdaptor)1 BundleContext (org.osgi.framework.BundleContext)1 HttpService (org.osgi.service.http.HttpService)1 ServerConfigurationException (org.wso2.carbon.base.ServerConfigurationException)1 DefaultWebFingerProcessor (org.wso2.carbon.identity.webfinger.DefaultWebFingerProcessor)1 WebFingerEndpointException (org.wso2.carbon.identity.webfinger.WebFingerEndpointException)1 WebFingerResponseBuilder (org.wso2.carbon.identity.webfinger.builders.WebFingerResponseBuilder)1 WebFingerServlet (org.wso2.carbon.identity.webfinger.servlet.WebFingerServlet)1