Cleanup
This commit is contained in:
parent
39aaef8f8a
commit
5ceabe2146
@ -34,6 +34,7 @@ public class CommandService {
|
|||||||
private HelpProvider helpProvider;
|
private HelpProvider helpProvider;
|
||||||
@Inject
|
@Inject
|
||||||
private CommandMapper commandMapper;
|
private CommandMapper commandMapper;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Inject
|
@Inject
|
||||||
private PasswordSecurity passwordSecurity;
|
private PasswordSecurity passwordSecurity;
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@ -424,6 +424,7 @@ public class MySQL implements DataSource {
|
|||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
} else if (hashAlgorithm == HashAlgorithm.WORDPRESS) {
|
} else if (hashAlgorithm == HashAlgorithm.WORDPRESS) {
|
||||||
|
// NOTE: Eclipse says pst should be closed HERE, but it's a bug, we already close it above. -sgdc3
|
||||||
pst = con.prepareStatement("SELECT " + col.ID + " FROM " + tableName + " WHERE " + col.NAME + "=?;");
|
pst = con.prepareStatement("SELECT " + col.ID + " FROM " + tableName + " WHERE " + col.NAME + "=?;");
|
||||||
pst.setString(1, auth.getNickname());
|
pst.setString(1, auth.getNickname());
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
@ -500,6 +501,7 @@ public class MySQL implements DataSource {
|
|||||||
rs.close();
|
rs.close();
|
||||||
pst.close();
|
pst.close();
|
||||||
} else if (hashAlgorithm == HashAlgorithm.XFBCRYPT) {
|
} else if (hashAlgorithm == HashAlgorithm.XFBCRYPT) {
|
||||||
|
// NOTE: Eclipse says pst should be closed HERE, but it's a bug, we already close it above. -sgdc3
|
||||||
pst = con.prepareStatement("SELECT " + col.ID + " FROM " + tableName + " WHERE " + col.NAME + "=?;");
|
pst = con.prepareStatement("SELECT " + col.ID + " FROM " + tableName + " WHERE " + col.NAME + "=?;");
|
||||||
pst.setString(1, auth.getNickname());
|
pst.setString(1, auth.getNickname());
|
||||||
rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
|
|||||||
@ -407,12 +407,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
plugin.getManagement().performQuit(player, true);
|
plugin.getManagement().performQuit(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
||||||
* Note #360: npc status can be used to bypass security!!!
|
|
||||||
* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
|
||||||
*/
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||||
if (shouldCancelEvent(event)) {
|
if (shouldCancelEvent(event)) {
|
||||||
|
|||||||
@ -152,7 +152,6 @@ public class SendMailSSL {
|
|||||||
} else {
|
} else {
|
||||||
email.setStartTLSEnabled(true);
|
email.setStartTLSEnabled(true);
|
||||||
email.setStartTLSRequired(true);
|
email.setStartTLSRequired(true);
|
||||||
email.setTLS(true);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
@ -161,7 +160,7 @@ public class SendMailSSL {
|
|||||||
break;
|
break;
|
||||||
case 465:
|
case 465:
|
||||||
email.setSslSmtpPort(Integer.toString(port));
|
email.setSslSmtpPort(Integer.toString(port));
|
||||||
email.setSSL(true);
|
email.setSSLOnConnect(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
email.setStartTLSEnabled(true);
|
email.setStartTLSEnabled(true);
|
||||||
|
|||||||
@ -346,7 +346,6 @@ public class PermissionsManager implements PermissionsService {
|
|||||||
|
|
||||||
case Z_PERMISSIONS:
|
case Z_PERMISSIONS:
|
||||||
// zPermissions
|
// zPermissions
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
Map<String, Boolean> perms = zPermissionsService.getPlayerPermissions(player.getWorld().getName(), null, player.getName());
|
Map<String, Boolean> perms = zPermissionsService.getPlayerPermissions(player.getWorld().getName(), null, player.getName());
|
||||||
if (perms.containsKey(permsNode))
|
if (perms.containsKey(permsNode))
|
||||||
return perms.get(permsNode);
|
return perms.get(permsNode);
|
||||||
@ -448,7 +447,6 @@ public class PermissionsManager implements PermissionsService {
|
|||||||
*
|
*
|
||||||
* @return The name of the primary permission group. Or null.
|
* @return The name of the primary permission group. Or null.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public String getPrimaryGroup(Player player) {
|
public String getPrimaryGroup(Player player) {
|
||||||
// If no permissions system is used, return an empty list
|
// If no permissions system is used, return an empty list
|
||||||
if (!isEnabled())
|
if (!isEnabled())
|
||||||
|
|||||||
@ -1,71 +1,62 @@
|
|||||||
package fr.xephi.authme.security.pbkdf2;
|
package fr.xephi.authme.security.pbkdf2;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free auxiliary functions. Copyright 2007, 2014, Matthias Gärtner
|
||||||
|
*
|
||||||
|
* This is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2.1 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this software; if not, write to the Free
|
||||||
|
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* Free auxiliary functions
|
||||||
* Free auxiliary functions. Copyright (c) 2007 Matthias Gärtner
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* This library is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU Lesser General Public License as published by the Free
|
|
||||||
* Software Foundation; either version 2.1 of the License, or (at your option)
|
|
||||||
* any later version.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
|
||||||
* details.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with this library; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* For Details, see <a
|
|
||||||
* href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html"
|
|
||||||
* >http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</a>.
|
|
||||||
* </p>
|
|
||||||
*
|
*
|
||||||
* @author Matthias Gärtner
|
* @author Matthias Gärtner
|
||||||
* @version 1.0
|
|
||||||
*/
|
*/
|
||||||
public class BinTools {
|
public class BinTools {
|
||||||
|
public static final String hex = "0123456789ABCDEF";
|
||||||
private static final String HEX_CHARS = "0123456789ABCDEF";
|
|
||||||
|
|
||||||
private BinTools() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple binary-to-hexadecimal conversion.
|
* Simple binary-to-hexadecimal conversion.
|
||||||
*
|
*
|
||||||
* @param b Input bytes. May be <code>null</code>.
|
* @param b
|
||||||
*
|
* Input bytes. May be <code>null</code>.
|
||||||
* @return Hexadecimal representation of b. Uppercase A-F, two characters
|
* @return Hexadecimal representation of b. Uppercase A-F, two characters
|
||||||
* per byte. Empty string on <code>null</code> input.
|
* per byte. Empty string on <code>null</code> input.
|
||||||
*/
|
*/
|
||||||
public static String bin2hex(final byte[] b) {
|
public static String bin2hex(final byte[] b) {
|
||||||
if (b == null) {
|
if (b == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
StringBuffer stringBuffer = new StringBuffer(2 * b.length);
|
StringBuffer sb = new StringBuffer(2 * b.length);
|
||||||
for (byte aB : b) {
|
for (int i = 0; i < b.length; i++) {
|
||||||
int v = (256 + aB) % 256;
|
int v = (256 + b[i]) % 256;
|
||||||
stringBuffer.append(HEX_CHARS.charAt((v / 16) & 15));
|
sb.append(hex.charAt((v / 16) & 15));
|
||||||
stringBuffer.append(HEX_CHARS.charAt((v % 16) & 15));
|
sb.append(hex.charAt((v % 16) & 15));
|
||||||
}
|
}
|
||||||
return stringBuffer.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert hex string to array of bytes.
|
* Convert hex string to array of bytes.
|
||||||
*
|
*
|
||||||
* @param s String containing hexadecimal digits. May be <code>null</code>.
|
* @param s
|
||||||
* On odd length leading zero will be assumed.
|
* String containing hexadecimal digits. May be <code>null</code>
|
||||||
*
|
* . On odd length leading zero will be assumed.
|
||||||
* @return Array on bytes, non-<code>null</code>.
|
* @return Array on bytes, non-<code>null</code>.
|
||||||
* @throws IllegalArgumentException when string contains non-hex character
|
* @throws IllegalArgumentException
|
||||||
|
* when string contains non-hex character
|
||||||
*/
|
*/
|
||||||
public static byte[] hex2bin(final String s) {
|
public static byte[] hex2bin(final String s) {
|
||||||
String m = s;
|
String m = s;
|
||||||
@ -88,10 +79,11 @@ public class BinTools {
|
|||||||
/**
|
/**
|
||||||
* Convert hex digit to numerical value.
|
* Convert hex digit to numerical value.
|
||||||
*
|
*
|
||||||
* @param c 0-9, a-f, A-F allowed.
|
* @param c
|
||||||
*
|
* 0-9, a-f, A-F allowd.
|
||||||
* @return 0-15
|
* @return 0-15
|
||||||
* @throws IllegalArgumentException on non-hex character
|
* @throws IllegalArgumentException
|
||||||
|
* on non-hex character
|
||||||
*/
|
*/
|
||||||
public static int hex2bin(char c) {
|
public static int hex2bin(char c) {
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
@ -106,9 +98,7 @@ public class BinTools {
|
|||||||
throw new IllegalArgumentException("Input string may only contain hex digits, but found '" + c + "'");
|
throw new IllegalArgumentException("Input string may only contain hex digits, but found '" + c + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note ljacqu 20160313: This appears to be a test method that was present in the third-party source.
|
public static void main(String[] args) {
|
||||||
// We can keep it for troubleshooting in the future.
|
|
||||||
private static void testUtils() {
|
|
||||||
byte b[] = new byte[256];
|
byte b[] = new byte[256];
|
||||||
byte bb = 0;
|
byte bb = 0;
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
|
|||||||
@ -31,7 +31,6 @@ public final class MigrationService {
|
|||||||
* @param dataSource The data source
|
* @param dataSource The data source
|
||||||
* @param authmeSha256 Instance to the AuthMe SHA256 encryption method implementation
|
* @param authmeSha256 Instance to the AuthMe SHA256 encryption method implementation
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void changePlainTextToSha256(NewSetting settings, DataSource dataSource,
|
public static void changePlainTextToSha256(NewSetting settings, DataSource dataSource,
|
||||||
SHA256 authmeSha256) {
|
SHA256 authmeSha256) {
|
||||||
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
|
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
|
||||||
@ -62,7 +61,6 @@ public final class MigrationService {
|
|||||||
* @param dataSource The data source
|
* @param dataSource The data source
|
||||||
* @return The converted datasource (SQLite), or null if no migration was necessary
|
* @return The converted datasource (SQLite), or null if no migration was necessary
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static DataSource convertFlatfileToSqlite(NewSetting settings, DataSource dataSource) {
|
public static DataSource convertFlatfileToSqlite(NewSetting settings, DataSource dataSource) {
|
||||||
if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) {
|
if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) {
|
||||||
ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated; it will be changed "
|
ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated; it will be changed "
|
||||||
|
|||||||
@ -41,6 +41,7 @@ public class CommandInitializerTest {
|
|||||||
|
|
||||||
private static Set<CommandDescription> commands;
|
private static Set<CommandDescription> commands;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initializeCommandManager() {
|
public static void initializeCommandManager() {
|
||||||
AuthMeServiceInitializer initializer = mock(AuthMeServiceInitializer.class);
|
AuthMeServiceInitializer initializer = mock(AuthMeServiceInitializer.class);
|
||||||
|
|||||||
@ -75,6 +75,7 @@ public class EventsConsistencyTest {
|
|||||||
return !clazz.isInterface() && !clazz.isEnum() && !Modifier.isAbstract(clazz.getModifiers());
|
return !clazz.isInterface() && !clazz.isEnum() && !Modifier.isAbstract(clazz.getModifiers());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static Class<? extends Event> getEventClassFromFile(File file) {
|
private static Class<? extends Event> getEventClassFromFile(File file) {
|
||||||
String fileName = file.getPath();
|
String fileName = file.getPath();
|
||||||
String className = fileName
|
String className = fileName
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
*/
|
*/
|
||||||
public class ConstructorInjectionTest {
|
public class ConstructorInjectionTest {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void shouldReturnDependencies() {
|
public void shouldReturnDependencies() {
|
||||||
// given
|
// given
|
||||||
@ -73,6 +74,7 @@ public class ConstructorInjectionTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldReturnNullForNoConstructorInjection() {
|
public void shouldReturnNullForNoConstructorInjection() {
|
||||||
// given / when
|
// given / when
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
Injection<FieldInjection> injection = ConstructorInjection.provide(FieldInjection.class).get();
|
Injection<FieldInjection> injection = ConstructorInjection.provide(FieldInjection.class).get();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
*/
|
*/
|
||||||
public class FieldInjectionTest {
|
public class FieldInjectionTest {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void shouldReturnDependencies() {
|
public void shouldReturnDependencies() {
|
||||||
// given
|
// given
|
||||||
@ -105,9 +106,11 @@ public class FieldInjectionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class ThrowingConstructor {
|
private static class ThrowingConstructor {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Inject
|
@Inject
|
||||||
private ProvidedClass providedClass;
|
private ProvidedClass providedClass;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public ThrowingConstructor() {
|
public ThrowingConstructor() {
|
||||||
throw new UnsupportedOperationException("Exception in constructor");
|
throw new UnsupportedOperationException("Exception in constructor");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import javax.inject.Inject;
|
|||||||
*/
|
*/
|
||||||
public class BadFieldInjection {
|
public class BadFieldInjection {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Inject
|
@Inject
|
||||||
private AlphaService alphaService;
|
private AlphaService alphaService;
|
||||||
|
|
||||||
|
|||||||
@ -9,8 +9,10 @@ import javax.inject.Inject;
|
|||||||
public abstract class InvalidPostConstruct {
|
public abstract class InvalidPostConstruct {
|
||||||
|
|
||||||
public static final class WithParams {
|
public static final class WithParams {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Inject
|
@Inject
|
||||||
private AlphaService alphaService;
|
private AlphaService alphaService;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Inject
|
@Inject
|
||||||
private ProvidedClass providedClass;
|
private ProvidedClass providedClass;
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import javax.inject.Inject;
|
|||||||
*/
|
*/
|
||||||
public class InvalidStaticFieldInjection {
|
public class InvalidStaticFieldInjection {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Inject
|
@Inject
|
||||||
private ProvidedClass providedClass;
|
private ProvidedClass providedClass;
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@ -88,6 +88,7 @@ public class CommandPageCreater implements ToolTask {
|
|||||||
*
|
*
|
||||||
* @return the initializer mock
|
* @return the initializer mock
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static AuthMeServiceInitializer getMockInitializer() {
|
private static AuthMeServiceInitializer getMockInitializer() {
|
||||||
AuthMeServiceInitializer initializer = mock(AuthMeServiceInitializer.class);
|
AuthMeServiceInitializer initializer = mock(AuthMeServiceInitializer.class);
|
||||||
when(initializer.newInstance(isA(Class.class))).thenAnswer(new Answer<Object>() {
|
when(initializer.newInstance(isA(Class.class))).thenAnswer(new Answer<Object>() {
|
||||||
|
|||||||
@ -137,6 +137,7 @@ public class EncryptionMethodInfoGatherer {
|
|||||||
return key.cast(map.get(key));
|
return key.cast(map.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static AuthMeServiceInitializer createInitializer() {
|
private static AuthMeServiceInitializer createInitializer() {
|
||||||
NewSetting settings = mock(NewSetting.class);
|
NewSetting settings = mock(NewSetting.class);
|
||||||
// Return the default value for any property
|
// Return the default value for any property
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user