Remove use of MineHQ specific terminology. Copied from c949a7a2d4

This commit is contained in:
Colin McDonald 2016-11-29 22:23:23 -05:00
parent db0b173f15
commit 6cd0cb31ec
9 changed files with 39 additions and 23 deletions

View File

@ -1,6 +1,11 @@
mongoUri: mongodb://158.69.26.208:27027/MineHQ mongoUri: mongodb://158.69.26.208:27027/MineHQ
redisUri: redis://209.222.96.50:6379 redisUri: redis://209.222.96.50:6379
network:
name: MineHQ Network
appealUrl: minehq.com/appeal
rootPermission: minehq
http: http:
port: 80 port: 80
keystoreFile: keystoreFile:

View File

@ -152,18 +152,16 @@ public final class APIv3 extends AbstractVerticle implements ApplicationContextA
} }
private void setupHttpServer() { private void setupHttpServer() {
Environment environment = SpringUtils.getBean(Environment.class);
HttpServerOptions httpServerOptions = new HttpServerOptions(); HttpServerOptions httpServerOptions = new HttpServerOptions();
httpServerOptions.setCompressionSupported(true); httpServerOptions.setCompressionSupported(true);
if (!environment.getProperty("http.keystoreFile").isEmpty()) { if (!SpringUtils.getProperty("http.keystoreFile").isEmpty()) {
httpServerOptions.setSsl(true); httpServerOptions.setSsl(true);
httpServerOptions.setKeyStoreOptions( httpServerOptions.setKeyStoreOptions(
new JksOptions() new JksOptions()
.setPassword(environment.getProperty("http.keystorePassword")) .setPassword(SpringUtils.getProperty("http.keystorePassword"))
.setPath(environment.getProperty("http.keystoreFile")) .setPath(SpringUtils.getProperty("http.keystoreFile"))
); );
} }
@ -292,7 +290,7 @@ public final class APIv3 extends AbstractVerticle implements ApplicationContextA
httpGet(router, "/whoami", GETWhoAmI.class); httpGet(router, "/whoami", GETWhoAmI.class);
httpPost(router, "/logout", POSTLogout.class); httpPost(router, "/logout", POSTLogout.class);
int port = environment.getProperty("http.port", Integer.class); int port = SpringUtils.getProperty("http.port", Integer.class);
webServer.requestHandler(router::accept).listen(port); webServer.requestHandler(router::accept).listen(port);
} }

View File

@ -145,15 +145,15 @@ public final class IpBan {
String accessDenialReason; String accessDenialReason;
if (linkedIpBanUser != null) { if (linkedIpBanUser != null) {
accessDenialReason = "Your IP address has been suspended from the MineHQ Network for a punishment related to " + linkedIpBanUser.getLastUsername() + ". \n\n"; accessDenialReason = "Your IP address has been suspended from the " + SpringUtils.getProperty("network.name") + " for a punishment related to " + linkedIpBanUser.getLastUsername() + ". \n\n";
} else { } else {
accessDenialReason = "Your IP address has been suspended from the MineHQ Network. \n\n"; accessDenialReason = "Your IP address has been suspended from the " + SpringUtils.getProperty("network.name") + ". \n\n";
} }
if (getExpiresAt() != null) { if (getExpiresAt() != null) {
accessDenialReason += "Expires in " + TimeUtils.formatIntoDetailedString(TimeUtils.getSecondsBetween(getExpiresAt(), Instant.now())); accessDenialReason += "Expires in " + TimeUtils.formatIntoDetailedString(TimeUtils.getSecondsBetween(getExpiresAt(), Instant.now()));
} else { } else {
accessDenialReason += "Appeal at MineHQ.com/appeal"; accessDenialReason += "Appeal at " + SpringUtils.getProperty("network.appealUrl");
} }
return accessDenialReason; return accessDenialReason;

View File

@ -151,7 +151,7 @@ public final class IpIntel {
private IpIntel(String ip, GeoIpInfo result) { private IpIntel(String ip, GeoIpInfo result) {
this.id = ip; this.id = ip;
this.hashedIp = Hashing.sha256().hashString(id + SpringUtils.getBean(Environment.class).getProperty("ipHashing.salt"), Charsets.UTF_8).toString(); this.hashedIp = Hashing.sha256().hashString(id + SpringUtils.getProperty("ipHashing.salt"), Charsets.UTF_8).toString();
this.lastUpdatedAt = Instant.now(); this.lastUpdatedAt = Instant.now();
this.result = result; this.result = result;
this.location = new GeoJsonPoint(result.getLocation()); this.location = new GeoJsonPoint(result.getLocation());

View File

@ -81,7 +81,7 @@ public final class IpLogEntry {
this.id = new ObjectId().toString(); this.id = new ObjectId().toString();
this.user = user.getId(); this.user = user.getId();
this.userIp = userIp; this.userIp = userIp;
this.hashedUserIp = Hashing.sha256().hashString(userIp + SpringUtils.getBean(Environment.class).getProperty("ipHashing.salt"), Charsets.UTF_8).toString(); this.hashedUserIp = Hashing.sha256().hashString(userIp + SpringUtils.getProperty("ipHashing.salt"), Charsets.UTF_8).toString();
this.firstSeenAt = Instant.now(); this.firstSeenAt = Instant.now();
this.lastSeenAt = Instant.now(); this.lastSeenAt = Instant.now();
this.uses = 0; this.uses = 0;

View File

@ -141,14 +141,14 @@ public final class Punishment {
public String getAccessDenialReason() { public String getAccessDenialReason() {
switch (type) { switch (type) {
case BLACKLIST: case BLACKLIST:
return "Your account has been blacklisted from the MineHQ Network. \n\nThis type of punishment cannot be appealed."; return "Your account has been blacklisted from the " + SpringUtils.getProperty("network.name") + ". \n\nThis type of punishment cannot be appealed.";
case BAN: case BAN:
String accessDenialReason = "Your account has been suspended from the MineHQ Network. \n\n"; String accessDenialReason = "Your account has been suspended from the " + SpringUtils.getProperty("network.name") + ". \n\n";
if (getExpiresAt() != null) { if (getExpiresAt() != null) {
accessDenialReason += "Expires in " + TimeUtils.formatIntoDetailedString(TimeUtils.getSecondsBetween(getExpiresAt(), Instant.now())); accessDenialReason += "Expires in " + TimeUtils.formatIntoDetailedString(TimeUtils.getSecondsBetween(getExpiresAt(), Instant.now()));
} else { } else {
accessDenialReason += "Appeal at MineHQ.com/appeal"; accessDenialReason += "Appeal at " + SpringUtils.getProperty("network.appealUrl");
} }
return accessDenialReason; return accessDenialReason;

View File

@ -438,12 +438,12 @@ public final class User {
if (!userType.isAllowed()) { if (!userType.isAllowed()) {
proposedAccess = ImmutableMap.of( proposedAccess = ImmutableMap.of(
"allowed", false, "allowed", false,
"message", "You cannot join the server from a VPN." "message", "You cannot join the " + SpringUtils.getProperty("network.name") + " from a VPN."
); );
} else if (BannedAsn.findById(geoIpInfo.getTraits().getAsn()) != null) { } else if (BannedAsn.findById(geoIpInfo.getTraits().getAsn()) != null) {
proposedAccess = ImmutableMap.of( proposedAccess = ImmutableMap.of(
"allowed", false, "allowed", false,
"message", "You cannot join the server from this ISP." "message", "You cannot join the " + SpringUtils.getProperty("network.name") + " from this ISP."
); );
} }

View File

@ -1,16 +1,20 @@
package net.frozenorb.apiv3.unsorted; package net.frozenorb.apiv3.unsorted;
import net.frozenorb.apiv3.util.SpringUtils;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
@UtilityClass @UtilityClass
public class Permissions { public class Permissions {
public static final String PROTECTED_PUNISHMENT = "minehq.punishment.protected"; private static final String rootPermission = SpringUtils.getProperty("network.rootPermission");
public static final String BYPASS_VPN_CHECK = "minehq.vpn.bypass";
public static final String REQUIRE_TOTP_CODE = "minehq.totp.require"; public static final String PROTECTED_PUNISHMENT = rootPermission + ".punishment.protected";
public static final String CREATE_PUNISHMENT = "minehq.punishment.create"; public static final String BYPASS_VPN_CHECK = rootPermission + ".vpn.bypass";
public static final String REMOVE_PUNISHMENT = "minehq.punishment.remove"; public static final String REQUIRE_TOTP_CODE = rootPermission + ".totp.require";
public static final String CREATE_GRANT = "minehq.grant.create"; public static final String CREATE_PUNISHMENT = rootPermission + ".punishment.create";
public static final String REMOVE_GRANT = "minehq.grant.remove"; public static final String REMOVE_PUNISHMENT = rootPermission + ".punishment.remove";
public static final String CREATE_GRANT = rootPermission + ".grant.create";
public static final String REMOVE_GRANT = rootPermission + ".grant.remove";
} }

View File

@ -1,6 +1,7 @@
package net.frozenorb.apiv3.util; package net.frozenorb.apiv3.util;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.env.Environment;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -13,4 +14,12 @@ public final class SpringUtils {
return beanFactory.getBean(type); return beanFactory.getBean(type);
} }
public static String getProperty(String key) {
return beanFactory.getBean(Environment.class).getProperty(key);
}
public static <T> T getProperty(String key, Class<T> type) {
return beanFactory.getBean(Environment.class).getProperty(key, type);
}
} }