// Path: src/main/java-templates/com/github/games647/flexiblelogin/PomData.java
// public class PomData {
// 
//     public static final String ARTIFACT_ID = "${project.artifactId}";
//     public static final String NAME = "${project.name}";
//     public static final String VERSION = "${project.version}";
//     public static final String URL = "${project.url}";
//     public static final String DESCRIPTION = "${project.description}";
// }
// 
// Path: src/main/java/com/github/games647/flexiblelogin/hasher/BcryptHasher.java
// public class BcryptHasher implements Hasher {
// 
//     private static final int COST_FACTOR = 6;
//     private final BCrypt.Hasher hashAlg = BCrypt.with(Version.VERSION_2Y);
// 
//     @Override
//     public String hash(String rawPassword) {
//         //generate a different salt for each user
//         return hashAlg.hashToString(COST_FACTOR, rawPassword.toCharArray());
//     }
// 
//     @Override
//     public boolean checkPassword(String passwordHash, String userInput) {
//         if (passwordHash == null || passwordHash.isEmpty()) {
//             return false;
//         }
// 
//         return BCrypt.verifyer().verify(userInput.toCharArray(), passwordHash).verified;
//     }
// }
// 
// Path: src/main/java/com/github/games647/flexiblelogin/hasher/Hasher.java
// public interface Hasher {
// 
//     String hash(String rawPassword) throws Exception;
// 
//     boolean checkPassword(String passwordHash, String userInput) throws Exception;
// }
// 
// Path: src/main/java/com/github/games647/flexiblelogin/hasher/TOTP.java
// public class TOTP implements Hasher {
// 
//     private final GoogleAuthenticatorConfig config = new GoogleAuthenticatorConfigBuilder()
//             .setHmacHashFunction(HmacHashFunction.HmacSHA512)
//             //HmacSHA512 is not yet compatible with Base64
//             .setKeyRepresentation(KeyRepresentation.BASE64)
//             .build();
// 
//     private final IGoogleAuthenticator gAuth = new GoogleAuthenticator(config);
// 
//     public String getGoogleBarcodeURL(String user, String host, String secret) {
//         //this returns the google chart URL
//         GoogleAuthenticatorKey key = new Builder(secret).setConfig(config).build();
//         return GoogleAuthenticatorQRGenerator.getOtpAuthURL(host, user, key);
//     }
// 
//     @Override
//     public String hash(String rawPassword) {
//         //it's the secret code. We need to save it here
//         return gAuth.createCredentials().getKey();
//     }
// 
//     @Override
//     public boolean checkPassword(String passwordHash, String userInput) {
//         Integer code = Ints.tryParse(userInput);
//         return code != null && gAuth.authorize(passwordHash, code);
//     }
// }


import java.time.Duration;
import java.util.List;
import java.util.regex.Pattern;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.spongepowered.api.service.permission.Subject;
import com.github.games647.flexiblelogin.PomData;
import com.github.games647.flexiblelogin.hasher.BcryptHasher;
import com.github.games647.flexiblelogin.hasher.Hasher;
import com.github.games647.flexiblelogin.hasher.TOTP;
import com.google.common.collect.Lists;
/*
 * This file is part of FlexibleLogin
 *
 * The MIT License (MIT)
 *
 * Copyright (c) 2015-2018 contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.github.games647.flexiblelogin.config.node;





@SuppressWarnings("FieldMayBeFinal")
public class General {

    @Setting(comment = "FlexibleDatabase configuration")
    private SQLConfig sqlConfiguration = new SQLConfig();

    @Setting(comment = "Email configuration for password recovery")
    private MailConfig emailConfiguration = new MailConfig();

    @Setting(comment = "Algorithms for hashing user passwords. You can also choose totp")
    private HashingAlgorithm hashAlgo = HashingAlgorithm.BCrypt;

    @Setting(comment = "Regular expression for verifying validate player names. Default is a-zA-Z with 2-16 length")
    private Pattern validNames = Pattern.compile("^\\w{2,16}$");

    @Setting(comment = "Should the player name always be case sensitive equal to the time the player registered?")
    private boolean caseSensitiveNameCheck = true;

    @Setting(comment = "Should the plugin login users automatically if it's the same account from the same IP")
    private boolean ipAutoLogin;
    
    @Setting(comment = "Should the plugin don't register alias /l (used by some chat plugins) for /login command ")
    private boolean supportSomeChatPlugins;
    
    @Setting(comment = "Should only the specified commands be protected from unauthorized access")
    private boolean commandOnlyProtection;

    @Setting(comment = "The user should use a strong password")
    private int minPasswordLength = 4;

    @Setting(comment = "Number of seconds a player has time to login or will be kicked.-1 deactivates this features")
    private Duration timeoutLogin = Duration.ofMinutes(1);

// Path: src/main/java-templates/com/github/games647/flexiblelogin/PomData.java
// public class PomData {
// 
//     public static final String ARTIFACT_ID = "${project.artifactId}";
//     public static final String NAME = "${project.name}";
//     public static final String VERSION = "${project.version}";
//     public static final String URL = "${project.url}";
//     public static final String DESCRIPTION = "${project.description}";
// }
// 
// Path: src/main/java/com/github/games647/flexiblelogin/hasher/BcryptHasher.java
// public class BcryptHasher implements Hasher {
// 
//     private static final int COST_FACTOR = 6;
//     private final BCrypt.Hasher hashAlg = BCrypt.with(Version.VERSION_2Y);
// 
//     @Override
//     public String hash(String rawPassword) {
//         //generate a different salt for each user
//         return hashAlg.hashToString(COST_FACTOR, rawPassword.toCharArray());
//     }
// 
//     @Override
//     public boolean checkPassword(String passwordHash, String userInput) {
//         if (passwordHash == null || passwordHash.isEmpty()) {
//             return false;
//         }
// 
//         return BCrypt.verifyer().verify(userInput.toCharArray(), passwordHash).verified;
//     }
// }
// 
// Path: src/main/java/com/github/games647/flexiblelogin/hasher/Hasher.java
// public interface Hasher {
// 
//     String hash(String rawPassword) throws Exception;
// 
//     boolean checkPassword(String passwordHash, String userInput) throws Exception;
// }
// 
// Path: src/main/java/com/github/games647/flexiblelogin/hasher/TOTP.java
// public class TOTP implements Hasher {
// 
//     private final GoogleAuthenticatorConfig config = new GoogleAuthenticatorConfigBuilder()
//             .setHmacHashFunction(HmacHashFunction.HmacSHA512)
//             //HmacSHA512 is not yet compatible with Base64
//             .setKeyRepresentation(KeyRepresentation.BASE64)
//             .build();
// 
//     private final IGoogleAuthenticator gAuth = new GoogleAuthenticator(config);
// 
//     public String getGoogleBarcodeURL(String user, String host, String secret) {
//         //this returns the google chart URL
//         GoogleAuthenticatorKey key = new Builder(secret).setConfig(config).build();
//         return GoogleAuthenticatorQRGenerator.getOtpAuthURL(host, user, key);
//     }
// 
//     @Override
//     public String hash(String rawPassword) {
//         //it's the secret code. We need to save it here
//         return gAuth.createCredentials().getKey();
//     }
// 
//     @Override
//     public boolean checkPassword(String passwordHash, String userInput) {
//         Integer code = Ints.tryParse(userInput);
//         return code != null && gAuth.authorize(passwordHash, code);
//     }
// }


// Path: src/main/java/com/github/games647/flexiblelogin/config/node/General.java
import java.time.Duration;
import java.util.List;
import java.util.regex.Pattern;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.spongepowered.api.service.permission.Subject;
import com.github.games647.flexiblelogin.PomData;
import com.github.games647.flexiblelogin.hasher.BcryptHasher;
import com.github.games647.flexiblelogin.hasher.Hasher;
import com.github.games647.flexiblelogin.hasher.TOTP;
import com.google.common.collect.Lists;

/*
 * This file is part of FlexibleLogin
 *
 * The MIT License (MIT)
 *
 * Copyright (c) 2015-2018 contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.github.games647.flexiblelogin.config.node;





@SuppressWarnings("FieldMayBeFinal")
public class General {

    @Setting(comment = "FlexibleDatabase configuration")
    private SQLConfig sqlConfiguration = new SQLConfig();

    @Setting(comment = "Email configuration for password recovery")
    private MailConfig emailConfiguration = new MailConfig();

    @Setting(comment = "Algorithms for hashing user passwords. You can also choose totp")
    private HashingAlgorithm hashAlgo = HashingAlgorithm.BCrypt;

    @Setting(comment = "Regular expression for verifying validate player names. Default is a-zA-Z with 2-16 length")
    private Pattern validNames = Pattern.compile("^\\w{2,16}$");

    @Setting(comment = "Should the player name always be case sensitive equal to the time the player registered?")
    private boolean caseSensitiveNameCheck = true;

    @Setting(comment = "Should the plugin login users automatically if it's the same account from the same IP")
    private boolean ipAutoLogin;
    
    @Setting(comment = "Should the plugin don't register alias /l (used by some chat plugins) for /login command ")
    private boolean supportSomeChatPlugins;
    
    @Setting(comment = "Should only the specified commands be protected from unauthorized access")
    private boolean commandOnlyProtection;

    @Setting(comment = "The user should use a strong password")
    private int minPasswordLength = 4;

    @Setting(comment = "Number of seconds a player has time to login or will be kicked.-1 deactivates this features")
    private Duration timeoutLogin = Duration.ofMinutes(1);

    @Setting(comment = "Should this plugin check for player permissions")