id
stringlengths
36
36
text
stringlengths
1
1.25M
80545766-b4a7-45b1-b457-e8f7c91f2503
public void ClearSentQueue() { jobsent.clear(); }
bea5f90c-8032-4e75-9e35-2ec143d009b3
public Auth(Logging passedLog) { psk = null; mylog = passedLog; // Load Shiro try { Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini"); SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); mylog.out("INFO", ...
2c281669-87a1-4c97-9fc0-f4e5d5bfca8b
public void SetPSK(String PassedPSK) { if (PassedPSK.isEmpty()) { mylog.out("FATAL", "PreShared Key CANNOT be set to empty/null."); System.exit(0); } psk = PassedPSK; }
233f7fd2-6814-438e-9cd2-7853f3662811
public String[] GetCredential() { // Cast variables String user = ""; String pw = ""; // Create input handle BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // Capture subject identity (user name) System.out.println("Provide subject identity:"); try { user = br.readLine();...
7429fd53-e401-443a-aec2-1b1dd1b7ad81
public Subject Login(String username, String password) { // Create subject identity Subject currentUser = SecurityUtils.getSubject(); // Authenticate user if (!currentUser.isAuthenticated()) { try { UsernamePasswordToken token = new UsernamePasswordToken(username, password); token.setRememberMe(true...
2da5d691-5355-4e0f-bd14-b75c53e711f8
private void failedLogin() { mylog.out("FATAL", "Login DENIED"); mylog.out("FATAL", "Application terminated"); System.exit(0); }
68467be5-74cc-45f5-bad3-a4c2c7e261c7
public Session EstablishSession(Subject targetSubject) { // Setup a session Session session = targetSubject.getSession(); // Determine the rough use of the session, store it for easy access if (targetSubject.hasRole("nothing")) { session.setAttribute("USE", ""); session.setAttribute("SecurityLevel", "0")...
8ba06e4d-d0d6-46bf-87bb-bd9ec2c6b8cb
public String GetPSK() { return psk; }
13d6e10c-d2eb-42bd-8885-9d7a410188f4
public ServerThread(Auth passedSubject, Logging passedLog, Socket passedSocket, int passedUID, Object passedLock, JobManagement passedJobQueue, boolean PassedMode) { subject = passedSubject; mylog = passedLog; socket = passedSocket; UID = passedUID; JobLock = passedLock; JobQueue = passedJobQueue; Serv...
9bc1cfd1-0a48-41bf-8ccc-94c19774f2a3
public ServerThread(Logging passedLog, Object passedLock, JobManagement passedJobQueue) { mylog = passedLog; JobLock = passedLock; JobQueue = passedJobQueue; }
3c411897-f5a0-4857-8267-b83e2c3e3852
public void JobLoader(String type) { synchronized (JobLock) { if (type.compareToIgnoreCase("sw") == 0) { JobQueue.SampleWindows(); mylog.out("INFO", "Loaded 10 sample jobs (Windows)."); } else if (type.compareToIgnoreCase("sl") == 0) { JobQueue.SampleLinux(); mylog.out("INFO", "Loaded 10 sample ...
da9630ad-486a-4070-a96c-61b09a0f5160
public void JobLoader(String type, String filename) { int QtyJobsLoaded = 0; synchronized (JobLock) { if (type.compareToIgnoreCase("load") == 0) { try { QtyJobsLoaded = JobQueue.Load(filename); } catch (IOException e) { mylog.out("ERROR", "Failed to load jobs from file [" + filename + "]"); ...
7e2bf74b-e32b-4924-9371-a3b884bdc369
public String AssignJob(String clientID, String OS, int ClientSecurityLevel) { String job = ""; synchronized (JobLock) { job = JobQueue.Assign(clientID, OS, ClientSecurityLevel); } return job; }
955b9fa3-688c-4183-93ee-14515044c300
public void run() { // UID is just an iterator from the server side // It has no bearing on anything besides the raw question // "How many have connected to this single runtime?" mylog.out("INFO", "Establishing session with client number [" + UID + "]"); // Load and save the cleints IP and port for future UU...
6862caab-0661-49ce-8a55-579e0f4ca777
private String fromNetwork() { String decryptedValue = null; byte[] initialValue = network.ReceiveByte(); if (initialValue == null) { mylog.out("WARN", "Client disconnected abruptly"); } decryptedValue = crypt.decrypt(initialValue); if (decryptedValue == null) { mylog.out("WARN", "Client disconnected...
2953a8d3-1701-47be-83df-0b8f39fc7758
private byte[] fromNetworkByte() { byte[] decryptedValue = null; byte[] initialValue = network.ReceiveByte(); if (initialValue == null) { mylog.out("WARN", "Client disconnected abruptly"); } decryptedValue = crypt.decryptByte(initialValue); if (decryptedValue == null) { mylog.out("WARN", "Client disc...
75db4fe8-c110-42f7-83c8-5848d6ae746c
private void SendACK() { network.Send(crypt.encrypt("<ACK>")); if (crypt.decrypt(network.ReceiveByteACK()).compareToIgnoreCase("<ACK>") != 0) { mylog.out("ERROR", "Partner failed to ACK"); } }
85d57dcc-59ce-4cc6-8a84-f064f4ce8196
private void RecieveACK() { if (crypt.decrypt(network.ReceiveByteACK()).compareToIgnoreCase("<ACK>") != 0) { mylog.out("ERROR", "Partner failed to ACK"); } network.Send(crypt.encrypt("<ACK>")); }
c7b0332f-1eed-4cd3-944f-9d1ebd4ea72a
public Crypto(Logging passedLog, String password, String Target) { // Setup log mylog = passedLog; // Setup cipher cipher = new AesCipherService(); // NEW key setup cipher.setKeySize(128); byte[] salt = CodecSupport.toBytes(password + "ExtraSalty"); SecretKeyFactory factory = null; try { factory ...
3bd1ddff-8fa9-4a3c-9293-06d0f9278034
public void ReKey(String newPassword, String ReKeyedWith) { byte[] salt = CodecSupport.toBytes(newPassword + "ExtraSalty"); SecretKeyFactory factory = null; try { factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); } catch (NoSuchAlgorithmException e) { mylog.out("ERROR", "PBKDF2 is MISSING"); ...
d3da9046-9730-43bf-b114-a9f1542593eb
public void test() { String text = "Tell nobody!"; // Encrypt byte[] encrypted = encrypt(text); // Decrypt String decrypted = decrypt(encrypted); // Validate if (text.compareTo(decrypted) == 0) { System.out.println("TRUE!"); } else { System.out.println("False"); } System.out.println("[" + t...
11576b49-17dd-4ae0-9dfe-1b03c4394365
public byte[] encrypt(String plainText) { byte[] encrypted = cipher.encrypt(CodecSupport.toBytes(plainText), KeyBytes).getBytes(); return encrypted; }
e5643424-0019-4b0d-a145-731603868a00
public byte[] encrypt(byte[] byteArray) { byte[] encrypted = cipher.encrypt(byteArray, KeyBytes).getBytes(); return encrypted; }
fea138eb-dbae-463f-bdc0-7eb126e62cfd
public String decrypt(byte[] encryptedText) { if (encryptedText != null) { String decrypted = "Failed2DECRYPT"; try { decrypted = CodecSupport.toString((cipher.decrypt(encryptedText, KeyBytes).getBytes())); } catch (CryptoException err) { mylog.out("WARN", "Failed to decrypt the message. Likely bad P...
e5ce3ff3-a4ba-468e-8d46-b882bef25d5c
public byte[] decryptByte(byte[] encryptedText) { byte[] decrypted = null; try { decrypted = (cipher.decrypt(encryptedText, KeyBytes).getBytes()); } catch (CryptoException err) { mylog.out("WARN", "Failed to decrypt the message. Likely bad PSK."); } return decrypted; }
0282ef24-631c-45cd-a44a-8a2bc743c4bb
public void testDH() { DH sideA = new DH(mylog); DH sideB = new DH(mylog, sideA.GetPrime(16), 16, sideA.GetBase(16), 16); sideA.DHPhase1(); sideB.DHPhase1(); sideA.DHPhase2(sideB.GetPublicKey(), "Test"); sideB.DHPhase2(sideA.GetPublicKey(), "Test"); // Final verification System.out.println("Shared Secr...
781ac144-1683-414a-9b35-cc0371e7d490
@Before public void createCloseWindowsCheat() { this.cheat = new Cheat("Close Windows", "Open Start Menu"); }
d3c76c36-3ff3-487d-90b8-8f625d26f1e4
@Test public void shouldNotEqualsOpenWindows() { assertFalse(this.cheat.equals(new Cheat("Open Windows", "Never do that"))); }
54a6d973-d006-4fe0-9145-d2241c80f355
@Before public void createFacesWithFileGitCheatTxt() throws IOException { this.faces = Faces.loadFile("templates/git-cheat.txt"); }
89c6f0ec-f746-4dae-bda6-481153f588f2
@Test public void facesSizeShouldBeFive() { assertEquals(5, (int) this.faces.size()); }
51c8618d-d37b-4fb2-9cb3-55f6ed96f9ad
@Test public void firstFaceShouldEqualsAnotheFaceWithSameCheats() { Face face = new Face("Create & clone") .newCheat("git init", "create new repository") .newCheat("git clone /path/to/repo", "clone local repository") .newCheat("git clone username@host:/path/to/repo", "clone remote repo"); assertEquals(...
524617be-ea18-4c5d-9a5d-7c917ef28a0d
@Test public void firstFaceShouldNotEqualsAnotheFaceWithOtherTitle() { Face face = new Face("Create") .newCheat("git init", "create new repository") .newCheat("git clone /path/to/repo", "clone local repository") .newCheat("git clone username@host:/path/to/repo", "clone remote repo"); assertFalse(face.equ...
b85abb59-6b11-4cca-a940-c605701df17f
@Test public void firstFaceNotShouldEqualsAnotheFaceWithNotSameNumberOfCheats() { Face face = new Face("Create & clone") .newCheat("git init", "create new repository"); assertFalse(face.equals(this.faces.at(0))); }
2a9326a8-dcef-42d2-8f03-e0c081cee33c
@Test public void firstFaceShouldNotEqualsAnotheFaceWithOtherCheatsAndSameSize() { Face face = new Face("Create & clone") .newCheat("git init", "create old repository") .newCheat("git clone /path/to/repo", "clone local repository") .newCheat("git clone username@host:/path/to/repo", "clone remote repo"); ...
1f78d1ae-bf97-4fdc-87ad-4cdc2b4a712c
@Before public void generateSVGFromGitCheat() throws IOException, ParserConfigurationException, SAXException, XPathExpressionException, TransformerException { String svg = (new SVGCubeFile("templates/cube.svg")).fusion("templates/git-cheat.txt"); this.doc = (new XMLDocument()).loadXMLString(svg); }
9a976a6a-f05c-4473-ba3d-4a9021e95190
@Test public void aTagTSpanShouldContainsCreateAndClone() throws XPathExpressionException { assertTrue(this.doc.match("//tspan[contains(text(), \"Create & clone\")]")); }
85232b55-dabc-44c3-9019-15d9f3b67392
@Test public void aTagTSpanShouldContainsAddAndRemove() throws XPathExpressionException { assertTrue(this.doc.match("//tspan[contains(text(), \"Add & remove\")]")); }
c297a78b-f32a-45bc-b2c0-cda285ca11c0
@Test public void aTextTagShouldContainsGitInitCheat() throws XPathExpressionException { assertTrue(this.doc.match("//text//tspan[contains(text(), \"git init\")][following-sibling::tspan[contains(text(), \"create new repository\")]]")); }
a0a15ed8-b1da-4cb0-84b4-3db1d468f009
@Test public void aTextTagShouldContainsGitPushOriginMaster() throws XPathExpressionException { assertTrue(this.doc.match("//text//tspan[contains(text(), \"git push origin master\")][following-sibling::tspan[contains(text(), \"push changes\")]]")); }
4790aa24-c1bf-4b2c-b0e7-5877f2931113
public FacesTxtFile(String filename) { this.filename = filename; }
5f0c02cc-ed2e-4bbe-8c2e-07066c49cf8a
public Faces populate(Faces faces) throws IOException { BufferedReader input = new BufferedReader(new FileReader(new File( this.filename))); try { this.populate(faces, input); } finally { input.close(); } return faces; }
9c974df4-3901-42dd-982f-f87829e62588
private void populate(Faces faces, BufferedReader input) throws IOException { String line; while ((line = input.readLine()) != null) { this.parseLine(line, faces); } }
040f4543-8fec-4537-9204-27b82ea63f2a
private void parseLine(String line, Faces faces) { if (line.startsWith("* ")) { faces.newFace(line.substring(2)); } if (line.startsWith("** ")) { this.currentCheatTitle = line.substring(3); } if (line.startsWith("*** ")) { faces.newCheat(this.currentCheatTitle, line.substring(4)); } }
0963dab0-df5b-4e0a-b12d-70208dbd92a3
public SVGCubeFile(String filePath) { this.filePath = filePath; }
279556d2-445b-4f8a-91f6-4343a9a41829
public String fusion(String cheatFilePath) throws IOException, XPathExpressionException, SAXException, ParserConfigurationException, TransformerException { Faces faces = Faces.loadFile(cheatFilePath); XMLDocument doc = (new XMLDocument()).loadXMLFile(this.filePath); return this.fusion(faces, doc); }
dd762aa3-2800-4890-8c76-c6528af9d8a5
public String fusion(Faces faces, XMLDocument doc) throws SAXException, IOException, ParserConfigurationException, XPathExpressionException, TransformerException { faces.acceptVisitor(new FacesToSVGVisitor(doc, faces)); return doc.asXMLString(); }
38623944-9439-430f-b88c-7e5490fa64ba
public CheatToSVGVistor(Element title, Element content) { this.title = title; this.content = content; }
e6a21578-6861-450e-aec9-3bf68055c3f8
@Override public void visitTitle(String title) { this.title.setTextContent(title); }
79607c78-bb1c-4ac6-ae4c-934bae5e31a2
@Override public void visitContent(String content) { this.content.setTextContent(content); }
4be30016-8d6d-4584-bcdd-82896d377a39
public abstract void visitFace(Face face, Integer i) throws XPathExpressionException;
c635c8e6-e29d-4c0c-8951-1cb3a11e2fa6
public Cheat(String title, String content) { this.title = title; this.content = content; }
b5a029a8-dbaa-4a85-8a46-13fd1b07a318
public boolean equals(Object other) { Cheat cheat = (Cheat) other; return this.title.equals(cheat.title) && this.content.equals(cheat.content); }
8e240644-9120-467f-8dc5-3f10a4142f26
public void acceptVisitor(ICheatVisitor visitor) { visitor.visitTitle(this.title); visitor.visitContent(this.content); }
7a58f231-ad05-455c-a4db-2f72221566e2
public static void main(String[] args) throws XPathExpressionException, IOException, SAXException, ParserConfigurationException, TransformerException { System.out.println((new SVGCubeFile(args[0])).fusion(args[1])); }
c2affe58-b8ca-4f2e-a929-eef649f0abc4
public FaceToSVGVisitor(XMLDocument doc, Element blocNode, Element templateNode) { this.blocNode = blocNode; this.templateNode = templateNode; this.doc = doc; }
a74021bf-e4b5-4769-b773-9cd86b150ce8
@Override public void visitTitle(String title) { this.blocNode.setTextContent(title); }
f6be9984-3e12-4785-8551-afbc147ff678
@Override public void visitCheat(int cheatNumber, Cheat cheat) { Element cheatNode = (Element) this.templateNode.cloneNode(false); this.templateNode.getParentNode().appendChild(cheatNode); Float y = cheatNumber * 10 + Float.parseFloat(this.templateNode.getAttribute("y")); cheatNode.setAttribute("y", y.toS...
74c7dfad-7a11-4e7a-a1cf-cf4aada096d9
public Element newCheatContentNodeOn(Element cheatNode) { Element content = this.doc.createElement("tspan"); cheatNode.appendChild(content); return content; }
85f114b6-e1aa-4bd9-9d52-169a0ffeb294
public Element newCheatTitleNodeOn(Element cheatNode) { Element title = this.doc.createElement("tspan"); title.setAttribute("style", "font-weight: bold"); cheatNode.appendChild(title); return title; }
3df327a3-cb19-4500-bf84-26f7f406ec16
void visitTitle(String content);
2cf50b3e-22d2-4ff6-a909-31ef8c56f4f5
void visitContent(String content);
c8b61251-0da6-4d3e-b433-8c1623152ec8
public static Faces loadFile(String filename) throws IOException { return new FacesTxtFile(filename).populate(new Faces()); }
149ac799-bb6b-409b-8a76-76c1a7134581
public void newFace(String title) { this.faces.add(new Face(title)); }
e9fba465-2723-4ba0-b6c7-bf0337ed801e
public Integer size() { return this.faces.size(); }
a74b452a-0860-4852-9052-fb886fefa0d6
public Face at(int i) { return this.faces.get(i); }
d7f737f8-a5f3-4b19-bf51-78ed18d1c909
public Face last() { return this.faces.get(this.faces.size() - 1); }
11decb2e-4987-49eb-ab71-1d7965be0afa
public void newCheat(String title, String content) { this.last().newCheat(title, content); }
e16ab7bd-9510-496b-8e90-9bc7649042b9
public void acceptVisitor(IFacesVisitor visitor) throws XPathExpressionException { for(Integer i=1; i <= this.size(); i++) { visitor.visitFace(this.faces.get(i-1), i); } }
2a298a92-2248-4bde-b17a-d074de9939a4
public XMLDocument loadXMLString(String xml) throws SAXException, IOException, ParserConfigurationException { this.doc = this.newDocumentBuilder().parse( new InputSource(new StringReader(xml))); return this; }
a4cabdeb-91b4-449b-baa9-c7d426de2eab
public XMLDocument loadXMLFile(String filepath) throws SAXException, IOException, ParserConfigurationException { this.doc = this.newDocumentBuilder().parse(filepath); return this; }
a025ab47-94bd-4d01-a92a-c18a8f17283a
public NodeList nodesFromXPath(String xpathQuery) throws XPathExpressionException { return (NodeList) this.newXPathExpression(xpathQuery).evaluate( this.doc, XPathConstants.NODESET); }
983e416d-2ce5-414d-9804-b95db823bf3d
public boolean match(String xpathQuery) throws XPathExpressionException { return (this.nodesFromXPath(xpathQuery).getLength() > 0); }
544b102a-d040-4bdf-b3ba-184d2e76012f
public Element getFirstNodeFromXPath(String xpath) throws XPathExpressionException { return (Element) this.nodesFromXPath(xpath).item(0); }
fad9ef78-7cbc-4c04-8829-6402baf328fd
public String asXMLString() throws TransformerFactoryConfigurationError, TransformerException { StringWriter writer = new StringWriter(); this.writeDocXMLOn(writer); return writer.toString(); }
681bf739-98e9-4185-a9f1-4395160b52d5
public Element createElement(String name) { return this.doc.createElement(name); }
bd314ce8-9f5a-4b26-a3e8-0cc41426c677
public void writeDocXMLOn(StringWriter writer) throws TransformerException, TransformerConfigurationException, TransformerFactoryConfigurationError { StreamResult result = new StreamResult(writer); this.newTransformer().transform(new DOMSource(this.doc), result); }
f3796528-8e05-40b4-bc47-34a70c1f922f
public Transformer newTransformer() throws TransformerConfigurationException, TransformerFactoryConfigurationError { Transformer transformer = TransformerFactory.newInstance() .newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); return transformer; }
69e5d703-83c3-457c-a682-4efd6022a711
public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException { return DocumentBuilderFactory.newInstance().newDocumentBuilder(); }
407af677-e967-41fd-a40c-6fe6b3f94577
public XPathExpression newXPathExpression(String xpathQuery) throws XPathExpressionException { return newXPath().compile(xpathQuery); }
941e31bd-efff-42f7-b56d-832e0a35d935
public XPath newXPath() { return XPathFactory.newInstance().newXPath(); }
d1f0155b-137a-4861-802f-53094acd7875
public Face(String title) { this.title = title; }
9c880035-1402-434f-8036-00efb760aa6d
public Face newCheat(String title, String content) { this.cheats.add(new Cheat(title, content)); return this; }
27e12ea8-2ff8-4d1e-bacb-7bbc0967643f
@Override public boolean equals(Object other) { Face otherFace = (Face)other; return this.title.equals(otherFace.title) && this.cheats.equals(otherFace.cheats); }
71fdc804-0f4b-4a4a-bfd7-bb173feddff4
public void acceptVisitor(IFaceVisitor faceToSVGVisitor) { faceToSVGVisitor.visitTitle(this.title); this.cheats.acceptVisitor(faceToSVGVisitor); }
4ab23319-dcbf-40b5-b583-3e8f5a465396
public FacesToSVGVisitor(XMLDocument doc, Faces faces) { this.faces = faces; this.doc = doc; }
ba4110b3-cad2-4999-9847-1970f630a045
@Override public void visitFace(Face face, Integer faceNumber) throws XPathExpressionException { Element blocNode = this.doc .getFirstNodeFromXPath("//tspan[contains(text(), \"$BLOCK" + faceNumber.toString() + "\")]"); Element templateNode = this.doc .getFirstNodeFromXPath("//text[contains(text(), \...
8b2c09b0-46e1-4c6c-b71e-2681a0f94fdb
void visitTitle(String title);
7aa330ce-2fbe-4bcd-8ddb-5ba42824ce91
void visitCheat(int i, Cheat cheat);
decdf68b-f224-480a-8f41-655a41671dce
public Iterator<Cheat> iterator() { return this.cheats .iterator(); }
9968bfad-b9df-4c9b-b054-ad8691ef7863
public void add(Cheat cheat) { this.cheats.add(cheat); }
a086be2b-f0f7-4863-a909-739e4084e95f
@Override public boolean equals(Object other) { Cheats otherCheats = (Cheats)other; if (otherCheats.cheats.size() != this.cheats.size()) return false; for(int i=0; i<this.cheats.size(); i++) { if (! this.cheats.get(i).equals(otherCheats.cheats.get(i))) return false; } return true; }
86caf904-308b-4f45-aea7-9c38604deac9
public void acceptVisitor(IFaceVisitor faceToSVGVisitor) { for(int i=0; i<this.cheats.size(); i++) { faceToSVGVisitor.visitCheat(i, cheats.get(i)); } }
cca2b374-1d82-4e33-8f14-76f32e793918
public Duck() { }
f95f633a-4c94-4e8f-b8c4-f77b02faa2c5
public abstract void display ();
4dac854a-0397-4132-9adc-6abb3f07fd37
public void performFly() { flyBehavior.fly(); }
71e29131-bcea-40c4-b78b-5b5bd33f65f0
public void performQuack() { quackBehavior.quack(); }
9850a97a-f1d8-400e-8131-73ce1cca87d7
public void swim() { System.out.println("All ducks float, even decoys."); }
89d5d2b4-f2ec-46d7-822d-c44eea04e868
public void quack();
1680cf0f-9896-4c7b-8543-f4b1f5ce056f
public void fly() { System.out.println("I'm flying."); }
10e42761-4c08-41ef-897b-c16f339ef5cf
public MallardDuck() { quackBehavior = new Quack(); flyBehavior = new FlyWithWings(); }