public void storeOAuth2Accessor(final OAuth2Accessor accessor) { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "storeOAuth2Accessor", accessor); } this.cache.storeOAuth2Accessor(accessor); if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "storeOAuth2Accessor"); } }
public OAuth2Accessor getOAuth2Accessor(final OAuth2CallbackState state) { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "getOAuth2Accessor", state); } final OAuth2Accessor ret = this.cache.getOAuth2Accessor(state); if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "getOAuth2Accessor", ret); } return ret; }
public OAuth2Token createToken() { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "createToken"); } final OAuth2Token ret = this.internalCreateToken(); if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "clearCache", ret); } return ret; }
public OAuth2Accessor removeOAuth2Accessor(final OAuth2Accessor accessor) { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "removeOAuth2Accessor", accessor); } final OAuth2Accessor ret = null; if (accessor != null) { return this.cache.removeOAuth2Accessor(accessor); } if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "removeOAuth2Accessor", ret); } return ret; }
@Test public void testExiting_2() throws Exception { final FilteredLogger fixture = FilteredLogger.getFilteredLogger(""); final String sourceClass = ""; final String sourceMethod = ""; final Object result = new Object(); fixture.exiting(sourceClass, sourceMethod, result); }
BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "getRefreshBody", ret);
@Test public void testExiting_2() throws Exception { final FilteredLogger fixture = FilteredLogger.getFilteredLogger(""); final String sourceClass = ""; final String sourceMethod = ""; final Object result = new Object(); fixture.exiting(sourceClass, sourceMethod, result); }
private static String buildRefreshTokenUrl(final OAuth2Accessor accessor) { final boolean isLogging = BasicOAuth2Request.LOG.isLoggable(); if (isLogging) { BasicOAuth2Request.LOG.entering(BasicOAuth2Request.LOG_CLASS, "buildRefreshTokenUrl", accessor); } String ret = null; final String refreshUrl = accessor.getTokenUrl(); if (refreshUrl != null) { ret = BasicOAuth2Request.getCompleteRefreshUrl(refreshUrl); } if (isLogging) { BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "buildRefreshTokenUrl", ret); } return ret; }
@Test public void testExiting_1() throws Exception { final FilteredLogger fixture = FilteredLogger.getFilteredLogger(""); final String sourceClass = ""; final String sourceMethod = ""; fixture.exiting(sourceClass, sourceMethod); }
@Test public void testExiting_1() throws Exception { final FilteredLogger fixture = FilteredLogger.getFilteredLogger(""); final String sourceClass = ""; final String sourceMethod = ""; fixture.exiting(sourceClass, sourceMethod); }
public void clearClientCache() throws GadgetException { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "clearClientCache"); } try { this.cache.clearClients(); } catch (final OAuth2CacheException e) { if (isLogging) { BasicOAuth2Store.LOG.log("Error clearing OAuth2 Client cache", e); } throw new GadgetException(Code.OAUTH_STORAGE_ERROR, "Error clearing OAuth2Client cache", e); } if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "clearClientCache"); } } }
public void clearAccessorCache() throws GadgetException { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "clearAccessorCache"); } try { this.cache.clearAccessors(); } catch (final OAuth2CacheException e) { if (isLogging) { BasicOAuth2Store.LOG.log("Error clearing OAuth2 Accessor cache", e); } throw new GadgetException(Code.OAUTH_STORAGE_ERROR, "Error clearing OAuth2Accessor cache", e); } if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "clearAccessorCache"); } }
public void clearTokenCache() throws GadgetException { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "clearTokenCache"); } try { this.cache.clearTokens(); } catch (final OAuth2CacheException e) { if (isLogging) { BasicOAuth2Store.LOG.log("Error clearing OAuth2 Token cache", e); } throw new GadgetException(Code.OAUTH_STORAGE_ERROR, "Error clearing OAuth2Token cache", e); } if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "clearTokenCache"); } }
private HttpResponseBuilder getErrorResponseBuilder(final Throwable t, final OAuth2Error error, final String contextMessage, final String errorUri, final String errorDescription) { final boolean isLogging = BasicOAuth2Request.LOG.isLoggable(); if (isLogging) { BasicOAuth2Request.LOG.entering(BasicOAuth2Request.LOG_CLASS, "getErrorResponseBuilder", new Object[] { t, error, contextMessage, errorUri, errorDescription }); } final HttpResponseBuilder ret = new HttpResponseBuilder().setHttpStatusCode( HttpResponse.SC_FORBIDDEN).setStrictNoCache(); if (t != null && this.sendTraceToClient) { final StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); final String message = sw.toString(); this.responseParams.addDebug(message); } if (this.sendTraceToClient) { this.responseParams.addToResponse(ret, error.getErrorCode(), error.getErrorDescription(contextMessage) + " , " + errorDescription, errorUri, error.getErrorExplanation()); } else { this.responseParams.addToResponse(ret, error.getErrorCode(), "", "", error.getErrorExplanation()); } if (isLogging) { BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "getErrorResponseBuilder", ret); } return ret; }
public boolean clearCache() throws GadgetException { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "clearCache"); } try { this.cache.clearClients(); this.cache.clearTokens(); this.cache.clearAccessors(); } catch (final OAuth2PersistenceException e) { if (isLogging) { BasicOAuth2Store.LOG.log("Error clearing OAuth2 cache", e); } throw new GadgetException(Code.OAUTH_STORAGE_ERROR, "Error clearing OAuth2 cache", e); } if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "clearCache", true); } return true; }
private boolean checkCanAuthorize(final OAuth2Accessor accessor) { final boolean isLogging = BasicOAuth2Request.LOG.isLoggable(); if (isLogging) { BasicOAuth2Request.LOG.entering(BasicOAuth2Request.LOG_CLASS, "checkCanAuthorize", accessor); } boolean ret = true; if (BasicOAuth2Request.LOG.isLoggable()) { BasicOAuth2Request.LOG.log("securityToken = {0}", this.securityToken); } final String pageOwner = this.securityToken.getOwnerId(); final String pageViewer = this.securityToken.getViewerId(); if (BasicOAuth2Request.LOG.isLoggable()) { BasicOAuth2Request.LOG.log("pageOwner = {0}", pageOwner); BasicOAuth2Request.LOG.log("pageViewer = {0}", pageViewer); } if (pageOwner == null || pageViewer == null) { accessor.setErrorResponse(null, OAuth2Error.AUTHORIZE_PROBLEM, "pageOwner or pageViewer is null", ""); ret = false; } else if (!this.fetcherConfig.isViewerAccessTokensEnabled() && !pageOwner.equals(pageViewer)) { accessor.setErrorResponse(null, OAuth2Error.AUTHORIZE_PROBLEM, "pageViewer is not pageOwner", ""); ret = false; } if (isLogging) { BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "checkCanAuthorize", ret); } return ret; }
public OAuth2Client getClient(final String gadgetUri, final String serviceName) throws GadgetException { final boolean isLogging = BasicOAuth2Store.LOG.isLoggable(); if (isLogging) { BasicOAuth2Store.LOG.entering(BasicOAuth2Store.LOG_CLASS, "getClient", new Object[] { gadgetUri, serviceName }); } OAuth2Client client = this.cache.getClient(gadgetUri, serviceName); if (isLogging) { BasicOAuth2Store.LOG.log("client from cache = {0}", client); } if (client == null) { try { client = this.persister.findClient(gadgetUri, serviceName); if (client != null) { this.cache.storeClient(client); } } catch (final OAuth2PersistenceException e) { if (isLogging) { BasicOAuth2Store.LOG.log("Error loading OAuth2 client ", e); } throw new GadgetException(Code.OAUTH_STORAGE_ERROR, "Error loading OAuth2 client " + serviceName, e); } } if (isLogging) { BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "getClient", client); } return client; }
BasicOAuth2Store.LOG.exiting(BasicOAuth2Store.LOG_CLASS, "getToken", token);
private HttpResponseBuilder fetchData(final OAuth2Accessor accessor, final boolean lastAttempt) { final boolean isLogging = BasicOAuth2Request.LOG.isLoggable(); if (isLogging) { BasicOAuth2Request.LOG.entering(BasicOAuth2Request.LOG_CLASS, "fetchData", accessor); } HttpResponseBuilder ret = null; try { final HttpResponse response = this.fetchFromServer(accessor, this.realRequest, lastAttempt); if (response != null) { ret = new HttpResponseBuilder(response); if (response.getHttpStatusCode() != HttpResponse.SC_OK && this.sendTraceToClient) { this.responseParams.addRequestTrace(this.realRequest, response); } } } catch (final OAuth2RequestException e) { ret = this.getErrorResponseBuilder(e, e.getError(), e.getErrorText(), e.getErrorUri(), e.getErrorDescription()); } if (isLogging) { BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "fetchData", ret); } return ret; }
private HttpResponse processResponse(final OAuth2Accessor accessor, final HttpResponseBuilder responseBuilder) { final boolean isLogging = BasicOAuth2Request.LOG.isLoggable(); if (isLogging) { BasicOAuth2Request.LOG.entering(BasicOAuth2Request.LOG_CLASS, "processResponse", new Object[] { accessor, responseBuilder == null }); } if (accessor.isErrorResponse() || responseBuilder == null) { return this.sendErrorResponse(accessor.getErrorException(), accessor.getError(), accessor.getErrorContextMessage(), accessor.getErrorUri(), ""); } if (this.responseParams.getAuthorizationUrl() != null) { responseBuilder.setMetadata(OAuth2ResponseParams.APPROVAL_URL, this.responseParams.getAuthorizationUrl()); accessor.setRedirecting(true); } else { accessor.setRedirecting(false); } final HttpResponse ret = responseBuilder.create(); if (isLogging) { BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "processResponse", "response logged in fetch()"); } return ret; }