org.spincast.website.HttpAuthInit Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of spincast-website Show documentation
                Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
                
            package org.spincast.website;
import java.util.List;
import org.spincast.core.server.IServer;
import org.spincast.shaded.org.apache.commons.lang3.tuple.Pair;
import com.google.inject.Inject;
/**
 * Initilizes the HTTP authentication.
 */
public class HttpAuthInit {
    private final IAppConfig appConfig;
    private final IServer server;
    @Inject
    public HttpAuthInit(IAppConfig appConfig, IServer server) {
        this.appConfig = appConfig;
        this.server = server;
    }
    protected IAppConfig getAppConfig() {
        return this.appConfig;
    }
    protected IServer getServer() {
        return this.server;
    }
    @Inject
    protected void init() {
        //==========================================
        // Admin section
        //==========================================
        List> adminUsernamesPasswords = getAppConfig().getAdminUsernamesPasswords();
        for(Pair adminUsernamesPassword : adminUsernamesPasswords) {
            getServer().addHttpAuthentication(AppConstants.HTTP_AUTH_REALM_NAME_ADMIN,
                                              adminUsernamesPassword.getKey(),
                                              adminUsernamesPassword.getValue());
        }
        //==========================================
        // Example page
        //==========================================
        getServer().addHttpAuthentication(AppConstants.HTTP_AUTH_REALM_NAME_EXAMPLE, "Stromgol", "Laroche");
    }
}
      © 2015 - 2025 Weber Informatics LLC | Privacy Policy