Skip to content

Commit

Permalink
Use internal package for non-public parts of ratpack-pac4j implementa…
Browse files Browse the repository at this point in the history
…tion (#257)
  • Loading branch information
davidmc24 committed Mar 14, 2014
1 parent 4dbdcd6 commit d1efb47
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
Expand Up @@ -22,6 +22,7 @@
import org.pac4j.core.client.Client;
import org.pac4j.core.credentials.Credentials;
import org.pac4j.core.profile.UserProfile;
import ratpack.pac4j.internal.AbstractPac4jModule;

import java.lang.reflect.Type;

Expand Down
5 changes: 3 additions & 2 deletions ratpack-pac4j/src/main/java/ratpack/pac4j/Pac4jModule.java
Expand Up @@ -20,6 +20,7 @@
import org.pac4j.core.client.Client;
import org.pac4j.core.credentials.Credentials;
import org.pac4j.core.profile.UserProfile;
import ratpack.pac4j.internal.AbstractPac4jModule;

/**
* An extension module that provides support for authentication via pac4j.
Expand Down Expand Up @@ -125,12 +126,12 @@ public Pac4jModule(Client<C, U> client, Authorizer<U> authorizer) {
}

@Override
Client<C, U> getClient(Injector injector) {
protected Client<C, U> getClient(Injector injector) {
return client;
}

@Override
Authorizer<U> getAuthorizer(Injector injector) {
protected Authorizer<U> getAuthorizer(Injector injector) {
return authorizer;
}
}
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package ratpack.pac4j;
package ratpack.pac4j.internal;

import com.google.inject.AbstractModule;
import com.google.inject.Injector;
Expand All @@ -25,14 +25,15 @@
import ratpack.handling.Handler;
import ratpack.handling.Handlers;
import ratpack.launch.LaunchConfig;
import ratpack.pac4j.Authorizer;

/**
* Base class for pac4j integration modules.
*
* @param <C> The {@link org.pac4j.core.credentials.Credentials} type
* @param <U> The {@link org.pac4j.core.profile.UserProfile} type
*/
abstract class AbstractPac4jModule<C extends Credentials, U extends UserProfile> extends AbstractModule implements HandlerDecoratingModule {
public abstract class AbstractPac4jModule<C extends Credentials, U extends UserProfile> extends AbstractModule implements HandlerDecoratingModule {
private static final String DEFAULT_CALLBACK_PATH = "pac4j-callback";

private String callbackPath;
Expand All @@ -58,7 +59,7 @@ protected void configure() {
* @param injector The injector created from all the application modules
* @return The callback path
*/
String getCallbackPath(Injector injector) {
private String getCallbackPath(Injector injector) {
LaunchConfig launchConfig = injector.getInstance(LaunchConfig.class);
return callbackPath == null ? launchConfig.getOther("pac4j.callbackPath", DEFAULT_CALLBACK_PATH) : callbackPath;
}
Expand All @@ -69,15 +70,15 @@ String getCallbackPath(Injector injector) {
* @param injector The injector created from all the application modules
* @return The client
*/
abstract Client<C, U> getClient(Injector injector);
protected abstract Client<C, U> getClient(Injector injector);

/**
* Returns the authorizer to use for authorization.
*
* @param injector The injector created from all the application modules
* @return The authorizer
*/
abstract Authorizer<U> getAuthorizer(Injector injector);
protected abstract Authorizer<U> getAuthorizer(Injector injector);

@Override
public Handler decorate(Injector injector, Handler handler) {
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package ratpack.pac4j;
package ratpack.pac4j.internal;

import org.pac4j.core.client.BaseClient;
import org.pac4j.core.client.Client;
Expand All @@ -23,21 +23,22 @@
import ratpack.func.Action;
import ratpack.handling.Context;
import ratpack.handling.Handler;
import ratpack.pac4j.Authorizer;
import ratpack.server.PublicAddress;
import ratpack.session.store.SessionStorage;

import java.util.concurrent.Callable;

import static ratpack.pac4j.SessionConstants.SAVED_URI;
import static ratpack.pac4j.SessionConstants.USER_PROFILE;
import static ratpack.pac4j.internal.SessionConstants.SAVED_URI;
import static ratpack.pac4j.internal.SessionConstants.USER_PROFILE;

/**
* Filters requests to apply authentication and authorization as required.
*
* @param <C> The {@link org.pac4j.core.credentials.Credentials} type
* @param <U> The {@link org.pac4j.core.profile.UserProfile} type
*/
class Pac4jAuthenticationHandler<C extends Credentials, U extends UserProfile> implements Handler {
public class Pac4jAuthenticationHandler<C extends Credentials, U extends UserProfile> implements Handler {
private final Client<C, U> client;
private final Authorizer<U> authorizer;
private final String callbackPath;
Expand All @@ -49,7 +50,7 @@ class Pac4jAuthenticationHandler<C extends Credentials, U extends UserProfile> i
* @param authorizer The authorizer to user for authorization
* @param callbackPath the path to use for callbacks from the identity provider
*/
Pac4jAuthenticationHandler(Client<C, U> client, Authorizer<U> authorizer, String callbackPath) {
public Pac4jAuthenticationHandler(Client<C, U> client, Authorizer<U> authorizer, String callbackPath) {
this.client = client;
this.authorizer = authorizer;
this.callbackPath = callbackPath;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package ratpack.pac4j;
package ratpack.pac4j.internal;

import org.pac4j.core.client.Client;
import org.pac4j.core.credentials.Credentials;
Expand All @@ -24,20 +24,21 @@
import ratpack.func.Action;
import ratpack.handling.Context;
import ratpack.handling.Handler;
import ratpack.pac4j.Authorizer;
import ratpack.session.store.SessionStorage;

import java.util.concurrent.Callable;

import static ratpack.pac4j.SessionConstants.SAVED_URI;
import static ratpack.pac4j.SessionConstants.USER_PROFILE;
import static ratpack.pac4j.internal.SessionConstants.SAVED_URI;
import static ratpack.pac4j.internal.SessionConstants.USER_PROFILE;

/**
* Handles callback requests from identity providers.
*
* @param <C> The {@link org.pac4j.core.credentials.Credentials} type
* @param <U> The {@link org.pac4j.core.profile.UserProfile} type
*/
class Pac4jCallbackHandler<C extends Credentials, U extends UserProfile> implements Handler {
public class Pac4jCallbackHandler<C extends Credentials, U extends UserProfile> implements Handler {
private static final String DEFAULT_REDIRECT_URI = "/";

private final Client<C, U> client;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package ratpack.pac4j;
package ratpack.pac4j.internal;

import org.pac4j.core.context.WebContext;
import ratpack.handling.Context;
Expand Down
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package ratpack.pac4j;
package ratpack.pac4j.internal;

/**
* Constants for session variables used by the pac4j integration.
Expand Down

0 comments on commit d1efb47

Please sign in to comment.