Schematic Nodes #90
79
SpigotCore_Main/src/de/steamwar/sql/CheckedSchematic.java
Normale Datei
79
SpigotCore_Main/src/de/steamwar/sql/CheckedSchematic.java
Normale Datei
@ -0,0 +1,79 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program 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 Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Deprecated
|
||||
public class CheckedSchematic {
|
||||
|
||||
private final CheckedNode node;
|
||||
|
||||
private CheckedSchematic(CheckedNode node){
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
Chaoscaot markierte diese Unterhaltung als gelöst
Veraltet
|
||||
public CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason){
|
||||
this(new CheckedNode(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), validator ,startTime, endTime, declineReason));
|
||||
Lixfel markierte diese Unterhaltung als gelöst
Veraltet
Lixfel
hat
Das rückwirkend für alle Schems (teils gelöschte) zu ändern? Halleluja! Viel Spaß. Das rückwirkend für alle Schems (teils gelöschte) zu ändern? Halleluja! Viel Spaß.
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public CheckedSchematic(String schemName, UUID schemOwner, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){
|
||||
this(new CheckedNode(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), validator ,startTime, endTime, declineReason));
|
||||
}
|
||||
|
||||
public static List<CheckedSchematic> getLastDeclined(UUID schemOwner){
|
||||
return getLastDelined(SteamwarUser.get(schemOwner).getId());
|
||||
}
|
||||
|
||||
public static List<CheckedSchematic> getLastDelined(int schemOwner){
|
||||
return CheckedNode.getLastDelined(schemOwner).stream().map(node1 -> new CheckedSchematic(node1)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void remove() {
|
||||
node.remove();
|
||||
}
|
||||
|
||||
public String getSchemName() {
|
||||
return node.getSchemName();
|
||||
}
|
||||
|
||||
public int getSchemOwner() {
|
||||
return node.getSchemOwner();
|
||||
}
|
||||
|
||||
public int getValidator() {
|
||||
return node.getValidator();
|
||||
}
|
||||
|
||||
public Timestamp getStartTime() {
|
||||
return node.getStartTime();
|
||||
}
|
||||
|
||||
public Timestamp getEndTime() {
|
||||
return node.getEndTime();
|
||||
}
|
||||
|
||||
public String getDeclineReason() {
|
||||
return node.getDeclineReason();
|
||||
}
|
||||
}
|
@ -19,38 +19,11 @@
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import com.google.common.io.BaseEncoding;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
|
||||
public class DownloadSchematic {
|
||||
private DownloadSchematic(){}
|
||||
|
||||
private static final SQL.Statement createLink = new SQL.Statement("INSERT INTO SchemDownload (SchemID, Link) VALUES (?, ?) ON DUPLICATE KEY UPDATE Link = VALUES(Link)");
|
||||
|
||||
|
||||
private static final String BASE = "https://steamwar.de/download.php?schem=";
|
||||
|
||||
public static String getLink(SchematicNode schem){
|
||||
if(schem.isDir())
|
||||
throw new SecurityException("Can not Download Directorys");
|
||||
MessageDigest digest;
|
||||
try {
|
||||
digest = MessageDigest.getInstance("SHA-1");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
digest.reset();
|
||||
digest.update((Instant.now().toString() + schem.getOwner() + schem.getId()).getBytes());
|
||||
String hash = BaseEncoding.base16().encode(digest.digest());
|
||||
createLink.update(schem.getId(), hash);
|
||||
return BASE + hash;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String getLink(Schematic schem){
|
||||
return getLink(schem.getNode());
|
||||
return NodeDownload.getLink(schem.getNode());
|
||||
}
|
||||
}
|
||||
|
49
SpigotCore_Main/src/de/steamwar/sql/NodeDownload.java
Normale Datei
49
SpigotCore_Main/src/de/steamwar/sql/NodeDownload.java
Normale Datei
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import com.google.common.io.BaseEncoding;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
|
||||
public class NodeDownload {
|
||||
|
||||
private static final SQL.Statement createLink = new SQL.Statement("INSERT INTO NodeDownload (NodeId, Link) VALUES (?, ?) ON DUPLICATE KEY UPDATE Link = VALUES(Link)");
|
||||
|
||||
private static final String BASE = "https://steamwar.de/download.php?schem=";
|
||||
|
||||
public static String getLink(SchematicNode schem){
|
||||
if(schem.isDir())
|
||||
throw new SecurityException("Can not Download Directorys");
|
||||
MessageDigest digest;
|
||||
try {
|
||||
digest = MessageDigest.getInstance("SHA-1");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
digest.reset();
|
||||
digest.update((Instant.now().toString() + schem.getOwner() + schem.getId()).getBytes());
|
||||
String hash = BaseEncoding.base16().encode(digest.digest());
|
||||
createLink.update(schem.getId(), hash);
|
||||
return BASE + hash;
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren
CheckedSchematic kann ganz aus dem SpigotCore entfernt werden, ich glaube, kein System (im SpigotCore) braucht den noch.
Die SQL klasse ist aber nur Protected