Sha256: a24c2a1e96aecf52c3b36e3331d8681d9b4bab044882ed6fc13031cf249bc699

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 Bytes

Contents

package com.game_machine.authentication;

import org.mindrot.jbcrypt.BCrypt;

import GameMachine.Messages.Player;

public class DefaultAuthenticator implements PlayerAuthenticator {

	private static String scope = "players";
	public Player player;

	public DefaultAuthenticator(Player player) {
		this.player = player;
	}

	public void setPassword(String password) {
		player.setPasswordHash(BCrypt.hashpw(password, BCrypt.gensalt()));
		player.storeSet(scope);
	}

	public boolean authenticate(String password) {
		if (player.hasPasswordHash()) {
			return BCrypt.checkpw(password, player.getPasswordHash());
		} else {
			return false;
		}
	}
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
game_machine-1.0.4 java/project/src/main/java/com/game_machine/authentication/DefaultAuthenticator.java
game_machine-1.0.2 java/project/src/main/java/com/game_machine/authentication/DefaultAuthenticator.java