Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean web finger ep #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
* Singleton class to process the webfinger request.
*/
public class DefaultWebFingerProcessor implements WebFingerProcessor {
private static final Log log = LogFactory.getLog(DefaultWebFingerProcessor.class);
private static final Log LOG = LogFactory.getLog(DefaultWebFingerProcessor.class);
private static DefaultWebFingerProcessor defaultWebFingerProcessor = new DefaultWebFingerProcessor();

private DefaultWebFingerProcessor() {
if (log.isDebugEnabled()) {
log.debug("Initializing OIDCProcessor for OpenID connect discovery processor.");
}

LOG.debug("Initializing OIDCProcessor for OpenID connect discovery processor.");
}

public static DefaultWebFingerProcessor getInstance() {
Expand All @@ -56,27 +55,26 @@ public WebFingerResponse getResponse(HttpServletRequest request) throws WebFinge
public int handleError(WebFingerEndpointException error) {
String errorCode = error.getErrorCode();
if (WebFingerConstants.ERROR_CODE_INVALID_REQUEST.equals(errorCode)) {
if (log.isDebugEnabled()) {
log.debug(error);
if (LOG.isDebugEnabled()) {
LOG.debug(error);
}
return HttpServletResponse.SC_BAD_REQUEST;
} else if (WebFingerConstants.ERROR_CODE_INVALID_RESOURCE.equals(errorCode)) {
if (log.isDebugEnabled()) {
log.debug(error);
if (LOG.isDebugEnabled()) {
LOG.debug(error);
}
return HttpServletResponse.SC_NOT_FOUND;
} else if (WebFingerConstants.ERROR_CODE_JSON_EXCEPTION.equals(errorCode)) {
if (log.isDebugEnabled()) {
log.debug(error);
if (LOG.isDebugEnabled()) {
LOG.debug(error);
}
return HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE;
} else if (WebFingerConstants.ERROR_CODE_NO_WEBFINGER_CONFIG.equals(errorCode)) {
log.error(WebFingerConstants.ERROR_MESSAGE_NO_WEBFINGER_CONFIG, error);
LOG.error(WebFingerConstants.ERROR_MESSAGE_NO_WEBFINGER_CONFIG, error);
return HttpServletResponse.SC_NOT_FOUND;
} else {
log.error("Internal server error occured. ", error);
LOG.error("Internal server error occured. ", error);
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,4 @@ public WebFingerResponse getResponse() {
public void setResponse(WebFingerResponse response) {
this.response = response;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.wso2.carbon.identity.webfinger;


import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -52,5 +51,4 @@ public void addLink(String rel, String href) {
link.setHref(href);
this.links.add(link);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,4 @@ public String getRel() {
public void setRel(String rel) {
this.rel = rel;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
public class DefaultWebFingerRequestBuilder implements WebFingerRequestBuilder {

private static final Log log = LogFactory.getLog(DefaultWebFingerRequestBuilder.class);
private static final Log LOG = LogFactory.getLog(DefaultWebFingerRequestBuilder.class);

@Override
public WebFingerRequest buildRequest(HttpServletRequest request) throws WebFingerEndpointException {
Expand All @@ -59,7 +59,7 @@ public WebFingerRequest buildRequest(HttpServletRequest request) throws WebFinge
webFingerRequest.setResource(resource);

if (StringUtils.isBlank(resource)) {
log.warn("Can't normalize null or empty URI: " + resource);
LOG.warn("Can't normalize null or empty URI: " + resource);
throw new WebFingerEndpointException(WebFingerConstants.ERROR_CODE_INVALID_RESOURCE, "Null or empty URI.");

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package org.wso2.carbon.identity.webfinger.builders;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.base.ServerConfigurationException;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.util.OAuth2Util;
Expand All @@ -38,8 +36,6 @@
*/
public class WebFingerOIDCResponseBuilder {

private static final Log log = LogFactory.getLog(WebFingerOIDCResponseBuilder.class);

public WebFingerResponse buildWebFingerResponse(WebFingerRequest request) throws WebFingerEndpointException,
ServerConfigurationException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@
immediate = true
)
public class WebFingerServiceComponent {
private static final Log log = LogFactory.getLog(WebFingerServiceComponent.class);
private static final Log LOG = LogFactory.getLog(WebFingerServiceComponent.class);

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.");
}
LOG.debug("OpenID WebFinger bundle is activated.");


// Register OpenID Connect WebFinger servlet
HttpService httpService = WebFingerServiceComponentHolder.getHttpService();
Expand All @@ -63,11 +62,11 @@ protected void activate(ComponentContext context) {
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);
LOG.error(errMsg, e);
throw new RuntimeException(errMsg, e);
}
} catch (Throwable e) {
log.error("Error while activating the WebFingerServiceComponent", e);
LOG.error("Error while activating the WebFingerServiceComponent", e);
}
}

Expand All @@ -79,16 +78,14 @@ protected void activate(ComponentContext context) {
unbind = "unsetRealmService"
)
protected void setRealmService(RealmService realmService) {
if (log.isDebugEnabled()) {
log.info("Setting the Realm Service");
}

LOG.info("Setting the Realm Service");
WebFingerServiceComponentHolder.setRealmService(realmService);
}

protected void unsetRealmService(RealmService realmService) {
if (log.isDebugEnabled()) {
log.info("Unsetting the Realm Service");
}

LOG.info("Unsetting the Realm Service");
WebFingerServiceComponentHolder.setRealmService(null);
}

Expand All @@ -100,16 +97,14 @@ protected void unsetRealmService(RealmService realmService) {
unbind = "unsetHttpService"
)
protected void setHttpService(HttpService httpService) {
if (log.isDebugEnabled()) {
log.debug("HTTP Service is set in the OpenID Connect WebFinger bundle");
}

LOG.debug("HTTP Service is set in the OpenID Connect WebFinger bundle");
WebFingerServiceComponentHolder.setHttpService(httpService);
}

protected void unsetHttpService(HttpService httpService) {
if (log.isDebugEnabled()) {
log.debug("HTTP Service is unset in the OpenID Connect WebFinger bundle");
}

LOG.debug("HTTP Service is unset in the OpenID Connect WebFinger bundle");
WebFingerServiceComponentHolder.setHttpService(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@


import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.webfinger.WebFingerEndpointException;
import org.wso2.carbon.identity.webfinger.WebFingerResponse;
import org.wso2.carbon.identity.webfinger.builders.WebFingerResponseBuilder;
Expand All @@ -30,7 +28,6 @@
* Webfinger response builder
*/
public class JSONResponseBuilder implements WebFingerResponseBuilder {
private static final Log log = LogFactory.getLog(JSONResponseBuilder.class);

@Override
public String getOIDProviderIssuerString(WebFingerResponse webFingerResponse) throws WebFingerEndpointException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* Webfinger endpoint. Servelet is registered for the path /.well-known/webfinger
*/
public class WebFingerServlet extends HttpServlet {
private static final Log log = LogFactory.getLog(WebFingerServlet.class);
private static final Log LOG = LogFactory.getLog(WebFingerServlet.class);

@Override
protected void doGet(HttpServletRequest httpServletRequest,
Expand All @@ -57,7 +57,7 @@ public void getOIDProviderIssuer(HttpServletRequest httpServletRequest,
httpServletResponse.setStatus(processor.handleError(e));
return;
} catch (ServerConfigurationException e) {
log.error("Server Configuration error occurred.", e);
LOG.error("Server Configuration error occurred.", e);
httpServletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
Expand Down
Loading