Search in sources :

Example 1 with OAuthProvider

use of com.adeptj.modules.commons.oauth.common.OAuthProvider in project adeptj-modules by AdeptJ.

the class OAuthProviderFactoryImpl method deleted.

/**
 * {@inheritDoc}
 */
@Override
public void deleted(String pid) {
    LOGGER.info("Removing configs for pid: [{}]", pid);
    OAuthProvider provider = this.providers.remove(pid);
    if (provider != null) {
        this.providerNamePidMappings.remove(provider.getProviderName());
    }
}
Also used : OAuthProvider(com.adeptj.modules.commons.oauth.common.OAuthProvider)

Example 2 with OAuthProvider

use of com.adeptj.modules.commons.oauth.common.OAuthProvider in project adeptj-modules by AdeptJ.

the class OAuth2AuthorizationRequestServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String providerName = StringUtils.substringAfterLast(req.getRequestURI(), "/");
    LOGGER.info("Authz request for provider: [{}]", providerName);
    OAuthProvider provider = this.providerFactory.getProvider(providerName);
    LOGGER.info("OAuthProvider: [{}]", provider);
    OAuth20Service oauth2Service = this.providerFactory.getOAuth2Service(providerName);
    if (oauth2Service == null) {
        oauth2Service = new ServiceBuilder().apiKey(provider.getApiKey()).apiSecret(provider.getApiSecret()).callback(provider.getCallbackURL()).build(provider.getApi());
        this.providerFactory.addOAuth2Service(providerName, oauth2Service);
    }
    String authorizationUrl = oauth2Service.getAuthorizationUrl();
    LOGGER.info("Authz URL: [{}]", authorizationUrl);
    resp.sendRedirect(authorizationUrl);
}
Also used : OAuthProvider(com.adeptj.modules.commons.oauth.common.OAuthProvider) OAuth20Service(com.github.scribejava.core.oauth.OAuth20Service) ServiceBuilder(com.github.scribejava.core.builder.ServiceBuilder)

Aggregations

OAuthProvider (com.adeptj.modules.commons.oauth.common.OAuthProvider)2 ServiceBuilder (com.github.scribejava.core.builder.ServiceBuilder)1 OAuth20Service (com.github.scribejava.core.oauth.OAuth20Service)1