/*
 * Copyright 2012 Steve Chaloner
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package be.objectify.deadbolt.java;

import be.objectify.deadbolt.java.models.Subject;
import play.libs.concurrent.HttpExecution;
import play.mvc.Http;
import play.mvc.Result;
import play.mvc.Results;
import scala.concurrent.ExecutionContext;
import scala.concurrent.ExecutionContextExecutor;
import views.html.defaultpages.unauthorized;

import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;

/**
 * Abstract implementation of {@link DeadboltHandler} that gives a standard unauthorised result when access fails.
 *
 * @author Steve Chaloner (steve@objectify.be)
 */
public abstract class AbstractDeadboltHandler extends Results implements DeadboltHandler
{
    protected final DeadboltExecutionContextProvider executionContextProvider;

    public AbstractDeadboltHandler(final ExecutionContextProvider ecProvider)
    {
        this.executionContextProvider = ecProvider.get();
    }

    /**
     * {@inheritDoc}
     */
    public CompletionStage<Optional<? extends Subject>> getSubject(final Http.Context context)
    {
        return CompletableFuture.completedFuture(Optional.empty());
    }

    /**
     * {@inheritDoc}
     */
    public CompletionStage<Result> onAuthFailure(final Http.Context context,
                                                 final Optional<String> content)
    {
        final ExecutionContext executionContext = executionContextProvider.get();
        final ExecutionContextExecutor executor = HttpExecution.fromThread(executionContext);
        return CompletableFuture.supplyAsync(unauthorized::render,
                                             executor)
                                .thenApplyAsync(Results::unauthorized,
                                                executor);
    }

    /**
     * {@inheritDoc}
     */
    public CompletionStage<Optional<DynamicResourceHandler>> getDynamicResourceHandler(final Http.Context context)
    {
        return CompletableFuture.completedFuture(Optional.empty());
    }
}

@@ -1619,32 +1619,271 @@
 tDoc%7D%0D%0A     */%0D%0A
+    @Override%0D%0A    public CompletionStage%3COptional%3CResult%3E%3E beforeAuthCheck(Http.Context context)%0D%0A    %7B%0D%0A        return CompletableFuture.completedFuture(Optional.empty());%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * %7B@inheritDoc%7D%0D%0A     */%0D%0A    @Override%0D%0A
     public Compl
@@ -2079,32 +2079,47 @@
 tDoc%7D%0D%0A     */%0D%0A
+    @Override%0D%0A
     public Compl
@@ -2748,24 +2748,39 @@
 %7D%0D%0A     */%0D%0A
+    @Override%0D%0A
     public C

Add a default do-nothing implementation of beforeAuthCheck.