├── .gitignore ├── .travis.yml ├── CONTRIBUTION.md ├── LICENSE.md ├── README.md ├── app.js ├── cert ├── apiserver │ └── .gitkeep ├── authserver │ └── .gitkeep └── sessionserver │ └── .gitkeep ├── cli.js ├── config ├── default.json ├── production.json ├── testing-config.json ├── testing-fallback.json └── testing-mongodb.json ├── db.js ├── docs ├── Installation.md ├── Usage.md └── Utilities.md ├── fixtures └── user.js ├── generate_ssl.sh ├── images ├── cape │ └── .gitkeep └── skin │ ├── .gitkeep │ └── steve.png ├── lib ├── actions.js ├── cli │ └── userHelper.js ├── driver │ ├── config.js │ └── mongodb.js ├── keychain.js ├── logger.js └── userManager.js ├── package-lock.json ├── package.json ├── patcher ├── build.xml ├── dist │ ├── MANIFEST.MF │ ├── patcher.exe │ └── patcher.jar ├── launch4j.config.xml ├── launch4j │ ├── LICENSE.txt │ ├── bin │ │ ├── COPYING │ │ ├── ld │ │ └── windres │ ├── head │ │ ├── LICENSE.txt │ │ ├── consolehead.o │ │ ├── guihead.o │ │ └── head.o │ ├── launch4j.jar │ ├── launch4j.jfpr │ ├── lib │ │ ├── JGoodies.Forms.LICENSE.txt │ │ ├── JGoodies.Looks.LICENSE.txt │ │ ├── Nuvola.Icon.Theme.LICENSE.txt │ │ ├── XStream.LICENSE.txt │ │ ├── ant.LICENSE.txt │ │ ├── ant.jar │ │ ├── commons-beanutils.jar │ │ ├── commons-logging.jar │ │ ├── commons.LICENSE.txt │ │ ├── formsrt.jar │ │ ├── foxtrot.LICENSE.txt │ │ ├── foxtrot.jar │ │ ├── jgoodies-common.jar │ │ ├── jgoodies-forms.jar │ │ ├── jgoodies-looks.jar │ │ └── xstream.jar │ ├── sign4j │ │ ├── README.txt │ │ └── sign4j.c │ └── w32api │ │ ├── MinGW.LICENSE.txt │ │ ├── crt2.o │ │ ├── libadvapi32.a │ │ ├── libgcc.a │ │ ├── libkernel32.a │ │ ├── libmingw32.a │ │ ├── libmsvcrt.a │ │ ├── libshell32.a │ │ └── libuser32.a ├── lib │ ├── gson-2.4.jar │ └── lzma-4.63-jio-0.93.jar └── src │ ├── Main.java │ ├── commands │ ├── AuthlibPatcher.java │ ├── CertInstaller.java │ ├── CertManager.java │ ├── HostsPatcher.java │ ├── LauncherPatcher.java │ └── ServerPatcher.java │ ├── lib │ ├── BasePatcher.java │ ├── CertKeyStoreManager.java │ ├── VersionComparator.java │ └── VersionTokenizer.java │ └── models │ ├── LatestVersion.java │ ├── Version.java │ └── Versions.java ├── static └── .gitkeep └── test ├── authenticate_fallback_spec.js ├── authenticate_spec.js ├── invalidate_spec.js ├── playernameToUuid_spec.js ├── playernamesToUuid_spec.js ├── refresh_spec.js ├── root_spec.js ├── sessionJoin_spec.js ├── sessionUuidToProfile_spec.js ├── session_hasJoined_spec.js ├── signOut_spec.js ├── synchronousTestRunner.js ├── uuidToName_spec.js └── validate_spec.js /.gitignore: -------------------------------------------------------------------------------- 1 | /images/*.* 2 | /images/skin/* 3 | /images/cape/* 4 | !/images/*/.gitkeep 5 | !/images/skin/steve.png 6 | /static/* 7 | !/static/.gitkeep 8 | node_modules 9 | .idea 10 | /cert/*/* 11 | !/cert/*/.gitkeep 12 | /patcher/build 13 | /patcher/out 14 | /patcher/*.iml 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: false 3 | node_js: 4 | - '8' 5 | - '9' 6 | - '10' 7 | services: 8 | - mongodb 9 | before_install: 10 | - npm install -g frisby 11 | - npm install -g jasmine-node 12 | - npm install -g underscore 13 | - npm install -g pow-mongodb-fixtures 14 | - ./generate_ssl.sh 15 | before_script: 16 | - mongofixtures test fixtures 17 | - npm start & 18 | - sleep 5 19 | after_script: 20 | - process.exit() 21 | env: 22 | - NODE_ENV=testing-config 23 | - NODE_ENV=testing-mongodb 24 | - NODE_ENV=testing-fallback 25 | matrix: 26 | exclude: 27 | - node_js: '9' 28 | env: NODE_ENV=testing-fallback 29 | - node_js: '10' 30 | env: NODE_ENV=testing-fallback -------------------------------------------------------------------------------- /CONTRIBUTION.md: -------------------------------------------------------------------------------- 1 | # Contribution guide 2 | 3 | ## Installing the testing framework 4 | 5 | For testing you will need FrisbyJs and Jasmine: 6 | 7 | npm install -g frisby 8 | npm install -g jasmine-node 9 | npm install pow-mongodb-fixtures -g 10 | npm install -g underscore 11 | 12 | Note: Underscore is required because of an issue in the dependencies of mongodb-fixtures. 13 | 14 | ## Running the tests 15 | 16 | First, start the server in testing mode: 17 | 18 | NODE_ENV=testing-config node app.js 19 | 20 | (Re)populate the testing Mongodb database: 21 | 22 | mongo test --eval \"db.dropDatabase()\" 23 | mongofixtures test fixtures 24 | 25 | Then the tests: 26 | 27 | NODE_ENV=testing-config jasmine-node test 28 | 29 | All tests must pass. You have to repeat the steps above for all environments: 30 | 31 | * testing-config 32 | * testing-mongodb 33 | * testing-fallback 34 | 35 | ## Misc dev notes 36 | 37 | Environment variables: 38 | 39 | MJOLNIR_VERBOSE: boolean, set true to verbose mode 40 | NODE_ENV: environment in which the application should run, the default is development; can be: production, testing -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright © `2016` `András Rutkai` 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the “Software”), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Mjölnir Authentication Server 2 | ============================= 3 | 4 | [![Build Status](https://travis-ci.org/rutkai/Mjolnir-Authentication-Server.svg?branch=master)](https://travis-ci.org/rutkai/Mjolnir-Authentication-Server) 5 | 6 | Abstract 7 | -------- 8 | 9 | Mjölnir authentication is fully compatible with Yggdrasil authentication which is used by Minecraft and other Mojang apps. 10 | However, Mjölnir is developed for replacing the authentication system of Minecraft in case you want an own authentication server. 11 | 12 | Features (planned): 13 | 14 | - Backup authentication server (in proxy mode) 15 | - Rate limit 16 | 17 | In which cases are good such a system? 18 | 19 | - You have users who do not have premium but you still want to maintain an online server. 20 | - You want to have a backup authentication system. 21 | - ...or just because you can do it. :) 22 | 23 | 24 | Usage (clients/servers) 25 | ------------------------------ 26 | 27 | See [Usage guide](docs/Usage.md). 28 | 29 | Installation/Usage (Mjölnir) 30 | ---------------------- 31 | 32 | See [Installation guide](docs/Installation.md). 33 | 34 | Utilities 35 | --------- 36 | 37 | See [Utilities page](docs/Utilities.md). 38 | 39 | Dev Installation 40 | ---------------- 41 | 42 | See [Contribution guide](CONTRIBUTION.md) for dev installation. 43 | 44 | Specification 45 | ------------- 46 | 47 | [Documentation](http://wiki.vg/Authentication) 48 | 49 | Roadmap/Changelog 50 | ----------------- 51 | 52 | * 1.0.0: User management with file backend 53 | * 1.1.0: MongoDB backend 54 | * 1.2.0: Transparent (proxy) mode 55 | 56 | License 57 | ------- 58 | 59 | **MIT** 60 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var app = express(); 3 | var bodyParser = require('body-parser'); 4 | var http = require('http'); 5 | var https = require('https'); 6 | var pem = require('pem'); 7 | var config = require('config'); 8 | var fs = require('fs'); 9 | var actions = require('./lib/actions'); 10 | var logger = require('./lib/logger'); 11 | var keychain = require('./lib/keychain'); 12 | 13 | 14 | app.use(bodyParser.urlencoded({extended: true})); 15 | app.use(bodyParser.json()); 16 | 17 | logger.log("---- Mjolnir authentication server (auth) ----"); 18 | if (process.env.MJOLNIR_VERBOSE) { 19 | logger.log("Settings:"); 20 | logger.log(JSON.stringify(config, null, 4)); 21 | logger.log("Available hashing algorithms: " + require('crypto').getHashes()); 22 | } 23 | 24 | 25 | // Images 26 | app.use('/images', express.static('images')); 27 | app.use('/static', express.static('static')); 28 | 29 | // Authserver 30 | app.all('/', actions.root); 31 | app.all('/authenticate', actions.authenticate); 32 | app.all('/refresh', actions.refresh); 33 | app.all('/validate', actions.validate); 34 | app.all('/signout', actions.signOut); 35 | app.all('/invalidate', actions.invalidate); 36 | 37 | // Sessionserver 38 | app.all('/session/minecraft/join', actions.sessionJoin); 39 | app.all('/session/minecraft/hasJoined', actions.sessionHasJoined); 40 | app.all('/session/minecraft/profile/:uuid', actions.sessionUUIDToProfile); 41 | 42 | // APIserver 43 | app.all('/users/profiles/minecraft/:name', actions.apiNameToUUID); 44 | app.all('/user/profiles/:uuid/names', actions.apiUUIDToName); 45 | app.all('/profiles/minecraft', actions.apiPlayernamesToUUID); 46 | 47 | // Other 48 | app.all('*', function (request, response) { 49 | console.log('Unknown request: '); 50 | console.log(request.headers.host, request.originalUrl); 51 | console.log(request.body); 52 | response.status(404).json({ 53 | error: "Not Found", 54 | errorMessage: "The server has not found anything matching the request URI" 55 | }); 56 | }); 57 | 58 | 59 | startServer('sessionserver'); 60 | startServer('authserver'); 61 | startServer('apiserver'); 62 | 63 | 64 | function startServer(server) { 65 | var privateKey = fs.readFileSync('cert/' + server + '/server.key', 'utf8'); 66 | var certOptions = config.util.extendDeep({}, config.get(server + '.certification'), {"clientKey": privateKey}); 67 | 68 | pem.createCertificate(certOptions, function (err, keys) { 69 | if (err) { 70 | console.log(err); 71 | return; 72 | } 73 | 74 | keychain.store(server + '.key', keys.serviceKey); 75 | keychain.store(server + '.crt', keys.certificate); 76 | 77 | fs.writeFile('./cert/' + server + '/certificate.key', keys.serviceKey, function (err) { 78 | if (err) { 79 | console.log(err); 80 | } 81 | }); 82 | fs.writeFile('./cert/' + server + '/certificate.crt', keys.certificate, function (err) { 83 | if (err) { 84 | console.log(err); 85 | } 86 | }); 87 | 88 | http.createServer(app).listen(config.get(server + '.httpPort')); 89 | https.createServer({key: keys.serviceKey, cert: keys.certificate}, app).listen(config.get(server + '.httpsPort')); 90 | 91 | logger.log(server + ' is listening...'); 92 | }); 93 | } 94 | -------------------------------------------------------------------------------- /cert/apiserver/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/cert/apiserver/.gitkeep -------------------------------------------------------------------------------- /cert/authserver/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/cert/authserver/.gitkeep -------------------------------------------------------------------------------- /cert/sessionserver/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/cert/sessionserver/.gitkeep -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | var config = require('config'); 2 | var promptly = require('promptly'); 3 | var crypto = require('crypto'); 4 | var uuid = require('node-uuid'); 5 | 6 | var argv = require('yargs') 7 | .usage('Usage: $0 [options]') 8 | .command('create-hash', 'Creates a hash for a password using the defined hash algorithm.') 9 | .command('generate-uuid', 'Generates a UUID which is compatible with Minecraft.') 10 | .demand(1) 11 | .help('h') 12 | .alias('h', 'help') 13 | .argv; 14 | 15 | switch (argv._[0]) { 16 | case 'create-hash': 17 | createHash(); 18 | break; 19 | case 'generate-uuid': 20 | generateUUID(); 21 | break; 22 | default: 23 | console.log('Invalid command! Use --help for more information.'); 24 | process.exit(1); 25 | break; 26 | } 27 | 28 | 29 | function createHash() { 30 | var algorithm = config.get('hashAlgorithm'); 31 | var passwordValidator = function (value) { 32 | if (!value) { 33 | throw new Error('Password cannot be empty!'); 34 | } 35 | 36 | return value; 37 | }; 38 | 39 | console.log('Hashing algorithm: ', algorithm); 40 | promptly.password('Password: ', { validator: passwordValidator }, function (err, password) { 41 | console.log('Password hash: ', crypto.createHash(algorithm).update(password).digest("hex")); 42 | }); 43 | } 44 | 45 | function generateUUID() { 46 | console.log(uuid.v4()); 47 | } 48 | -------------------------------------------------------------------------------- /config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "serverOwner": "Developer", 3 | "serverDomain": "authserver.mojang.com", 4 | "timestampFormat": "YYYY-MM-DD HH:mm:ss| ", 5 | "hashAlgorithm": "md5", 6 | "secret": "Dev token", 7 | "authserver": { 8 | "httpPort": 9000, 9 | "httpsPort": 9001, 10 | "certification": { 11 | "days": 365, 12 | "selfSigned": true, 13 | "commonName": "authserver.mojang.com" 14 | } 15 | }, 16 | "sessionserver": { 17 | "httpPort": 9010, 18 | "httpsPort": 9011, 19 | "certification": { 20 | "days": 365, 21 | "selfSigned": true, 22 | "commonName": "sessionserver.mojang.com" 23 | } 24 | }, 25 | "apiserver": { 26 | "httpPort": 9020, 27 | "httpsPort": 9021, 28 | "certification": { 29 | "days": 365, 30 | "selfSigned": true, 31 | "commonName": "apiserver.mojang.com" 32 | } 33 | }, 34 | "drivers": ["config", "mongodb"], 35 | "mongodb": { 36 | "connectionStr": "mongodb://localhost:27017/mjolnir" 37 | }, 38 | "users": [ 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /config/production.json: -------------------------------------------------------------------------------- 1 | { 2 | "serverOwner": "Owner", 3 | "hashAlgorithm": "sha512", // Use better than MD5 4 | "secret": "Change this not secret token", // CHANGE THIS LINE TO SOMETHING RANDOM 5 | "certification": { 6 | "country": "HU", 7 | "state": "Budapest", 8 | "organization": "Rutkai", 9 | "organizationUnit": "Single developer", 10 | "emailAddress": "mail@mail.com" 11 | }, 12 | "users": [ 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /config/testing-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "serverOwner": "Tester", 3 | "timestampFormat": "YYYY-MM-DD HH:mm:ss| ", 4 | "hashAlgorithm": "md5", 5 | "secret": "test-token", 6 | "authserver": { 7 | "httpPort": 6666, 8 | "httpsPort": 6667 9 | }, 10 | "sessionserver": { 11 | "httpPort": 6677, 12 | "httpsPort": 6678 13 | }, 14 | "apiserver": { 15 | "httpPort": 6688, 16 | "httpsPort": 6689 17 | }, 18 | "users": [ 19 | { 20 | "id": "650bed2c-9ef5-4b5f-b02c-61fa493c68b5", 21 | "username": "test", 22 | "password": "098f6bcd4621d373cade4e832627b4f6", // test using MD5 23 | "playerName": "testPlayer", 24 | "skinUrl": "steve.png" 25 | }, 26 | { 27 | "id": "1294fda6-159c-4218-be4c-89b660d9cf32", 28 | "username": "testOld", 29 | "password": "098f6bcd4621d373cade4e832627b4f6", 30 | "playerName": "testPlayerOld", 31 | "skinUrl": "steve.png", 32 | "capeUrl": "mycape.png", 33 | "clientToken": "test-old-client-token", 34 | "accessToken": "d41d8cd98f00b204e9800998ecf8427e", 35 | "lastLogin": "2015-04-23T18:25:43.511Z" 36 | } 37 | ], 38 | "drivers": ["config"] 39 | } 40 | -------------------------------------------------------------------------------- /config/testing-fallback.json: -------------------------------------------------------------------------------- 1 | { 2 | "serverOwner": "Tester", 3 | "timestampFormat": "YYYY-MM-DD HH:mm:ss| ", 4 | "hashAlgorithm": "md5", 5 | "secret": "test-token", 6 | "authserver": { 7 | "httpPort": 6666, 8 | "httpsPort": 6667 9 | }, 10 | "sessionserver": { 11 | "httpPort": 6677, 12 | "httpsPort": 6678 13 | }, 14 | "apiserver": { 15 | "httpPort": 6688, 16 | "httpsPort": 6689 17 | }, 18 | "users": [ 19 | { 20 | "id": "650bed2c-9ef5-4b5f-b02c-61fa493c68b5", 21 | "username": "test", 22 | "password": "098f6bcd4621d373cade4e832627b4f6", // test using MD5 23 | "playerName": "testPlayer", 24 | "skinUrl": "steve.png" 25 | }, 26 | { 27 | "id": "0e565137-f983-49fe-ac61-15adfe19e962", 28 | "username": "overlapUser", 29 | "password": "912ec803b2ce49e4a541068d495ab570", // asdf using MD5 30 | "playerName": "overlapPlayer", 31 | "playerNameIndex": "overlapplayer", 32 | "skinUrl": "steve.png" 33 | } 34 | ], 35 | "drivers": ["config", "mongodb"], 36 | "mongodb": { 37 | "connectionStr": "mongodb://localhost:27017/test" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /config/testing-mongodb.json: -------------------------------------------------------------------------------- 1 | { 2 | "serverOwner": "Tester", 3 | "timestampFormat": "YYYY-MM-DD HH:mm:ss| ", 4 | "hashAlgorithm": "md5", 5 | "secret": "test-token", 6 | "authserver": { 7 | "httpPort": 6666, 8 | "httpsPort": 6667 9 | }, 10 | "sessionserver": { 11 | "httpPort": 6677, 12 | "httpsPort": 6678 13 | }, 14 | "apiserver": { 15 | "httpPort": 6688, 16 | "httpsPort": 6689 17 | }, 18 | "users": [], 19 | "drivers": ["mongodb"], 20 | "mongodb": { 21 | "connectionStr": "mongodb://localhost:27017/test" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /db.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var config = require('config'); 3 | var driver = require('./lib/driver/mongodb'); 4 | var promptly = require('promptly'); 5 | var helper = require('./lib/cli/userHelper'); 6 | var crypto = require('crypto'); 7 | var uuid = require('node-uuid'); 8 | 9 | var argv = require('yargs') 10 | .usage('Usage: $0 [options]') 11 | .command('show', 'Shows the data of an existing user.') 12 | .command('create', 'Creates a new user.') 13 | .command('update', 'Updates an existing user.') 14 | .command('delete', 'Removed a user from database.') 15 | .demand(1) 16 | .help('h') 17 | .alias('h', 'help') 18 | .argv; 19 | 20 | switch (argv._[0]) { 21 | case 'show': 22 | show(); 23 | break; 24 | case 'create': 25 | create(); 26 | break; 27 | case 'update': 28 | update(); 29 | break; 30 | case 'delete': 31 | del(); 32 | break; 33 | default: 34 | console.log('Invalid command! Use --help for more information.'); 35 | process.exit(1); 36 | break; 37 | } 38 | 39 | 40 | function show() { 41 | helper.getUser(driver) 42 | .then(function (user) { 43 | if (!user) { 44 | return console.log('User cannot be found!'); 45 | } 46 | 47 | helper.dumpUser(user); 48 | }) 49 | .catch(function () { 50 | }) 51 | .then(function () { 52 | driver.close(); 53 | }); 54 | } 55 | 56 | function create() { 57 | var user = {}; 58 | 59 | helper.askReqField('Username (required)') 60 | .then(function (username) { 61 | user.username = username; 62 | return helper.askPassword('Password (required)'); 63 | }) 64 | .then(function (password) { 65 | user.password = crypto.createHash(config.get('hashAlgorithm')).update(password).digest("hex"); 66 | return helper.askReqField('Player name (required)'); 67 | }) 68 | .then(function (playerName) { 69 | user.playerName = playerName; 70 | return helper.askOptField('Skin (optional)'); 71 | }) 72 | .then(function (skin) { 73 | user.skinUrl = skin ? skin : 'steve.png'; 74 | try { 75 | fs.accessSync('./images/skin/' + user.skinUrl); 76 | } catch (err) { 77 | console.log('Skin does not exist!'); 78 | throw err; 79 | } 80 | 81 | return helper.askOptField('Cape (optional)'); 82 | }) 83 | .then(function (cape) { 84 | user.capeUrl = cape; 85 | if (user.capeUrl) { 86 | try { 87 | fs.accessSync('./images/cape/' + user.skinUrl); 88 | } catch (err) { 89 | console.log('Cape does not exist!'); 90 | throw err; 91 | } 92 | } 93 | }) 94 | .then(function () { 95 | return driver.findUserBy('username', user.username) 96 | }) 97 | .then(function (user) { 98 | if (user) { 99 | console.log('Username already exists!'); 100 | throw Error('Username already exists!'); 101 | } 102 | }) 103 | .then(function () { 104 | return driver.findUserBy('playerName', user.playerName); 105 | }) 106 | .then(function (user) { 107 | if (user) { 108 | console.log('Player name already exists!'); 109 | throw Error('Player name already exists!'); 110 | } 111 | }) 112 | .then(function () { 113 | helper.dumpUser(user); 114 | 115 | return helper.askConfirm('Are you sure you want to create this user?'); 116 | }) 117 | .then(function () { 118 | user.id = uuid.v4(); 119 | user.playerNameIndex = user.playerName.toLowerCase(); 120 | 121 | return driver.addUser(user); 122 | }) 123 | .then(function () { 124 | console.log('User is added to the database!'); 125 | }) 126 | .catch(function (err) { 127 | }) 128 | .then(function () { 129 | driver.close(); 130 | }); 131 | } 132 | 133 | function update() { 134 | var userDoc; 135 | 136 | helper.getUser(driver) 137 | .then(function (user) { 138 | if (!user) { 139 | console.log('User cannot be found!'); 140 | throw Error('User cannot be found!'); 141 | } 142 | 143 | helper.dumpUser(userDoc = user); 144 | 145 | return helper.askOptField('Username (leave blank for skip)'); 146 | }) 147 | .then(function (username) { 148 | if (username) { 149 | userDoc.username = username; 150 | } 151 | 152 | return driver.findUserBy('username', username); 153 | }) 154 | .then(function (user) { 155 | if (user && user.id !== userDoc.id) { 156 | console.log('Username already exists!'); 157 | throw Error('Username already exists!'); 158 | } 159 | 160 | return helper.askPassword('Password (leave blank for skip)', true); 161 | }) 162 | .then(function (password) { 163 | if (password) { 164 | userDoc.password = crypto.createHash(config.get('hashAlgorithm')).update(password).digest("hex"); 165 | } 166 | 167 | return helper.askOptField('Player name (leave blank for skip)'); 168 | }) 169 | .then(function (playerName) { 170 | if (playerName) { 171 | userDoc.playerName = playerName; 172 | userDoc.playerNameIndex = playerName.toLowerCase(); 173 | } 174 | 175 | return driver.findUserBy('playerName', playerName); 176 | }) 177 | .then(function (user) { 178 | if (user && user.id !== userDoc.id) { 179 | console.log('Player name already exists!'); 180 | throw Error('Player name already exists!'); 181 | } 182 | 183 | return helper.askOptField('Skin (leave blank for skip)'); 184 | }) 185 | .then(function (skin) { 186 | if (skin) { 187 | try { 188 | fs.accessSync('./images/skin/' + skin); 189 | } catch (err) { 190 | console.log('Skin does not exist!'); 191 | throw err; 192 | } 193 | userDoc.skinUrl = skin; 194 | } 195 | 196 | return helper.askOptField('Cape (leave blank for skip)'); 197 | }) 198 | .then(function (cape) { 199 | if (cape) { 200 | try { 201 | fs.accessSync('./images/cape/' + cape); 202 | } catch (err) { 203 | console.log('Cape does not exist!'); 204 | throw err; 205 | } 206 | userDoc.capeUrl = cape; 207 | } 208 | 209 | helper.dumpUser(userDoc); 210 | 211 | return helper.askConfirm('Are you sure you want to update this user as above?'); 212 | }) 213 | .then(function () { 214 | return driver.saveUser(userDoc); 215 | }) 216 | .then(function () { 217 | console.log('User has been updated!'); 218 | }) 219 | .catch(function (err) { 220 | }) 221 | .then(function () { 222 | driver.close(); 223 | }); 224 | } 225 | 226 | function del() { 227 | var userDoc; 228 | 229 | helper.getUser(driver) 230 | .then(function (user) { 231 | if (!user) { 232 | console.log('User cannot be found!'); 233 | throw Error('User cannot be found!'); 234 | } 235 | 236 | helper.dumpUser(userDoc = user); 237 | 238 | return helper.askConfirm('Are you sure you want to delete this user?'); 239 | }) 240 | .then(function () { 241 | return driver.removeUser(userDoc); 242 | }) 243 | .then(function () { 244 | console.log('User has been removed!'); 245 | }) 246 | .catch(function (err) { 247 | }) 248 | .then(function () { 249 | driver.close(); 250 | }); 251 | } 252 | -------------------------------------------------------------------------------- /docs/Installation.md: -------------------------------------------------------------------------------- 1 | # Installation/Configuration of Mjölnir Authentication Server 2 | 3 | ## Installation 4 | 5 | ### Prerequisites 6 | 7 | Node.js have to be installed on your system. 8 | 9 | [How to install Node.js via package manager](https://nodejs.org/en/download/package-manager/) 10 | 11 | If you want to use the Database backend, then you have to install MongoDB: 12 | 13 | [MongoDB Home](https://www.mongodb.com/) 14 | 15 | ### Mjolnir Authentication server 16 | 17 | Download the sources from github: 18 | 19 | git clone https://github.com/riskawarrior/Mjolnir-Authentication-Server.git 20 | 21 | Then: 22 | 23 | npm install --production 24 | 25 | *On linux based systems you may have to install libkrb5-dev package for compiling mongodb plugin pre-requisites.* 26 | 27 | Generate new SSL certificates for your server: 28 | 29 | ./generate_ssl.sh 30 | 31 | *Note that you may have to change the owner of the certification to the same user as node server's!* 32 | 33 | To start the server you have to execute the following command in console: 34 | 35 | NODE_ENV=production node app.js 36 | 37 | If you want to use your authentication server as a daemon, I can recommend using [forever](https://github.com/foreverjs/forever). 38 | 39 | After this step, your server will be accepting requests but not from the default port (443)! You have to redirect traffic to it depending on the virtual host. 40 | 41 | #### Installing and configuring Apache proxy 42 | 43 | Install Apache2 on Debian based systems (e.g. Ubuntu): 44 | 45 | sudo apt-get install apache2 46 | 47 | Then enable modproxy: 48 | 49 | sudo a2enmod proxy_http 50 | 51 | And modssl: 52 | 53 | sudo a2enmod ssl 54 | 55 | And add the following lines to your Apache2 config (usually `/etc/apache2/sites-enabled/000-default`): 56 | 57 | # Authserver 58 | 59 | ServerName authserver.mojang.com 60 | 61 | 62 | Order deny,allow 63 | Allow from all 64 | 65 | 66 | SSLEngine on 67 | SSLProxyEngine On 68 | SSLCertificateFile /cert/authserver/certificate.crt 69 | SSLCertificateKeyFile /cert/authserver/certificate.key 70 | 71 | ProxyRequests off 72 | ProxyPreserveHost on 73 | ProxyPass / http://localhost:9000/ 74 | ProxyPassReverse / http://localhost:9000/ 75 | 76 | 77 | # Sessionserver 78 | 79 | ServerName sessionserver.mojang.com 80 | 81 | 82 | Order deny,allow 83 | Allow from all 84 | 85 | 86 | SSLEngine on 87 | SSLProxyEngine On 88 | SSLCertificateFile /cert/sessionserver/certificate.crt 89 | SSLCertificateKeyFile /cert/sessionserver/certificate.key 90 | 91 | ProxyRequests off 92 | ProxyPreserveHost on 93 | ProxyPass / http://localhost:9010/ 94 | ProxyPassReverse / http://localhost:9010/ 95 | 96 | 97 | # APIserver 98 | 99 | ServerName api.mojang.com 100 | 101 | 102 | Order deny,allow 103 | Allow from all 104 | 105 | 106 | SSLEngine on 107 | SSLProxyEngine On 108 | SSLCertificateFile /cert/apiserver/certificate.crt 109 | SSLCertificateKeyFile /cert/apiserver/certificate.key 110 | 111 | ProxyRequests off 112 | ProxyPreserveHost on 113 | ProxyPass / http://localhost:9020/ 114 | ProxyPassReverse / http://localhost:9020/ 115 | 116 | 117 | *Note: First, you have to start your Mjölnir server to create the certificate files!* 118 | 119 | Finally, restart apache2 to reload the configuration: 120 | 121 | sudo service apache2 restart 122 | 123 | ## Database 124 | 125 | Mjolnir uses Mongodb by default. You may add your users to the database using the [Database manager](Utilities.md). 126 | 127 | ## Configuration 128 | 129 | There are three configuration files: 130 | 131 | * config/default.json: Development mode and default configurations 132 | * config/testing.json: Testing mode, tweaked for automated testing 133 | * config/production.json: Production mode, **override the defaults for your server here** 134 | 135 | **Important notes** for configuring the Production environment: 136 | 137 | * Do not use md5 and other weak password hashing algorithms! 138 | * The secret token must be changed to a randomly generated token! 139 | 140 | ### Selecting encryption algorithm 141 | 142 | You can set which encryption algorithm do you want to use to store passwords. Passwords are salted by default. 143 | 144 | The available encryption algorithms can be dumped by running the server in verbose mode (linux): 145 | 146 | MJOLNIR_VERBOSE=true node app.js 147 | 148 | Or (windows): 149 | 150 | set MJOLNIR_VERBOSE=true 151 | node app.js 152 | 153 | Then, you can set the selected encryption method to the production config. 154 | 155 | ### Creating a user in config 156 | 157 | Open the `config/production.json` file using a text editor. Then add the following lines between the brackets, like this (but without comments): 158 | 159 | "users": [ 160 | { // a user 161 | "id": "6c84fb90-12c4-12e1-840d-7b25c5ee775a", // This ID must be a UUID and it must be unique! See Utilities section. 162 | "username": "test", 163 | "password": "098f6bcd4621d373cade4e832627b4f6", // Here is your encrypted password using the algorithm that you've selected. See Utilities section. 164 | "playerName": "test" 165 | }, 166 | { // a second sample user 167 | "id": "110ec58a-aaf2-4ac4-8393-c866d813b8d1", 168 | "username": "test2", 169 | "password": "098f6bcd4621d373cade4e832627b4f6", 170 | "playerName": "test2" 171 | } 172 | ] 173 | 174 | For UUID and password generation, please see the [Utilities page](Utilities.md). 175 | 176 | > Note: the server runs in fallback mode by default. It means, it uses the users defined in the configuration file, then fallbacks to database. -------------------------------------------------------------------------------- /docs/Usage.md: -------------------------------------------------------------------------------- 1 | # Usage guide for authentication server users 2 | 3 | For all commands, we will use the Patcher which is a tool for simplifying the configuration tasks. 4 | 5 | You can find the patcher in the `patcher/dist` folder. 6 | 7 | *Note: it is not possible to use both the original and the private auth server at the same time! 8 | You have to patch your files to use your private server and unpatch/download original jars to use the original servers again.* 9 | 10 | ## Minecraft server owners 11 | 12 | ### Patching hosts file 13 | 14 | You have to create a redirection from the original auth server to your server. You can do this by patching the hosts file using the patcher (linux): 15 | 16 | java -jar patcher.jar patch-hosts 17 | 18 | Or (windows): 19 | 20 | patcher.exe patch-hosts 21 | 22 | **You'll need administrator/root terminal to do that!** 23 | 24 | ### Trusting SSL certificates 25 | 26 | Now, we have to add the authentication server's certificates as a trusted certificate. Run the following command **as root/administrator** (linux): 27 | 28 | java -jar patcher.jar install-certs 29 | 30 | Or (windows): 31 | 32 | patcher.exe install-certs 33 | 34 | ### Downloading a patched server 35 | 36 | The last step here is to download a new server jar. In fact, we'll use a Vanilla jar file but with the authentication server's certificate. Linux: 37 | 38 | java -jar patcher.jar patch-server 39 | 40 | Windows: 41 | 42 | patcher.exe patch-server 43 | 44 | You're done! You can start your server now (with the downloaded jar) and accept client connections. Please note that clients have to patch their system as well! 45 | 46 | ## Minecraft clients 47 | 48 | ### Patching hosts file 49 | 50 | You have to create a redirection from the original auth server to your server. You can do this by patching the hosts file using the patcher (linux): 51 | 52 | java -jar patcher.jar patch-hosts 53 | 54 | Or (windows): 55 | 56 | patcher.exe patch-hosts 57 | 58 | **You'll need administrator/root terminal to do that!** 59 | 60 | ### Trusting SSL certificates 61 | 62 | Now, we have to add the authentication server's certificates as a trusted certificate. Run the following command **as root/administrator** (linux): 63 | 64 | java -jar patcher.jar install-certs 65 | 66 | Or (windows): 67 | 68 | patcher.exe install-certs 69 | 70 | ### Downloading a patched client 71 | 72 | As you may expected, you have to patch your client. You can download a freshly patcher launcher by running the following command (linux): 73 | 74 | java -jar patcher.jar patch-launcher 75 | 76 | Or (windows): 77 | 78 | patcher.exe patch-launcher 79 | 80 | ### Patching authlib 81 | 82 | Unfortunately, the Minecraft client uses its own library for authentication and not from the launcher. Because of this reason we have to patch that as well. :) 83 | 84 | First, start your launcher, login and start Minecraft if you haven't done it yet. It will download the necessary libraries. After entering the menu, you can exit now. 85 | 86 | Patch the authlib (linux): 87 | 88 | java -jar patcher.jar patch-authlib 89 | 90 | Or (windows): 91 | 92 | patcher.exe patch-authlib 93 | 94 | Aaaand, you're good to go! 95 | -------------------------------------------------------------------------------- /docs/Utilities.md: -------------------------------------------------------------------------------- 1 | # Server utilities 2 | 3 | ## Database manager 4 | 5 | Using the command line database manager (`db.cli`) you can add, create or remove users. 6 | 7 | > Note: you have to put skins in the `images/skin` directory and capes in the `images/cape` directory. Providing the filename is sufficient for entering the skin or cape name upon user creation or update. 8 | 9 | ### Show user 10 | 11 | You can find a user in the database using the `show` command: 12 | 13 | NODE_ENV=production node db.js show 14 | 15 | ### Create user 16 | 17 | You can create a new user using the `create` command: 18 | 19 | NODE_ENV=production node db.js create 20 | 21 | ### Update user 22 | 23 | You can update/edit an existing user using the `update` command: 24 | 25 | NODE_ENV=production node db.js update 26 | 27 | ### Delete user 28 | 29 | You can remove an existing user using the `delete` command: 30 | 31 | NODE_ENV=production node db.js delete 32 | 33 | ## Password hash generator 34 | 35 | You can generate password hashes using the command line interface. Usage (production mode, linux): 36 | 37 | NODE_ENV=production node cli.js create-hash 38 | 39 | Or (production mode, windows): 40 | 41 | set NODE_ENV=production 42 | node cli.js create-hash 43 | 44 | Then type in your password using the interactive console. 45 | 46 | *Note: You will not see the characters you are typing in!* 47 | 48 | ## UUID generator 49 | 50 | You can generate UUID-s for users with the following command: 51 | 52 | node cli.js generate-uuid 53 | -------------------------------------------------------------------------------- /fixtures/user.js: -------------------------------------------------------------------------------- 1 | exports.user = [ 2 | { 3 | "id": "650bed2c-9ef5-4b5f-b02c-61fa493c68b5", 4 | "username": "test", 5 | "password": "098f6bcd4621d373cade4e832627b4f6", // test using MD5 6 | "playerName": "testPlayer", 7 | "playerNameIndex": "testplayer", 8 | "skinUrl": "steve.png" 9 | }, 10 | { 11 | "id": "1294fda6-159c-4218-be4c-89b660d9cf32", 12 | "username": "testOld", 13 | "password": "098f6bcd4621d373cade4e832627b4f6", 14 | "playerName": "testPlayerOld", 15 | "playerNameIndex": "testplayerold", 16 | "skinUrl": "steve.png", 17 | "capeUrl": "mycape.png", 18 | "clientToken": "test-old-client-token", 19 | "accessToken": "d41d8cd98f00b204e9800998ecf8427e", 20 | "lastLogin": "2015-04-23T18:25:43.511Z" 21 | }, 22 | { 23 | "id": "9a7f1d46-4050-462e-bb32-fe4d78f7ec03", 24 | "username": "overlapUser", 25 | "password": "098f6bcd4621d373cade4e832627b4f6", 26 | "playerName": "overlapPlayer", 27 | "playerNameIndex": "overlapplayer", 28 | "skinUrl": "steve.png" 29 | }, 30 | { 31 | "id": "7ac4a66d-859d-4691-a2da-be490d0badcb", 32 | "username": "dbUser", 33 | "password": "d77d5e503ad1439f585ac494268b351b", // db using MD5 34 | "playerName": "dbPlayer", 35 | "playerNameIndex": "dbplayer", 36 | "skinUrl": "steve.png" 37 | } 38 | ]; 39 | -------------------------------------------------------------------------------- /generate_ssl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | openssl genrsa -out cert/authserver/server.key 4096 4 | openssl genrsa -out cert/sessionserver/server.key 4096 5 | openssl genrsa -out cert/apiserver/server.key 4096 6 | 7 | echo -e " The Certificates and Keys have been generated!" 8 | cd .. 9 | -------------------------------------------------------------------------------- /images/cape/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/images/cape/.gitkeep -------------------------------------------------------------------------------- /images/skin/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/images/skin/.gitkeep -------------------------------------------------------------------------------- /images/skin/steve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/images/skin/steve.png -------------------------------------------------------------------------------- /lib/actions.js: -------------------------------------------------------------------------------- 1 | var config = require('config'); 2 | var moment = require('moment'); 3 | var crypto = require('crypto'); 4 | var packageConf = require('../package.json'); 5 | var logger = require('./logger'); 6 | var userManager = require('./userManager'); 7 | var keychain = require('./keychain'); 8 | 9 | 10 | // Authserver actions 11 | exports.root = root; 12 | function root(request, response) { 13 | logger.log("Server info is requested"); 14 | response.json({ 15 | "Status": 'OK', 16 | "Runtime-Mode": 'productionMode', 17 | "Application-Author": 'András Rutkai', 18 | "Application-Description": packageConf.name, 19 | "Specification-Version": '2.13.34', 20 | "Application-Name": 'mjolnir.auth.server', 21 | "Implementation-Version": packageConf.version, 22 | "Application-Owner": config.get('serverOwner') 23 | }); 24 | } 25 | 26 | exports.authenticate = authenticate; 27 | function authenticate(request, response) { 28 | logger.log("Authentication request, user: " + request.body.username); 29 | 30 | userManager.authenticate(request.body.username, request.body.password, request.body.clientToken) 31 | .then(function (data) { 32 | logger.log(" Success"); 33 | var jsonResponse = { 34 | "accessToken": data.accessToken, 35 | "clientToken": data.clientToken 36 | }; 37 | if (request.body.agent) { 38 | jsonResponse.selectedProfile = { 39 | "id": data.userId, 40 | "name": data.playerName 41 | }; 42 | jsonResponse.availableProfiles = [ 43 | { 44 | "id": data.userId, 45 | "name": data.playerName 46 | } 47 | ]; 48 | } 49 | 50 | response.json(jsonResponse); 51 | }) 52 | .catch(function () { 53 | logger.log(" Bad credentials"); 54 | response.json({ 55 | "error": "ForbiddenOperationException", 56 | "errorMessage": "Invalid credentials. Invalid username or password." 57 | }); 58 | }); 59 | } 60 | 61 | exports.refresh = refresh; 62 | function refresh(request, response) { 63 | logger.log("Refresh request"); 64 | 65 | if (!request.body.accessToken) { 66 | logger.log(" Missing access token"); 67 | response.json({ 68 | "error": "IllegalArgumentException", 69 | "errorMessage": "Access Token can not be null or empty." 70 | }); 71 | return; 72 | } 73 | 74 | userManager.refreshAccessToken(request.body.accessToken, request.body.clientToken) 75 | .then(function (accessToken) { 76 | var jsonResponse; 77 | 78 | logger.log(" Token refreshed"); 79 | jsonResponse = { 80 | "accessToken": accessToken, 81 | "clientToken": request.body.clientToken 82 | }; 83 | if (request.body.selectedProfile) { 84 | jsonResponse.selectedProfile = request.body.selectedProfile; 85 | } 86 | 87 | response.json(jsonResponse); 88 | }) 89 | .catch(function () { 90 | logger.log(" Invalid token"); 91 | response.json({ 92 | "error": "ForbiddenOperationException", 93 | "errorMessage": "Invalid token." 94 | }); 95 | }); 96 | } 97 | 98 | exports.validate = validate; 99 | function validate(request, response) { 100 | logger.log("Validation request"); 101 | 102 | if (!request.body.accessToken) { 103 | logger.log(" Missing access token"); 104 | response.json({ 105 | "error": "IllegalArgumentException", 106 | "errorMessage": "Access Token can not be null or empty." 107 | }); 108 | return; 109 | } 110 | 111 | userManager.isAccessTokenAnActiveSession(request.body.accessToken) 112 | .then(function () { 113 | logger.log(" Access token is valid"); 114 | response.json({}); 115 | }) 116 | .catch(function () { 117 | logger.log(" Invalid access token"); 118 | response.json({ 119 | "error": "ForbiddenOperationException", 120 | "errorMessage": "Invalid token" 121 | }); 122 | }); 123 | } 124 | 125 | exports.signOut = signOut; 126 | function signOut(request, response) { 127 | logger.log("Logout request, user: " + request.body.username); 128 | 129 | if (!request.body.username) { 130 | logger.log(" Missing username"); 131 | response.json({ 132 | "error": "IllegalArgumentException", 133 | "errorMessage": "Access Token can not be null or empty." 134 | }); 135 | return; 136 | } 137 | 138 | userManager.signOut(request.body.username, request.body.password) 139 | .then(function () { 140 | logger.log(" Success"); 141 | response.json({}); 142 | }) 143 | .catch(function () { 144 | logger.log(" Invalid password"); 145 | response.json({ 146 | "error": "ForbiddenOperationException", 147 | "errorMessage": "Invalid credentials. Invalid username or password." 148 | }); 149 | }); 150 | } 151 | 152 | exports.invalidate = invalidate; 153 | function invalidate(request, response) { 154 | logger.log("Invalidation request"); 155 | 156 | if (request.body.accessToken) { 157 | userManager.invalidate(request.body.accessToken, request.body.clientToken) 158 | .then(function () { 159 | response.json({}); 160 | }) 161 | .catch(function () { 162 | response.json({}); 163 | }); 164 | return; 165 | } 166 | 167 | response.json({}); 168 | } 169 | 170 | 171 | // Sessionserver actions 172 | exports.sessionJoin = sessionJoin; 173 | function sessionJoin(request, response) { 174 | logger.log("Session join request"); 175 | 176 | if (!request.body.serverId) { 177 | logger.log(" Missing server id"); 178 | response.json({ 179 | "error": "IllegalArgumentException", 180 | "errorMessage": "accessToken.getServerId() can not be null or empty." 181 | }); 182 | return; 183 | } 184 | 185 | if (!request.body.accessToken) { 186 | logger.log(" Missing access token"); 187 | response.json({ 188 | "error": "IllegalArgumentException", 189 | "errorMessage": "Access Token can not be null or empty." 190 | }); 191 | return; 192 | } 193 | 194 | if (!request.body.selectedProfile) { 195 | logger.log(" Missing access token"); 196 | response.json({ 197 | "error": "IllegalArgumentException", 198 | "errorMessage": "selectedProfile can not be null." 199 | }); 200 | return; 201 | } 202 | 203 | userManager.sessionJoin(request.body.accessToken, request.body.selectedProfile, request.body.serverId) 204 | .then(function () { 205 | logger.log(" Success"); 206 | response.json({}); 207 | }) 208 | .catch(function () { 209 | logger.log(" Invalid access token"); 210 | response.json({ 211 | "error": "ForbiddenOperationException", 212 | "errorMessage": "Invalid token" 213 | }); 214 | }); 215 | } 216 | 217 | exports.sessionHasJoined = sessionHasJoined; 218 | function sessionHasJoined(request, response) { 219 | logger.log("Session has joined request"); 220 | 221 | if (!request.query.username || !request.query.serverId) { 222 | logger.log(" Invalid parameters"); 223 | response.json({}); 224 | } 225 | 226 | userManager.sessionHasJoined(request.query.username, request.query.serverId) 227 | .then(function (user) { 228 | return createFullProfileResponse(user, false); 229 | }) 230 | .then(function (jsonResponse) { 231 | logger.log(" Success"); 232 | 233 | response.json(jsonResponse); 234 | }) 235 | .catch(function () { 236 | logger.log(" Invalid parameters"); 237 | response.json({}); 238 | }); 239 | } 240 | 241 | exports.sessionUUIDToProfile = sessionUUIDToProfile; 242 | function sessionUUIDToProfile(request, response) { 243 | logger.log("UUID -> Profile request"); 244 | 245 | userManager.getUserByUuid(request.params.uuid) 246 | .then(function (user) { 247 | return createFullProfileResponse(user, request.query.unsigned); 248 | }) 249 | .then(function (jsonResponse) { 250 | logger.log(" Success"); 251 | 252 | response.json(jsonResponse); 253 | }) 254 | .catch(function () { 255 | logger.log(" UUID doesn't exist"); 256 | response.status(204).json({}); 257 | }); 258 | } 259 | 260 | exports.apiNameToUUID = apiNameToUUID; 261 | function apiNameToUUID(request, response) { 262 | logger.log("Name -> UUID request with name: " + request.params.name); 263 | 264 | if (!request.params.name) { 265 | logger.log(" Missing name"); 266 | response.status(400).json({ 267 | "error": "IllegalArgumentException", 268 | "errorMessage": "Name is missing." 269 | }); 270 | return; 271 | } 272 | 273 | userManager.nameToUUID(request.params.name) 274 | .then(function (userId) { 275 | logger.log(" User found"); 276 | response.json({ 277 | "id": userId, 278 | "name": request.params.name 279 | }); 280 | }) 281 | .catch(function () { 282 | logger.log(" Name doesn't exist"); 283 | response.status(204).json({}); 284 | }); 285 | } 286 | 287 | exports.apiUUIDToName = apiUUIDToName; 288 | function apiUUIDToName(request, response) { 289 | logger.log("UUID -> Name history request"); 290 | 291 | userManager.getUserByUuid(request.params.uuid) 292 | .then(function (user) { 293 | logger.log(" UUID found"); 294 | response.json([{ 295 | "name": user.playerName 296 | }]); 297 | }) 298 | .catch(function () { 299 | logger.log(" UUID doesn't exist"); 300 | response.status(204).json({}); 301 | }); 302 | } 303 | 304 | exports.apiPlayernamesToUUID = apiPlayernamesToUUID; 305 | function apiPlayernamesToUUID(request, response) { 306 | logger.log("Bulk name -> UUID request"); 307 | 308 | if (typeof request.body !== 'object') { 309 | logger.log(" Invalid list"); 310 | response.json({ 311 | "error": "IllegalArgumentException", 312 | "errorMessage": "Invalid payload." 313 | }); 314 | return; 315 | } 316 | 317 | if (Object.keys(request.body).length > 100) { 318 | logger.log(" Too many names"); 319 | response.json({ 320 | "error": "IllegalArgumentException", 321 | "errorMessage": "Too many names." 322 | }); 323 | return; 324 | } 325 | 326 | var queries = []; 327 | for (var i in request.body) { 328 | if (typeof request.body[i] !== 'string' || !request.body[i]) { 329 | response.json({ 330 | "error": "IllegalArgumentException", 331 | "errorMessage": "Empty username." 332 | }); 333 | } 334 | 335 | var query = userManager.nameToUUID(request.body[i]) 336 | .then(function (userId) { 337 | logger.log(" User found"); 338 | 339 | return userManager.getUserByUuid(userId) 340 | .then(function (user) { 341 | return { 342 | "id": userId, 343 | "name": user.playerName 344 | }; 345 | }); 346 | }) 347 | .catch(function () { 348 | logger.log(" User not found"); 349 | }); 350 | queries.push(query); 351 | } 352 | 353 | Promise.all(queries) 354 | .then(function (results) { 355 | logger.log(" Users are fetched"); 356 | response.json(results); 357 | }) 358 | .catch(function () { 359 | response.json([]); 360 | }); 361 | } 362 | 363 | 364 | function createFullProfileResponse(user, unsigned) { 365 | return userManager.getUserId(user.username) 366 | .then(function (profileId) { 367 | var value = { 368 | "timestamp": moment().unix(), 369 | "profileId": profileId, 370 | "profileName": user.playerName, 371 | "isPublic": true, 372 | "textures": { 373 | "SKIN": { 374 | "url": "https://" + config.get("serverDomain") + "/images/skin/" + (user.skinUrl ? user.skinUrl : "steve.png") 375 | } 376 | } 377 | }; 378 | if (user.capeUrl) { 379 | value["textures"]["CAPE"] = { 380 | "url": "https://" + config.get("serverDomain") + "/images/cape/" + user.capeUrl 381 | } 382 | } 383 | 384 | value = toBase64(value); 385 | 386 | var response = { 387 | "id": profileId, 388 | "name": user.playerName, 389 | "properties": [ 390 | { 391 | "name": "textures", 392 | "value": value 393 | } 394 | ] 395 | }; 396 | if (!unsigned) { 397 | response["properties"][0]["signature"] = generateSignature(value); 398 | } 399 | 400 | return response; 401 | }); 402 | } 403 | 404 | function toBase64(obj) { 405 | var buffer = new Buffer(JSON.stringify(obj)); 406 | return buffer.toString('base64'); 407 | } 408 | 409 | function generateSignature(value) { 410 | var key = keychain.get('sessionserver.key'); 411 | var signature = crypto.createSign('sha1WithRSAEncryption'); 412 | 413 | signature.update(value); 414 | return signature.sign(key, 'base64'); 415 | } 416 | -------------------------------------------------------------------------------- /lib/cli/userHelper.js: -------------------------------------------------------------------------------- 1 | var promptly = require('promptly'); 2 | var Table = require('cli-table'); 3 | 4 | exports.getUser = getUser; 5 | function getUser(driver) { 6 | console.log('You may find a user by Username or Player name:'); 7 | return askOptField('Username') 8 | .then(function (username) { 9 | if (username) { 10 | return driver.findUserBy('username', username); 11 | } 12 | 13 | return askOptField('Player name') 14 | .then(function (playerName) { 15 | if (!playerName) { 16 | throw Error('Cancelled'); 17 | } 18 | 19 | return driver.findUserBy('playerName', playerName); 20 | }); 21 | }); 22 | } 23 | 24 | exports.dumpUser = dumpUser; 25 | function dumpUser(user) { 26 | var table = new Table({}); 27 | table.push( 28 | {'Username': user.username}, 29 | {'Password': user.password ? '********' : 'DISABLED'}, 30 | {'Player name': user.playerName}, 31 | {'Skin': user.skinUrl ? user.skinUrl : 'NOT SET'}, 32 | {'Cape': user.capeUrl ? user.capeUrl : 'NOT SET'} 33 | ); 34 | console.log(table.toString()); 35 | } 36 | 37 | exports.askOptField = askOptField; 38 | function askOptField(field) { 39 | return new Promise(function (resolve, reject) { 40 | promptly.prompt(field + ': ', {default: -1}, function (err, value) { 41 | if (value !== -1) { 42 | resolve(value); 43 | } 44 | 45 | resolve(null); 46 | }); 47 | }); 48 | } 49 | 50 | exports.askReqField = askReqField; 51 | function askReqField(field) { 52 | return promptly.prompt(field + ': '); 53 | } 54 | 55 | exports.askPassword = askPassword; 56 | function askPassword(message, optional) { 57 | return promptly.password(message + ': ', {default: optional ? '' : null}); 58 | } 59 | 60 | exports.askConfirm = askConfirm; 61 | function askConfirm(question) { 62 | return new Promise(function (resolve, reject) { 63 | promptly.confirm(question, function (err, value) { 64 | if (value) { 65 | return resolve() 66 | } 67 | 68 | reject(); 69 | }); 70 | }); 71 | } 72 | -------------------------------------------------------------------------------- /lib/driver/config.js: -------------------------------------------------------------------------------- 1 | var config = require('config'); 2 | 3 | var users = config.get('users'); 4 | 5 | exports.findUserBy = findUserBy; 6 | function findUserBy(field, value) { 7 | return new Promise(function (resolve, reject) { 8 | for (var i in users) { 9 | if (caseInsensitiveEqual(users[i][field], value)) { 10 | return resolve(users[i]); 11 | } 12 | } 13 | 14 | return resolve(null); 15 | }); 16 | } 17 | 18 | exports.saveUser = saveUser; 19 | function saveUser(user) { 20 | return new Promise(function (resolve, reject) { 21 | for (var i in users) { 22 | if (users[i].id === user.id) { 23 | users[i] = user; 24 | return resolve(user); 25 | } 26 | } 27 | 28 | reject('User not found!'); 29 | }); 30 | } 31 | 32 | exports.addUser = addUser; 33 | function addUser() { 34 | throw new Error('Invalid operation!'); 35 | } 36 | 37 | exports.removeUser = removeUser; 38 | function removeUser() { 39 | throw new Error('Invalid operation!'); 40 | } 41 | 42 | exports.close = close; 43 | function close() { 44 | // noop 45 | } 46 | 47 | 48 | function caseInsensitiveEqual(left, right) { 49 | return !!(left === right || typeof left === 'string' && typeof right === 'string' && left.toLowerCase() === right.toLowerCase()); 50 | } 51 | 52 | 53 | // Validating UUID-s 54 | var uuid = new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"); 55 | for (var i in users) { 56 | if (!uuid.test(users[i].id)) { 57 | console.log('The following UUID is not valid in the config file: ', users[i].id); 58 | process.exit(1); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/driver/mongodb.js: -------------------------------------------------------------------------------- 1 | var config = require('config'); 2 | var MongoClient = require('mongodb').MongoClient; 3 | var dbconn, users; 4 | 5 | MongoClient.connect(config.get('mongodb.connectionStr'), function (err, db) { 6 | if (err) { 7 | console.log(err); 8 | process.exit(1); 9 | } 10 | 11 | dbconn = db; 12 | users = db.collection('user'); 13 | }); 14 | 15 | exports.findUserBy = findUserBy; 16 | function findUserBy(field, value) { 17 | var search = {}; 18 | 19 | if (field === 'playerName') { 20 | field = 'playerNameIndex'; 21 | value = value.toLowerCase(); 22 | } 23 | 24 | search[field] = value; 25 | return users.find(search).limit(1).next(); 26 | } 27 | 28 | exports.saveUser = saveUser; 29 | function saveUser(user) { 30 | return users.replaceOne({_id: user._id}, user) 31 | .then(function () { 32 | return user; 33 | }); 34 | } 35 | 36 | exports.addUser = addUser; 37 | function addUser(user) { 38 | return users.insertOne(user); 39 | } 40 | 41 | exports.removeUser = removeUser; 42 | function removeUser(user) { 43 | return users.deleteOne(user); 44 | } 45 | 46 | exports.close = close; 47 | function close() { 48 | dbconn.close(); 49 | } 50 | -------------------------------------------------------------------------------- /lib/keychain.js: -------------------------------------------------------------------------------- 1 | var keys = {}; 2 | 3 | exports.store = store; 4 | function store(id, key) { 5 | keys[id] = key; 6 | } 7 | 8 | exports.get = get; 9 | function get(id) { 10 | return keys[id]; 11 | } -------------------------------------------------------------------------------- /lib/logger.js: -------------------------------------------------------------------------------- 1 | var config = require('config'); 2 | var moment = require('moment'); 3 | 4 | exports.log = log; 5 | 6 | function log(message) { 7 | console.log(moment().format(config.get('timestampFormat')) + message); 8 | } 9 | -------------------------------------------------------------------------------- /lib/userManager.js: -------------------------------------------------------------------------------- 1 | var config = require('config'); 2 | var crypto = require('crypto'); 3 | var moment = require('moment'); 4 | 5 | var drivers = []; 6 | 7 | config.get('drivers').forEach(function (driver) { 8 | drivers.push(require('./driver/' + driver)); 9 | }); 10 | 11 | 12 | exports.authenticate = authenticate; 13 | function authenticate(username, password, token) { 14 | return findUser(username) 15 | .then(function (result) { 16 | if (password && result.user.password === crypto.createHash(config.get('hashAlgorithm')).update(password).digest('hex')) { 17 | result.user.lastLogin = new Date(); 18 | result.user.accessToken = makeAccessToken(result.user.username); 19 | result.user.clientToken = token ? token : makeClientToken(result.user.username); 20 | return result.driver.saveUser(result.user); 21 | } 22 | 23 | throw new Error('Authentication is unsuccessful.'); 24 | }) 25 | .then(function (user) { 26 | return { 27 | accessToken: user.accessToken, 28 | clientToken: user.clientToken, 29 | userId: createIdFromUUID(user.id), 30 | playerName: user.playerName 31 | } 32 | }); 33 | } 34 | 35 | exports.getUserId = getUserId; 36 | function getUserId(username) { 37 | return findUser(username) 38 | .then(function (result) { 39 | return createIdFromUUID(result.user.id); 40 | }); 41 | } 42 | 43 | exports.refreshAccessToken = refreshAccessToken; 44 | function refreshAccessToken(accessToken, clientToken) { 45 | return findUser(clientToken, 'clientToken') 46 | .then(function (result) { 47 | if (result.user.accessToken === accessToken) { 48 | result.user.accessToken = makeAccessToken(result.user.username); 49 | result.user.lastLogin = new Date(); 50 | return result.driver.saveUser(result.user) 51 | .then(function () { 52 | return result.user.accessToken; 53 | }); 54 | } 55 | 56 | throw new Error('Access token refresh was unsuccessful.'); 57 | }); 58 | } 59 | 60 | exports.isAccessTokenAnActiveSession = isAccessTokenAnActiveSession; 61 | function isAccessTokenAnActiveSession(accessToken) { 62 | return findUser(accessToken, 'accessToken') 63 | .then(function (result) { 64 | if (moment().subtract(2, 'hours').isBefore(result.user.lastLogin)) { 65 | return; 66 | } 67 | 68 | throw new Error('Session inactive.'); 69 | }); 70 | } 71 | 72 | exports.signOut = signOut; 73 | function signOut(username, password) { 74 | return findUser(username) 75 | .then(function (result) { 76 | if (password && result.user.password === crypto.createHash(config.get('hashAlgorithm')).update(password).digest("hex")) { 77 | result.user.accessToken = undefined; 78 | return result.driver.saveUser(result.user); 79 | } 80 | 81 | throw new Error('Logging out was unsuccessful.'); 82 | }); 83 | } 84 | 85 | exports.invalidate = invalidate; 86 | function invalidate(accessToken, clientToken) { 87 | return findUser(accessToken, 'accessToken') 88 | .then(function (result) { 89 | if (!clientToken || result.user.clientToken === clientToken) { 90 | result.user.accessToken = undefined; 91 | return result.driver.saveUser(result.user); 92 | } 93 | }); 94 | } 95 | 96 | exports.sessionJoin = sessionJoin; 97 | function sessionJoin(accessToken, selectedProfile, serverId) { 98 | return findUser(accessToken, 'accessToken') 99 | .then(function (result) { 100 | if (selectedProfile !== createIdFromUUID(result.user.id)) { 101 | throw new Error('Invalid selected profile.'); 102 | } 103 | 104 | result.user.serverId = serverId; 105 | return result.driver.saveUser(result.user); 106 | }); 107 | } 108 | 109 | exports.sessionHasJoined = sessionHasJoined; 110 | function sessionHasJoined(playername, serverId) { 111 | return findUser(playername, 'playerName') 112 | .then(function (result) { 113 | if (serverId === result.user.serverId) { 114 | return result.user; 115 | } 116 | 117 | throw new Error('ServerId mismatch.'); 118 | }); 119 | } 120 | 121 | exports.nameToUUID = nameToUUID; 122 | function nameToUUID(playername) { 123 | return findUser(playername, 'playerName') 124 | .then(function (result) { 125 | return createIdFromUUID(result.user.id); 126 | }); 127 | } 128 | 129 | exports.getUserByUuid = getUserByUuid; 130 | function getUserByUuid(uuid) { 131 | return findUser(createUUIDFromId(uuid), 'id') 132 | .then(function (result) { 133 | return result.user; 134 | }); 135 | } 136 | 137 | 138 | function findUser(value, field) { 139 | if (!value) { 140 | return new Promise(function (resolve, reject) { 141 | resolve(null); 142 | }); 143 | } 144 | 145 | if (!field) { 146 | field = 'username'; 147 | } 148 | 149 | return findUserInDriver(field, value, 0); 150 | } 151 | 152 | function findUserInDriver(field, value, driverId) { 153 | return drivers[driverId].findUserBy(field, value) 154 | .then(function (user) { 155 | if (user) { 156 | return { 157 | user: user, 158 | driver: drivers[driverId] 159 | }; 160 | } 161 | 162 | if (drivers.length === driverId + 1) { 163 | throw new Error('Value not found in any of the drivers!'); 164 | } 165 | 166 | return findUserInDriver(field, value, driverId + 1); 167 | }); 168 | } 169 | 170 | function makeAccessToken(username) { 171 | return crypto.createHash('md5').update(username + 'ACCESS' + new Date().getTime() + config.get('secret')).digest('hex'); 172 | } 173 | 174 | function makeClientToken(username) { 175 | return crypto.createHash('md5').update(username + 'CLIENT' + new Date().getTime() + config.get('secret')).digest('hex'); 176 | } 177 | 178 | function createIdFromUUID(uuid) { 179 | return uuid.replace(/-/g, ''); 180 | } 181 | 182 | function createUUIDFromId(id) { 183 | return id.slice(0, 8) + '-' + id.slice(8, 12) + '-' + id.slice(12, 16) + '-' + id.slice(16, 20) + '-' + id.slice(20); 184 | } 185 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mjolnir-authentication-server", 3 | "version": "1.0.0", 4 | "description": "Mjolnir Authentication - an open source alternative to Yggdrasil Authentication", 5 | "homepage": "https://github.com/rutkai/Mjolnir-Authentication-Server", 6 | "main": "app.js", 7 | "scripts": { 8 | "test": "jasmine-node test", 9 | "test-mongodb": "mongo test --eval \"db.dropDatabase()\" && mongofixtures test fixtures && jasmine-node test || true", 10 | "start": "node app.js" 11 | }, 12 | "keywords": [ 13 | "mjolnir", 14 | "yggdrasil" 15 | ], 16 | "author": "András Rutkai (http://rutkai.com/)", 17 | "license": "MIT", 18 | "dependencies": { 19 | "body-parser": "~1.18.1", 20 | "cli-table": "^0.3.1", 21 | "config": "~1.30.0", 22 | "express": "~4.16.0", 23 | "moment": "~2.22.0", 24 | "mongodb": "~2.0.49", 25 | "node-uuid": "^1.4.8", 26 | "pem": "^1.12.5", 27 | "promptly": "^2.2.0", 28 | "yargs": "~3.15.0" 29 | }, 30 | "devDependencies": { 31 | "jasmine-node": "^1.15.0", 32 | "frisby": "~0.8.3" 33 | }, 34 | "repository": { 35 | "type": "git", 36 | "url": "https://github.com/riskawarrior/Mjolnir-Authentication-Server" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /patcher/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Build helper for compiling 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /patcher/dist/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Ant-Version: Apache Ant 1.9.4 3 | Created-By: 1.7.0_60-b19 (Oracle Corporation) 4 | Main-Class: Main 5 | 6 | -------------------------------------------------------------------------------- /patcher/dist/patcher.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/dist/patcher.exe -------------------------------------------------------------------------------- /patcher/dist/patcher.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/dist/patcher.jar -------------------------------------------------------------------------------- /patcher/launch4j.config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | console 5 | dist/patcher.jar 6 | dist/patcher.exe 7 | 8 | 9 | . 10 | normal 11 | http://java.com/download 12 | 13 | false 14 | false 15 | 16 | 17 | 18 | 19 | false 20 | false 21 | 1.7.0 22 | 23 | preferJre 24 | 64/32 25 | 26 | 27 | -------------------------------------------------------------------------------- /patcher/launch4j/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Launch4j (http://launch4j.sourceforge.net/) 2 | Cross-platform Java application wrapper for creating Windows native executables. 3 | 4 | Copyright (c) 2004, 2015 Grzegorz Kowal 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name of the copyright holder nor the names of its contributors 18 | may be used to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /patcher/launch4j/bin/COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 19yy 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) 19yy name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | -------------------------------------------------------------------------------- /patcher/launch4j/bin/ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/bin/ld -------------------------------------------------------------------------------- /patcher/launch4j/bin/windres: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/bin/windres -------------------------------------------------------------------------------- /patcher/launch4j/head/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Launch4j (http://launch4j.sourceforge.net/) 2 | Cross-platform Java application wrapper for creating Windows native executables. 3 | 4 | Copyright (c) 2004, 2015 Grzegorz Kowal 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | Except as contained in this notice, the name(s) of the above copyright holders 17 | shall not be used in advertising or otherwise to promote the sale, use or other 18 | dealings in this Software without prior written authorization. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. -------------------------------------------------------------------------------- /patcher/launch4j/head/consolehead.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/head/consolehead.o -------------------------------------------------------------------------------- /patcher/launch4j/head/guihead.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/head/guihead.o -------------------------------------------------------------------------------- /patcher/launch4j/head/head.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/head/head.o -------------------------------------------------------------------------------- /patcher/launch4j/launch4j.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/launch4j.jar -------------------------------------------------------------------------------- /patcher/launch4j/launch4j.jfpr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/launch4j.jfpr -------------------------------------------------------------------------------- /patcher/launch4j/lib/JGoodies.Forms.LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | The BSD License for the JGoodies Forms 3 | ====================================== 4 | 5 | Copyright (c) 2002-2014 JGoodies Software GmbH. All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | o Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | o Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | o Neither the name of JGoodies Software GmbH nor the names of 18 | its contributors may be used to endorse or promote products derived 19 | from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /patcher/launch4j/lib/JGoodies.Looks.LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | The BSD License for the JGoodies Looks 3 | ====================================== 4 | 5 | Copyright (c) 2001-2014 JGoodies Software GmbH. All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | o Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | o Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | o Neither the name of JGoodies Software GmbH nor the names of 18 | its contributors may be used to endorse or promote products derived 19 | from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /patcher/launch4j/lib/XStream.LICENSE.txt: -------------------------------------------------------------------------------- 1 | (BSD Style License) 2 | 3 | Copyright (c) 2003-2004, Joe Walnes 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | Redistributions of source code must retain the above copyright notice, this list of 10 | conditions and the following disclaimer. Redistributions in binary form must reproduce 11 | the above copyright notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution. 13 | 14 | Neither the name of XStream nor the names of its contributors may be used to endorse 15 | or promote products derived from this software without specific prior written 16 | permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 26 | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 27 | DAMAGE. 28 | -------------------------------------------------------------------------------- /patcher/launch4j/lib/ant.LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /patcher/launch4j/lib/ant.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/lib/ant.jar -------------------------------------------------------------------------------- /patcher/launch4j/lib/commons-beanutils.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/lib/commons-beanutils.jar -------------------------------------------------------------------------------- /patcher/launch4j/lib/commons-logging.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/lib/commons-logging.jar -------------------------------------------------------------------------------- /patcher/launch4j/lib/commons.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | ============================================================================ 4 | The Apache Software License, Version 1.1 5 | ============================================================================ 6 | 7 | Copyright (C) @year@ The Apache Software Foundation. All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without modifica- 10 | tion, are permitted provided that the following conditions are met: 11 | 12 | 1. Redistributions of source code must retain the above copyright notice, 13 | this list of conditions and the following disclaimer. 14 | 15 | 2. Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | 19 | 3. The end-user documentation included with the redistribution, if any, must 20 | include the following acknowledgment: "This product includes software 21 | developed by the Apache Software Foundation (http://www.apache.org/)." 22 | Alternately, this acknowledgment may appear in the software itself, if 23 | and wherever such third-party acknowledgments normally appear. 24 | 25 | 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be 26 | used to endorse or promote products derived from this software without 27 | prior written permission. For written permission, please contact 28 | apache@apache.org. 29 | 30 | 5. Products derived from this software may not be called "Apache", nor may 31 | "Apache" appear in their name, without prior written permission of the 32 | Apache Software Foundation. 33 | 34 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 35 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 36 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 37 | APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 38 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 39 | DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 40 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 41 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 42 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 43 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 | 45 | This software consists of voluntary contributions made by many individuals 46 | on behalf of the Apache Software Foundation and was originally created by 47 | Stefano Mazzocchi . For more information on the Apache 48 | Software Foundation, please see . 49 | 50 | */ 51 | -------------------------------------------------------------------------------- /patcher/launch4j/lib/formsrt.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/lib/formsrt.jar -------------------------------------------------------------------------------- /patcher/launch4j/lib/foxtrot.LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002, Simone Bordet & Marco Cravero 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted 5 | provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | - Neither the name of Foxtrot nor the names of the contributors may be used 15 | to endorse or promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 19 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 20 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS 21 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 23 | OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 25 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /patcher/launch4j/lib/foxtrot.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/lib/foxtrot.jar -------------------------------------------------------------------------------- /patcher/launch4j/lib/jgoodies-common.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/lib/jgoodies-common.jar -------------------------------------------------------------------------------- /patcher/launch4j/lib/jgoodies-forms.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/lib/jgoodies-forms.jar -------------------------------------------------------------------------------- /patcher/launch4j/lib/jgoodies-looks.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/lib/jgoodies-looks.jar -------------------------------------------------------------------------------- /patcher/launch4j/lib/xstream.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/lib/xstream.jar -------------------------------------------------------------------------------- /patcher/launch4j/sign4j/README.txt: -------------------------------------------------------------------------------- 1 | sign4j version 3.0 2 | ------------------ 3 | 4 | sign4j is a very simple utility to digitally sign executables containing an appended jar file, like those created by launch4j. 5 | 6 | It works by first signing a temporary file to detect the size of the applied signature, and by then adding that size to a counter in the ZIP_END_HEADER of the embedded jar, so as to pretend that the signature is a comment belonging to it. That way the jar remains formally correct, and java accepts it. 7 | 8 | This manipulation must be done atomically with the signing process, because doing it before would invalidate the jar file, while doing it later would break the signature. That's why the whole command line of your signing tool must be passed to sign4j, which will do the job. 9 | 10 | Any signing tool can be used, as long as the name of the output file can be recognized among its parameters. This is currently done by either using an -out option if present, or taking the last filename with an exe suffix after all supplied options. 11 | 12 | If the involved tool is able to remove a previous signature before adding the new one (as is normally the case) the initial test can be performed on the target executable itself, avoiding the creation of a temporary file. You can use the option --onthespot to signal that to sign4j. 13 | 14 | The option --strict can be used to suppress the use of double quotes around parameters that strictly don't need them. The option --verbose shows diagnostics about intermediary steps of the process. 15 | 16 | This utility can also be used to sign normal executables, but then it will remember you that the file can be signed directly. 17 | 18 | Please send comments to bramfeld@diogen.de 19 | -------------------------------------------------------------------------------- /patcher/launch4j/sign4j/sign4j.c: -------------------------------------------------------------------------------- 1 | /* 2 | sign4j.c: a simple utility to sign executables created by Launch4j 3 | 4 | Copyright (c) 2012 Servoy 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | 3. Neither the name of the copyright holder nor the names of its contributors 18 | may be used to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #include 34 | #include 35 | #include 36 | #ifdef _WIN32 37 | #include 38 | #include 39 | #else 40 | #include 41 | #include 42 | #endif 43 | #include 44 | #include 45 | 46 | #define ZIP_END_HEADER "\x50\x4B\x05\x06" 47 | #define END_HEADER_SIZE 22 48 | #define MAX_COMMENT_SIZE 0xFFFF 49 | #define SWAP_BLOCK_SIZE (4 * 1024 * 1024) 50 | #define TEST_FILE_NAME "sign4j_temporary.exe" 51 | #define SIGN4J_VERSION "3.0" 52 | 53 | #ifndef _WIN32 54 | #define O_BINARY 0 55 | #define _O_SHORT_LIVED 0 56 | #define _S_IREAD S_IREAD 57 | #define _S_IWRITE S_IWRITE 58 | #define stricmp strcasecmp 59 | #endif 60 | 61 | typedef unsigned char byte; 62 | 63 | char command[4096]; 64 | byte* image = 0; 65 | 66 | void usage (void); 67 | void quit (int rsn); 68 | void clear (void); 69 | 70 | int main (int argc, char* argv[]) 71 | { 72 | char bfr[2]; 73 | char* inf; 74 | char* outf; 75 | char* trg; 76 | byte* lmt; 77 | long lng, ext, off, blck, sgm; 78 | int fd, td; 79 | int fnd, spt, unq, vrb, qts, cmn; 80 | int i, j, n; 81 | byte* p; 82 | 83 | inf = outf = 0, fnd = spt = unq = vrb = 0; 84 | for (i = 1; i < argc && argv[i][0] == '-'; i++) 85 | if (! strcmp (argv[i], "--onthespot")) 86 | spt = 1; 87 | else if (! strcmp (argv[i], "--strict")) 88 | unq = 1; 89 | else if (! strcmp (argv[i], "--verbose")) 90 | vrb = 1; 91 | j = i; 92 | for (i = j + 1; i < argc; i++) 93 | if (! strcmp (argv[i], "-in") && i < argc - 1) 94 | inf = argv[++i], fnd = 1; 95 | else if (! strcmp (argv[i], "-out") && i < argc - 1) 96 | outf = argv[++i], fnd = 1; 97 | else if (argv[i][0] == '-' || (argv[i][0] == '/' && strlen (argv[i]) < 5)) 98 | (! fnd ? (inf = outf = 0) : 0); 99 | else if (! fnd && (n = strlen (argv[i])) > 4 && ! stricmp (argv[i] + n - 4, ".exe")) 100 | inf = outf = argv[i]; 101 | if (! inf || ! outf) 102 | usage (); 103 | atexit (clear); 104 | 105 | if ((fd = open (inf, O_RDONLY | O_BINARY)) < 0) 106 | quit (1); 107 | if ((lng = lseek (fd, 0, SEEK_END)) < 0) 108 | quit (2); 109 | blck = (lng > SWAP_BLOCK_SIZE ? SWAP_BLOCK_SIZE : lng); 110 | if (! (image = (byte*) malloc (blck))) 111 | quit (4); 112 | sgm = (blck > END_HEADER_SIZE + MAX_COMMENT_SIZE ? END_HEADER_SIZE + MAX_COMMENT_SIZE : blck); 113 | if (lseek (fd, -sgm, SEEK_END) < 0 || read (fd, image, sgm) != sgm) 114 | quit (2); 115 | for (p = image + sgm - END_HEADER_SIZE; p > image; p--) 116 | if (! memcmp (p, ZIP_END_HEADER, 4) && ((p[END_HEADER_SIZE - 1] << 8) | p[END_HEADER_SIZE - 2]) == (image + sgm) - (p + END_HEADER_SIZE)) 117 | break; 118 | if (p > image) 119 | { 120 | off = lng - ((image + sgm) - (p + END_HEADER_SIZE - 2)); 121 | cmn = (p[END_HEADER_SIZE - 1] << 8) | p[END_HEADER_SIZE - 2]; 122 | 123 | if (! spt && (inf == outf || ! strcmp (inf, outf))) 124 | { 125 | printf ("Making temporary file\n"); 126 | if ((td = open (TEST_FILE_NAME, O_CREAT | _O_SHORT_LIVED | O_WRONLY | O_BINARY, _S_IREAD | _S_IWRITE)) < 0) 127 | quit (5); 128 | if (lseek (fd, 0, SEEK_SET) < 0) 129 | quit (2); 130 | for (ext = lng; ext > 0; ext -= blck) 131 | { 132 | sgm = (ext > blck ? blck : ext); 133 | if (read (fd, image, sgm) != sgm || write (td, image, sgm) != sgm) 134 | quit (6); 135 | } 136 | close (td); 137 | trg = TEST_FILE_NAME; 138 | } 139 | else 140 | trg = outf; 141 | close (fd); 142 | 143 | #ifdef _WIN32 144 | strcpy (command, "\" "); 145 | #else 146 | strcpy (command, ""); 147 | #endif 148 | 149 | for (i = j; i < argc; i++) 150 | { 151 | p = (argv[i] == outf ? trg : argv[i]); 152 | qts = (! unq || strchr (p, 32)); 153 | if (qts) 154 | strcat (command, "\""); 155 | strcat (command, p); 156 | if (qts) 157 | strcat (command, "\""); 158 | strcat (command, " "); 159 | } 160 | 161 | #ifdef _WIN32 162 | strcat (command, "\""); 163 | #endif 164 | 165 | if (! vrb) 166 | #ifdef _WIN32 167 | strcat (command, " > NUL"); 168 | #else 169 | strcat (command, " > /dev/null"); 170 | #endif 171 | 172 | system (command); 173 | 174 | if ((td = open (trg, O_RDONLY | O_BINARY)) < 0) 175 | quit (7); 176 | if ((ext = lseek (td, 0, SEEK_END)) < 0) 177 | quit (7); 178 | close (td); 179 | if ((cmn += ext - lng) < 0 || cmn > MAX_COMMENT_SIZE) 180 | quit (8); 181 | 182 | if ((fd = open (inf, O_WRONLY | O_BINARY)) < 0) 183 | quit (1); 184 | if (lseek (fd, off, SEEK_SET) < 0) 185 | quit (3); 186 | bfr[0] = cmn & 0xFF; 187 | bfr[1] = (cmn >> 8) & 0xFF; 188 | if (write (fd, bfr, 2) != 2) 189 | quit (3); 190 | close (fd); 191 | } 192 | else 193 | { 194 | close (fd); 195 | printf ("You don't need sign4j to sign this file\n"); 196 | } 197 | 198 | #ifdef _WIN32 199 | strcpy (command, "\" "); 200 | #else 201 | strcpy (command, ""); 202 | #endif 203 | 204 | for (i = j; i < argc; i++) 205 | { 206 | p = argv[i]; 207 | qts = (! unq || strchr (p, 32)); 208 | if (qts) 209 | strcat (command, "\""); 210 | strcat (command, p); 211 | if (qts) 212 | strcat (command, "\""); 213 | strcat (command, " "); 214 | } 215 | 216 | #ifdef _WIN32 217 | strcat (command, "\""); 218 | #endif 219 | 220 | return system (command); 221 | } 222 | 223 | 224 | void usage () 225 | { 226 | printf ("\nThis is sign4j version " SIGN4J_VERSION "\n\n"); 227 | printf ("Usage: sign4j [options] \n\n"); 228 | printf (" * options:\n"); 229 | printf (" --onthespot avoid the creation of a temporary file (your tool must be able to sign twice)\n"); 230 | printf (" --strict supress the use of double quotes around parameters that strictly don't need them\n"); 231 | printf (" --verbose show diagnostics about intermediary steps of the process\n"); 232 | printf (" * arguments must specify verbatim the command line for your signing tool\n"); 233 | printf (" * only one file can be signed on each invocation\n"); 234 | exit (-1); 235 | } 236 | 237 | void quit (int rsn) 238 | { 239 | switch (rsn) 240 | { 241 | case 1: puts ("Could not open file\n"); break; 242 | case 2: puts ("Could not read file\n"); break; 243 | case 3: puts ("Could not write file\n"); break; 244 | case 4: puts ("Not enough memory\n"); break; 245 | case 5: puts ("Could not open temporary\n"); break; 246 | case 6: puts ("Could not write temporary\n"); break; 247 | case 7: puts ("Could not read target\n"); break; 248 | case 8: puts ("Unsupported operation\n"); break; 249 | } 250 | exit (-1); 251 | } 252 | 253 | void clear () 254 | { 255 | if (access (TEST_FILE_NAME, 0) == 0) 256 | remove (TEST_FILE_NAME); 257 | if (image) 258 | free (image); 259 | } 260 | -------------------------------------------------------------------------------- /patcher/launch4j/w32api/MinGW.LICENSE.txt: -------------------------------------------------------------------------------- 1 | MinGW - Licensing Terms 2 | 3 | Various pieces distributed with MinGW come with its own copyright and license: 4 | 5 | Basic MinGW runtime 6 | MinGW base runtime package is uncopyrighted and placed in the public domain. 7 | This basically means that you can do what you want with the code. 8 | 9 | w32api 10 | You are free to use, modify and copy this package. 11 | No restrictions are imposed on programs or object files compiled with this library. 12 | You may not restrict the the usage of this library. 13 | You may distribute this library as part of another package or as a modified package 14 | if and only if you do not restrict the usage of the portions consisting 15 | of this (optionally modified) library. 16 | If distributed as a modified package then this file must be included. 17 | 18 | This library is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty 20 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 | 22 | MinGW profiling code 23 | MinGW profiling code is distributed under the GNU General Public License. 24 | 25 | The development tools such as GCC, GDB, GNU Make, etc all covered by GNU General Public License. 26 | -------------------------------------------------------------------------------- /patcher/launch4j/w32api/crt2.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/w32api/crt2.o -------------------------------------------------------------------------------- /patcher/launch4j/w32api/libadvapi32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/w32api/libadvapi32.a -------------------------------------------------------------------------------- /patcher/launch4j/w32api/libgcc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/w32api/libgcc.a -------------------------------------------------------------------------------- /patcher/launch4j/w32api/libkernel32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/w32api/libkernel32.a -------------------------------------------------------------------------------- /patcher/launch4j/w32api/libmingw32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/w32api/libmingw32.a -------------------------------------------------------------------------------- /patcher/launch4j/w32api/libmsvcrt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/w32api/libmsvcrt.a -------------------------------------------------------------------------------- /patcher/launch4j/w32api/libshell32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/w32api/libshell32.a -------------------------------------------------------------------------------- /patcher/launch4j/w32api/libuser32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/launch4j/w32api/libuser32.a -------------------------------------------------------------------------------- /patcher/lib/gson-2.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/lib/gson-2.4.jar -------------------------------------------------------------------------------- /patcher/lib/lzma-4.63-jio-0.93.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/patcher/lib/lzma-4.63-jio-0.93.jar -------------------------------------------------------------------------------- /patcher/src/Main.java: -------------------------------------------------------------------------------- 1 | import commands.*; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | import java.io.PrintStream; 6 | import java.net.UnknownHostException; 7 | import java.util.prefs.Preferences; 8 | 9 | /** 10 | * Main class 11 | * 12 | * @author András Rutkai 13 | * @since 2015.08.03. 14 | */ 15 | public class Main { 16 | 17 | public static void main(String[] args) { 18 | if (args.length == 0) { 19 | printHelp(); 20 | return; 21 | } 22 | 23 | switch (args[0]) { 24 | case "patch-hosts": 25 | checkRoles(); 26 | patchHosts(); 27 | break; 28 | case "unpatch-hosts": 29 | checkRoles(); 30 | unpatchHosts(); 31 | break; 32 | case "install-certs": 33 | checkRoles(); 34 | installCerts(); 35 | break; 36 | case "patch-launcher": 37 | patchLauncher(); 38 | break; 39 | case "patch-authlib": 40 | patchAuthlib(); 41 | break; 42 | case "patch-server": 43 | patchServer(); 44 | break; 45 | default: 46 | System.out.println("No command line arguments!"); 47 | printHelp(); 48 | break; 49 | } 50 | } 51 | 52 | private static void printHelp() { 53 | System.out.println("The following commands are available:"); 54 | System.out.println(" help : prints this help"); 55 | System.out.println(" patch-hosts : patches the hosts file to use your own server"); 56 | System.out.println(" unpatch-hosts : un-patches the hosts file to use the original"); 57 | System.out.println(" install-certs : installs trusted certificates from your server server (requires patch-hosts)"); 58 | System.out.println(" patch-launcher : downloads a new client and patches it with your certificates"); 59 | System.out.println(" patch-authlib : patches the latest downloaded authlib to use your certificate"); 60 | System.out.println(" patch-server : downloads a new server and patches it with your certificates"); 61 | } 62 | 63 | private static void checkRoles() { 64 | if (!isAdmin()) { 65 | System.out.println("You'll need administrator/root access for this feature!"); 66 | System.setErr(new PrintStream(new OutputStream() { // Suppress second warning 67 | @Override 68 | public void write(int b) throws IOException { 69 | // Ignore warning 70 | } 71 | })); 72 | System.exit(100); 73 | } 74 | } 75 | 76 | private static boolean isAdmin() { 77 | Preferences prefs = Preferences.systemRoot(); 78 | PrintStream systemErr = System.err; 79 | System.setErr(new PrintStream(new OutputStream() { 80 | @Override 81 | public void write(int b) throws IOException { 82 | // Ignore warning 83 | } 84 | })); 85 | try { 86 | prefs.put("foo", "bar"); // SecurityException on Windows 87 | prefs.remove("foo"); 88 | prefs.flush(); // BackingStoreException on Linux 89 | return true; 90 | } catch (Exception e) { 91 | return false; 92 | } finally { 93 | System.setErr(systemErr); 94 | } 95 | } 96 | 97 | private static void patchHosts() { 98 | System.out.print("Please enter your server's address: "); 99 | String address = System.console().readLine().trim(); 100 | if ("".equals(address)) { 101 | System.exit(1); 102 | } 103 | 104 | HostsPatcher patcher = new HostsPatcher(); 105 | try { 106 | patcher.patch(address); 107 | } catch (UnknownHostException e) { 108 | System.out.println("Host is unknown!"); 109 | System.exit(1); 110 | } catch (IOException e) { 111 | System.out.println("Hosts file cannot be read! Try to use this script as administrator/root."); 112 | System.exit(1); 113 | } 114 | System.out.println("Hosts file has been patched!"); 115 | } 116 | 117 | private static void unpatchHosts() { 118 | HostsPatcher patcher = new HostsPatcher(); 119 | try { 120 | patcher.unpatch(); 121 | } catch (IOException e) { 122 | System.out.println("Hosts file cannot be read! Try to use this script as administrator/root."); 123 | System.exit(1); 124 | } 125 | System.out.println("Hosts file has been reverted!"); 126 | } 127 | 128 | private static void installCerts() { 129 | CertInstaller installer = new CertInstaller(); 130 | try { 131 | installer.installCerts(); 132 | } catch (Exception e) { 133 | System.out.println("Unhandled exception during certificate installation:"); 134 | e.printStackTrace(); 135 | System.exit(1); 136 | } 137 | System.out.println("Certifications from hosts file auth servers has been installed!"); 138 | } 139 | 140 | private static void patchLauncher() { 141 | System.out.print("Downloading and patching launcher..."); 142 | LauncherPatcher patcher = new LauncherPatcher(); 143 | try { 144 | patcher.savePatchedLauncher(); 145 | } catch (Exception e) { 146 | System.out.println("Unhandled exception during the process:"); 147 | e.printStackTrace(); 148 | System.exit(1); 149 | } 150 | System.out.println("done!"); 151 | } 152 | 153 | private static void patchAuthlib() { 154 | System.out.print("Patching existing authlib..."); 155 | AuthlibPatcher patcher = new AuthlibPatcher(); 156 | try { 157 | patcher.patch(); 158 | } catch (Exception e) { 159 | System.out.println("Unhandled exception during patching:"); 160 | e.printStackTrace(); 161 | System.exit(1); 162 | } 163 | System.out.println("done!"); 164 | } 165 | 166 | private static void patchServer() { 167 | try { 168 | ServerPatcher patcher = new ServerPatcher(); 169 | String version = getServerVersion(patcher); 170 | System.out.print("Downloading and patching server..."); 171 | patcher.savePatchedLauncher(version); 172 | } catch (Exception e) { 173 | System.out.println("Unhandled exception during the process:"); 174 | e.printStackTrace(); 175 | System.exit(1); 176 | } 177 | System.out.println("done!"); 178 | } 179 | 180 | private static String getServerVersion(ServerPatcher patcher) throws Exception { 181 | System.out.println("Available versions:"); 182 | System.out.println(patcher.versions().getVersions()); 183 | System.out.print("Version to download (default: " + patcher.versions().latest.release + "): "); 184 | String version = System.console().readLine().trim(); 185 | if ("".equals(version)) { 186 | version = patcher.versions().latest.release; 187 | } 188 | if (!patcher.versions().hasVersion(version)) { 189 | throw new Exception("Version is not valid!"); 190 | } 191 | return version; 192 | } 193 | 194 | } 195 | -------------------------------------------------------------------------------- /patcher/src/commands/AuthlibPatcher.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import lib.BasePatcher; 4 | import lib.VersionComparator; 5 | 6 | import java.io.*; 7 | import java.nio.file.Files; 8 | import java.nio.file.Paths; 9 | import java.nio.file.StandardCopyOption; 10 | import java.security.KeyManagementException; 11 | import java.security.KeyStoreException; 12 | import java.security.MessageDigest; 13 | import java.security.NoSuchAlgorithmException; 14 | import java.security.cert.CertificateException; 15 | import java.util.ArrayList; 16 | import java.util.Collections; 17 | import java.util.zip.ZipEntry; 18 | import java.util.zip.ZipInputStream; 19 | import java.util.zip.ZipOutputStream; 20 | 21 | public class AuthlibPatcher extends BasePatcher { 22 | 23 | public void patch() throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException { 24 | String authlibJar = getAuthlibJarPath(); 25 | patchJar(authlibJar); 26 | generateChecksum(authlibJar); 27 | } 28 | 29 | private void patchJar(String authlibJar) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException { 30 | FileInputStream in = new FileInputStream(authlibJar); 31 | savePatchedJar(in, authlibJar + ".new"); 32 | Files.move(Paths.get(authlibJar + ".new"), Paths.get(authlibJar), StandardCopyOption.REPLACE_EXISTING); 33 | } 34 | 35 | private void generateChecksum(String authlibJar) throws IOException, NoSuchAlgorithmException { 36 | byte[] rawChecksum = createSha1(new File(authlibJar)); 37 | String checksum = bytesToHex(rawChecksum); 38 | writeChecksum(authlibJar, checksum); 39 | } 40 | 41 | private String getHome() { 42 | if (System.getProperty("os.name").toLowerCase().contains("win")) { 43 | return System.getProperty("user.home") + "\\.minecraft"; 44 | } 45 | 46 | // On OSX: ~/Library/Application Support/minecraft 47 | 48 | return System.getProperty("user.home") + "/.minecraft"; 49 | } 50 | 51 | private String getAuthlibFolder() { 52 | return getHome() + File.separatorChar + "libraries" + File.separatorChar + "com" + File.separatorChar + "mojang" + File.separatorChar + "authlib"; 53 | } 54 | 55 | private String getLatestVersion() { 56 | ArrayList names = new ArrayList<>(); 57 | 58 | File folder = new File(getAuthlibFolder()); 59 | for (File entry : folder.listFiles()) { 60 | if (entry.isDirectory() && entry.getName().matches("[0-9]+\\.[0-9]+\\.[0-9]+")) { 61 | names.add(entry.getName()); 62 | } 63 | } 64 | 65 | Collections.sort(names, new VersionComparator()); 66 | 67 | return names.get(names.size() - 1); 68 | } 69 | 70 | private String getAuthlibJarPath() { 71 | String version = getLatestVersion(); 72 | return getAuthlibFolder() + File.separatorChar + version + File.separatorChar + "authlib-" + version + ".jar"; 73 | } 74 | 75 | protected boolean entryWriter(ZipInputStream zis, ZipEntry inEntry, ZipOutputStream zos) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException { 76 | if (inEntry.getName().equalsIgnoreCase("yggdrasil_session_pubkey.der")) { 77 | ZipEntry entry = new ZipEntry(inEntry.getName()); 78 | byte[] cert = getSessionServerCertificate(); 79 | zos.putNextEntry(entry); 80 | zos.write(cert, 0, cert.length); 81 | return true; 82 | } 83 | 84 | return false; 85 | } 86 | 87 | private byte[] createSha1(File file) throws IOException, NoSuchAlgorithmException { 88 | MessageDigest digest = MessageDigest.getInstance("SHA-1"); 89 | FileInputStream fis = new FileInputStream(file); 90 | int n = 0; 91 | byte[] buffer = new byte[8192]; 92 | while (n != -1) { 93 | n = fis.read(buffer); 94 | if (n > 0) { 95 | digest.update(buffer, 0, n); 96 | } 97 | } 98 | return digest.digest(); 99 | } 100 | 101 | private String bytesToHex(byte[] bytes) { 102 | StringBuilder result = new StringBuilder(); 103 | for (byte byt : bytes) { 104 | result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1)); 105 | } 106 | return result.toString(); 107 | } 108 | 109 | private void writeChecksum(String authlibJar, String checksum) throws FileNotFoundException { 110 | PrintWriter file = new PrintWriter(authlibJar + ".sha"); 111 | file.print(checksum); 112 | file.close(); 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /patcher/src/commands/CertInstaller.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import lib.CertKeyStoreManager; 4 | 5 | /** 6 | * Installs two new jssecerts which are required by Minecraft 7 | * 8 | * @author András Rutkai 9 | * @since 2015.10.03. 10 | */ 11 | public class CertInstaller { 12 | 13 | public void installCerts() throws Exception { 14 | CertKeyStoreManager keyStoreManager = new CertKeyStoreManager(); 15 | CertManager cm = new CertManager(keyStoreManager); 16 | 17 | cm.installCert("authserver.mojang.com"); 18 | cm.installCert("sessionserver.mojang.com"); 19 | 20 | keyStoreManager.writeKeyStore(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /patcher/src/commands/CertManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * - Neither the name of Sun Microsystems nor the names of its 16 | * contributors may be used to endorse or promote products derived 17 | * from this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package commands; 33 | 34 | import lib.CertKeyStoreManager; 35 | 36 | import javax.net.ssl.*; 37 | import java.io.ByteArrayInputStream; 38 | import java.io.IOException; 39 | import java.security.KeyManagementException; 40 | import java.security.KeyStoreException; 41 | import java.security.NoSuchAlgorithmException; 42 | import java.security.cert.Certificate; 43 | import java.security.cert.CertificateException; 44 | import java.security.cert.CertificateFactory; 45 | import java.security.cert.X509Certificate; 46 | import java.security.spec.X509EncodedKeySpec; 47 | 48 | /** 49 | * Certificate management class 50 | * 51 | * @author András Rutkai 52 | * @since 2015.10.06. 53 | */ 54 | public class CertManager { 55 | 56 | private CertKeyStoreManager keyStoreManager; 57 | 58 | public CertManager(CertKeyStoreManager keyStoreManager) { 59 | this.keyStoreManager = keyStoreManager; 60 | } 61 | 62 | public void installCert(String host) throws Exception { 63 | X509Certificate cert = getCert(host); 64 | 65 | String alias = host + "-" + 1; 66 | keyStoreManager.getKeyStore().setCertificateEntry(alias, cert); 67 | } 68 | 69 | public X509Certificate getCert(String host) throws NoSuchAlgorithmException, KeyStoreException, IOException, KeyManagementException { 70 | TrustManagerFactory tmf = 71 | TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); 72 | tmf.init(keyStoreManager.getKeyStore()); 73 | X509TrustManager defaultTrustManager = (X509TrustManager) tmf.getTrustManagers()[0]; 74 | SavingTrustManager tm = new SavingTrustManager(defaultTrustManager); 75 | 76 | performHandshake(tm, host); 77 | 78 | X509Certificate[] chain = tm.chain; 79 | if (chain == null) { 80 | throw new KeyManagementException("Could not obtain server certificate chain"); 81 | } 82 | return chain[0]; 83 | } 84 | 85 | public X509EncodedKeySpec getKey(String host) throws CertificateException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException { 86 | CertificateFactory certFactory = CertificateFactory.getInstance("X509"); 87 | Certificate certificate = certFactory.generateCertificate(new ByteArrayInputStream(getCert(host).getEncoded())); 88 | 89 | return new X509EncodedKeySpec(certificate.getPublicKey().getEncoded()); 90 | } 91 | 92 | private void performHandshake(SavingTrustManager tm, String host) throws KeyManagementException, NoSuchAlgorithmException, IOException { 93 | SSLSocket socket = (SSLSocket) createSSLSocketFactory(tm).createSocket(host, 443); 94 | socket.setSoTimeout(10000); 95 | try { 96 | socket.startHandshake(); 97 | socket.close(); 98 | } catch (SSLException e) { 99 | // Certificate has not been added yet 100 | } 101 | } 102 | 103 | private SSLSocketFactory createSSLSocketFactory(SavingTrustManager tm) throws NoSuchAlgorithmException, KeyManagementException { 104 | SSLContext context = SSLContext.getInstance("TLS"); 105 | context.init(null, new TrustManager[]{tm}, null); 106 | return context.getSocketFactory(); 107 | } 108 | 109 | private static class SavingTrustManager implements X509TrustManager { 110 | private final X509TrustManager tm; 111 | 112 | private X509Certificate[] chain; 113 | 114 | SavingTrustManager(X509TrustManager tm) { 115 | this.tm = tm; 116 | } 117 | 118 | public X509Certificate[] getAcceptedIssuers() { 119 | throw new UnsupportedOperationException(); 120 | } 121 | 122 | public void checkClientTrusted(X509Certificate[] chain, String authType) 123 | throws CertificateException { 124 | throw new UnsupportedOperationException(); 125 | } 126 | 127 | public void checkServerTrusted(X509Certificate[] chain, String authType) 128 | throws CertificateException { 129 | this.chain = chain; 130 | tm.checkServerTrusted(chain, authType); 131 | } 132 | 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /patcher/src/commands/HostsPatcher.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.io.IOException; 4 | import java.net.InetAddress; 5 | import java.net.UnknownHostException; 6 | import java.nio.charset.StandardCharsets; 7 | import java.nio.file.Files; 8 | import java.nio.file.Path; 9 | import java.nio.file.Paths; 10 | import java.util.regex.Pattern; 11 | 12 | /** 13 | * (Un)Patches the hosts file to use a custom server 14 | * 15 | * @author András Rutkai 16 | * @since 2015.10.03. 17 | */ 18 | public class HostsPatcher { 19 | 20 | private final Pattern IP_PATTERN = Pattern.compile("^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"); 21 | 22 | public void patch(String address) throws IOException { 23 | if (!isIP(address)) { 24 | address = getIPAddress(address); 25 | } 26 | 27 | patchHostsFileWithIP(address); 28 | } 29 | 30 | public void unpatch() throws IOException { 31 | String hosts = readHostsFile(); 32 | if (!isPatched(hosts)) { 33 | return; 34 | } 35 | 36 | hosts = stripHosts(hosts); 37 | writeHostsFile(hosts); 38 | } 39 | 40 | private boolean isIP(final String ip) { 41 | return IP_PATTERN.matcher(ip).matches(); 42 | } 43 | 44 | private String getIPAddress(String domain) throws UnknownHostException { 45 | InetAddress address = InetAddress.getByName(domain); 46 | return address.getHostAddress(); 47 | } 48 | 49 | private void patchHostsFileWithIP(String ip) throws IOException { 50 | String hosts = readHostsFile(); 51 | if (isPatched(hosts)) { 52 | return; 53 | } 54 | 55 | hosts = addHosts(hosts, ip); 56 | writeHostsFile(hosts); 57 | } 58 | 59 | private String readHostsFile() throws IOException { 60 | Path path = getPath(); 61 | return new String(Files.readAllBytes(path), StandardCharsets.UTF_8); 62 | } 63 | 64 | private void writeHostsFile(String content) throws IOException { 65 | Path path = getPath(); 66 | Files.write(path, content.getBytes()); 67 | } 68 | 69 | private Path getPath() { 70 | if (isWin()) { 71 | return Paths.get("C:\\Windows\\system32\\drivers\\etc\\hosts"); 72 | } 73 | 74 | return Paths.get("/etc/hosts"); 75 | } 76 | 77 | private boolean isWin() { 78 | return System.getProperty("os.name").toLowerCase().contains("win"); 79 | } 80 | 81 | private boolean isPatched(String hosts) { 82 | return hosts.contains("authserver.mojang.com") || hosts.contains("sessionserver.mojang.com"); 83 | } 84 | 85 | private String addHosts(String file, String ip) { 86 | return file + "\n" + 87 | ip + " authserver.mojang.com\n" + 88 | ip + " sessionserver.mojang.com\n" + 89 | ip + " api.mojang.com\n"; 90 | } 91 | 92 | private String stripHosts(String file) { 93 | return file 94 | .replaceAll("(?m)^[0-9.]+\\s+authserver\\.mojang\\.com\\n?$", "") 95 | .replaceAll("(?m)^[0-9.]+\\s+sessionserver\\.mojang\\.com\\n?$", "") 96 | .replaceAll("(?m)^[0-9.]+\\s+api\\.mojang\\.com\\n?$", ""); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /patcher/src/commands/LauncherPatcher.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import SevenZip.Compression.LZMA.Decoder; 4 | import lib.BasePatcher; 5 | import lib.CertKeyStoreManager; 6 | 7 | import javax.xml.bind.DatatypeConverter; 8 | import java.io.*; 9 | import java.security.KeyManagementException; 10 | import java.security.KeyStoreException; 11 | import java.security.MessageDigest; 12 | import java.security.NoSuchAlgorithmException; 13 | import java.security.cert.CertificateException; 14 | import java.util.Scanner; 15 | import java.util.jar.JarOutputStream; 16 | import java.util.jar.Pack200; 17 | import java.util.regex.Pattern; 18 | import java.util.zip.ZipEntry; 19 | import java.util.zip.ZipInputStream; 20 | import java.util.zip.ZipOutputStream; 21 | 22 | /** 23 | * Downloads and patches the Minecraft Launcher to use a forged certificate 24 | * 25 | * @author András Rutkai 26 | * @since 2015.10.03. 27 | */ 28 | public class LauncherPatcher extends BasePatcher { 29 | 30 | private final String DOWNLOAD_URL = "https://s3.amazonaws.com/Minecraft.Download/launcher/launcher.pack.lzma"; 31 | private final String ORIGINAL_CERT_CHECKSUM = "Sj8xWBxbm84OU915qY0tpT+l4RbDoWw8NtuZHxUrJVQ="; 32 | 33 | public void savePatchedLauncher() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException { 34 | savePatchedJar(getJarInputStream(), "launcher.jar"); 35 | } 36 | 37 | protected boolean entryWriter(ZipInputStream zis, ZipEntry inEntry, ZipOutputStream zos) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException { 38 | if (inEntry.getName().equalsIgnoreCase("yggdrasil_session_pubkey.der")) { 39 | ZipEntry entry = new ZipEntry(inEntry.getName()); 40 | byte[] cert = getSessionServerCertificate(); 41 | zos.putNextEntry(entry); 42 | zos.write(cert, 0, cert.length); 43 | return true; 44 | } else if (inEntry.getName().equalsIgnoreCase("META-INF/MANIFEST.MF")) { 45 | Scanner scanner = new Scanner(zis).useDelimiter("\\A"); 46 | String manifest = scanner.hasNext() ? scanner.next() : ""; 47 | byte[] cert = getSessionServerCertificate(); 48 | manifest = manifest.replaceAll("(?s)" + Pattern.quote(ORIGINAL_CERT_CHECKSUM), sha256Digest(cert)); 49 | 50 | ZipEntry entry = new ZipEntry(inEntry.getName()); 51 | zos.putNextEntry(entry); 52 | zos.write(manifest.getBytes(), 0, manifest.length()); 53 | return true; 54 | } else if (skipFile(inEntry.getName())) { 55 | return true; 56 | } 57 | 58 | return false; 59 | } 60 | 61 | private boolean skipFile(String filename) { 62 | return filename.equalsIgnoreCase("META-INF/MOJANGCS.RSA") || filename.equalsIgnoreCase("META-INF/MOJANGCS.SF"); 63 | } 64 | 65 | private String sha256Digest(byte[] file) throws NoSuchAlgorithmException { 66 | MessageDigest md = MessageDigest.getInstance("SHA-256"); 67 | md.update(file); 68 | return DatatypeConverter.printBase64Binary(md.digest()); 69 | } 70 | 71 | private InputStream getJarInputStream() throws IOException { 72 | InputStream archiveStream = getDownloadInputStream(DOWNLOAD_URL); 73 | InputStream packStream = unzip(archiveStream); 74 | return unpackJar(packStream); 75 | } 76 | 77 | private InputStream unzip(InputStream unbufferedInputStream) throws IOException { 78 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 79 | BufferedInputStream bufferedInputStream = new BufferedInputStream(unbufferedInputStream); 80 | BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream); 81 | Decoder decoder = new Decoder(); 82 | 83 | int propertiesSize = 5; 84 | byte[] properties = new byte[propertiesSize]; 85 | if (bufferedInputStream.read(properties, 0, propertiesSize) != propertiesSize) { 86 | throw new IOException("input .lzma file is too short"); 87 | } 88 | if (!decoder.SetDecoderProperties(properties)) { 89 | throw new IOException("Incorrect stream properties"); 90 | } 91 | 92 | long outSize = 0L; 93 | for (int i = 0; i < 8; ++i) { 94 | int size = bufferedInputStream.read(); 95 | if (size < 0) { 96 | throw new IOException("Can't read stream size"); 97 | } 98 | 99 | outSize |= (long) size << (8 * i); 100 | } 101 | 102 | decoder.Code(bufferedInputStream, bufferedOutputStream, outSize); 103 | bufferedInputStream.close(); 104 | bufferedOutputStream.flush(); 105 | 106 | return new ByteArrayInputStream(outputStream.toByteArray()); 107 | } 108 | 109 | private InputStream unpackJar(InputStream inputStream) throws IOException { 110 | Pack200.Unpacker unpacker = Pack200.newUnpacker(); 111 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 112 | JarOutputStream jos = new JarOutputStream(outputStream); 113 | unpacker.unpack(inputStream, jos); 114 | jos.flush(); 115 | jos.finish(); 116 | inputStream.close(); 117 | return new ByteArrayInputStream(outputStream.toByteArray()); 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /patcher/src/commands/ServerPatcher.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import com.google.gson.Gson; 4 | import lib.BasePatcher; 5 | import models.Versions; 6 | 7 | import java.io.BufferedReader; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.io.InputStreamReader; 11 | import java.security.KeyManagementException; 12 | import java.security.KeyStoreException; 13 | import java.security.NoSuchAlgorithmException; 14 | import java.security.cert.CertificateException; 15 | import java.util.zip.ZipEntry; 16 | import java.util.zip.ZipInputStream; 17 | import java.util.zip.ZipOutputStream; 18 | 19 | /** 20 | * Downloads and patches the Minecraft Server jar to use a forged certificate 21 | * 22 | * @author András Rutkai 23 | * @since 2015.10.11. 24 | */ 25 | public class ServerPatcher extends BasePatcher { 26 | 27 | private final String VERSIONS_URL = "http://s3.amazonaws.com/Minecraft.Download/versions/versions.json"; 28 | private final String SERVER_JAR_URL = "https://s3.amazonaws.com/Minecraft.Download/versions/%s/minecraft_server.%s.jar"; 29 | 30 | private Versions versions; 31 | 32 | public ServerPatcher() throws IOException { 33 | String json = readInputStream(getDownloadInputStream(VERSIONS_URL)); 34 | Gson gson = new Gson(); 35 | versions = gson.fromJson(json, Versions.class); 36 | } 37 | 38 | public Versions versions() { 39 | return versions; 40 | } 41 | 42 | public void savePatchedLauncher(String version) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException { 43 | String url = String.format(SERVER_JAR_URL, version, version); 44 | savePatchedJar(getDownloadInputStream(url), "minecraft_server.jar"); 45 | } 46 | 47 | protected boolean entryWriter(ZipInputStream zis, ZipEntry inEntry, ZipOutputStream zos) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException { 48 | if (inEntry.getName().equalsIgnoreCase("yggdrasil_session_pubkey.der")) { 49 | ZipEntry entry = new ZipEntry(inEntry.getName()); 50 | byte[] cert = getSessionServerCertificate(); 51 | zos.putNextEntry(entry); 52 | zos.write(cert, 0, cert.length); 53 | return true; 54 | } 55 | 56 | return false; 57 | } 58 | 59 | private String readInputStream(InputStream stream) throws IOException { 60 | BufferedReader reader = null; 61 | try { 62 | reader = new BufferedReader(new InputStreamReader(stream)); 63 | StringBuffer buffer = new StringBuffer(); 64 | int read; 65 | char[] chars = new char[1024]; 66 | while ((read = reader.read(chars)) != -1) { 67 | buffer.append(chars, 0, read); 68 | } 69 | 70 | return buffer.toString(); 71 | } finally { 72 | if (reader != null) { 73 | reader.close(); 74 | } 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /patcher/src/lib/BasePatcher.java: -------------------------------------------------------------------------------- 1 | package lib; 2 | 3 | import commands.CertManager; 4 | 5 | import java.io.File; 6 | import java.io.FileOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.net.URL; 10 | import java.security.KeyManagementException; 11 | import java.security.KeyStoreException; 12 | import java.security.NoSuchAlgorithmException; 13 | import java.security.cert.CertificateException; 14 | import java.util.zip.ZipEntry; 15 | import java.util.zip.ZipInputStream; 16 | import java.util.zip.ZipOutputStream; 17 | 18 | /** 19 | * Common functions in *Patcher classes 20 | */ 21 | public abstract class BasePatcher { 22 | 23 | private byte[] sessionserverCertification; 24 | 25 | abstract protected boolean entryWriter(ZipInputStream zis, ZipEntry inEntry, ZipOutputStream zos) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException; 26 | 27 | protected void savePatchedJar(InputStream jar, String outputName) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException { 28 | ZipInputStream zis = new ZipInputStream(jar); 29 | 30 | File f = new File(outputName); 31 | ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(f)); 32 | 33 | ZipEntry inEntry; 34 | while ((inEntry = zis.getNextEntry()) != null) { 35 | if (!entryWriter(zis, inEntry, zos)) { 36 | zos.putNextEntry(inEntry); 37 | byte[] buffer = new byte[1024]; 38 | int len; 39 | while ((len = (zis.read(buffer))) > 0) { 40 | zos.write(buffer, 0, len); 41 | } 42 | } 43 | 44 | zos.closeEntry(); 45 | } 46 | 47 | zos.close(); 48 | } 49 | 50 | protected InputStream getDownloadInputStream(String url) throws IOException { 51 | URL website = new URL(url); 52 | return website.openStream(); 53 | } 54 | 55 | protected byte[] getSessionServerCertificate() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, KeyManagementException { 56 | if (sessionserverCertification != null) { 57 | return sessionserverCertification; 58 | } 59 | 60 | CertKeyStoreManager keyStoreManager = new CertKeyStoreManager(); 61 | CertManager cm = new CertManager(keyStoreManager); 62 | sessionserverCertification = cm.getKey("sessionserver.mojang.com").getEncoded(); 63 | 64 | return sessionserverCertification; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /patcher/src/lib/CertKeyStoreManager.java: -------------------------------------------------------------------------------- 1 | package lib; 2 | 3 | import java.io.*; 4 | import java.security.KeyStore; 5 | import java.security.KeyStoreException; 6 | import java.security.NoSuchAlgorithmException; 7 | import java.security.cert.CertificateException; 8 | 9 | public class CertKeyStoreManager { 10 | 11 | private final char[] PASSPHRASE = "changeit".toCharArray(); 12 | 13 | private KeyStore keyStore; 14 | 15 | public CertKeyStoreManager() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException { 16 | keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); 17 | InputStream in = new FileInputStream(getCacertsFile()); 18 | keyStore.load(in, PASSPHRASE); 19 | in.close(); 20 | } 21 | 22 | public KeyStore getKeyStore() { 23 | return keyStore; 24 | } 25 | 26 | public void writeKeyStore() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException { 27 | OutputStream out = new FileOutputStream(getSecurityPath() + File.separatorChar + "jssecacerts"); 28 | keyStore.store(out, PASSPHRASE); 29 | out.close(); 30 | } 31 | 32 | private File getCacertsFile() { 33 | File file = new File("jssecacerts"); 34 | if (!file.isFile()) { 35 | File dir = new File(getSecurityPath()); 36 | file = new File(dir, "jssecacerts"); 37 | if (!file.isFile()) { 38 | file = new File(dir, "cacerts"); 39 | } 40 | } 41 | return file; 42 | } 43 | 44 | private String getSecurityPath() { 45 | return System.getProperty("java.home") + File.separatorChar 46 | + "lib" + File.separatorChar + "security"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /patcher/src/lib/VersionComparator.java: -------------------------------------------------------------------------------- 1 | package lib; 2 | 3 | import java.util.Comparator; 4 | 5 | public class VersionComparator implements Comparator { 6 | 7 | @Override 8 | public int compare(Object o1, Object o2) { 9 | String version1 = (String) o1; 10 | String version2 = (String) o2; 11 | 12 | VersionTokenizer tokenizer1 = new VersionTokenizer(version1); 13 | VersionTokenizer tokenizer2 = new VersionTokenizer(version2); 14 | 15 | int number1 = 0, number2 = 0; 16 | String suffix1 = "", suffix2 = ""; 17 | 18 | while (tokenizer1.MoveNext()) { 19 | if (!tokenizer2.MoveNext()) { 20 | do { 21 | number1 = tokenizer1.getNumber(); 22 | suffix1 = tokenizer1.getSuffix(); 23 | if (number1 != 0 || suffix1.length() != 0) { 24 | // Version one is longer than number two, and non-zero 25 | return 1; 26 | } 27 | } 28 | while (tokenizer1.MoveNext()); 29 | 30 | // Version one is longer than version two, but zero 31 | return 0; 32 | } 33 | 34 | number1 = tokenizer1.getNumber(); 35 | suffix1 = tokenizer1.getSuffix(); 36 | number2 = tokenizer2.getNumber(); 37 | suffix2 = tokenizer2.getSuffix(); 38 | 39 | if (number1 < number2) { 40 | // Number one is less than number two 41 | return -1; 42 | } 43 | if (number1 > number2) { 44 | // Number one is greater than number two 45 | return 1; 46 | } 47 | 48 | boolean empty1 = suffix1.length() == 0; 49 | boolean empty2 = suffix2.length() == 0; 50 | 51 | if (empty1 && empty2) continue; // No suffixes 52 | if (empty1) return 1; // First suffix is empty (1.2 > 1.2b) 53 | if (empty2) return -1; // Second suffix is empty (1.2a < 1.2) 54 | 55 | // Lexical comparison of suffixes 56 | int result = suffix1.compareTo(suffix2); 57 | if (result != 0) return result; 58 | 59 | } 60 | if (tokenizer2.MoveNext()) { 61 | do { 62 | number2 = tokenizer2.getNumber(); 63 | suffix2 = tokenizer2.getSuffix(); 64 | if (number2 != 0 || suffix2.length() != 0) { 65 | // Version one is longer than version two, and non-zero 66 | return -1; 67 | } 68 | } 69 | while (tokenizer2.MoveNext()); 70 | 71 | // Version two is longer than version one, but zero 72 | return 0; 73 | } 74 | return 0; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /patcher/src/lib/VersionTokenizer.java: -------------------------------------------------------------------------------- 1 | package lib; 2 | 3 | public class VersionTokenizer { 4 | private final String _versionString; 5 | private final int _length; 6 | 7 | private int _position; 8 | private int _number; 9 | private String _suffix; 10 | private boolean _hasValue; 11 | 12 | public int getNumber() { 13 | return _number; 14 | } 15 | 16 | public String getSuffix() { 17 | return _suffix; 18 | } 19 | 20 | public boolean hasValue() { 21 | return _hasValue; 22 | } 23 | 24 | public VersionTokenizer(String versionString) { 25 | if (versionString == null) 26 | throw new IllegalArgumentException("versionString is null"); 27 | 28 | _versionString = versionString; 29 | _length = versionString.length(); 30 | } 31 | 32 | public boolean MoveNext() { 33 | _number = 0; 34 | _suffix = ""; 35 | _hasValue = false; 36 | 37 | // No more characters 38 | if (_position >= _length) 39 | return false; 40 | 41 | _hasValue = true; 42 | 43 | while (_position < _length) { 44 | char c = _versionString.charAt(_position); 45 | if (c < '0' || c > '9') break; 46 | _number = _number * 10 + (c - '0'); 47 | _position++; 48 | } 49 | 50 | int suffixStart = _position; 51 | 52 | while (_position < _length) { 53 | char c = _versionString.charAt(_position); 54 | if (c == '.') break; 55 | _position++; 56 | } 57 | 58 | _suffix = _versionString.substring(suffixStart, _position); 59 | 60 | if (_position < _length) _position++; 61 | 62 | return true; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /patcher/src/models/LatestVersion.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class LatestVersion { 4 | public String snapshot; 5 | public String release; 6 | } 7 | -------------------------------------------------------------------------------- /patcher/src/models/Version.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | public class Version { 4 | String id; 5 | String time; // We won't use these 6 | String releaseTime; // We won't use these 7 | String type; 8 | } 9 | -------------------------------------------------------------------------------- /patcher/src/models/Versions.java: -------------------------------------------------------------------------------- 1 | package models; 2 | 3 | import java.util.List; 4 | 5 | public class Versions { 6 | public LatestVersion latest; 7 | public List versions; 8 | 9 | public String getVersions() { 10 | StringBuilder sb = new StringBuilder(); 11 | for (Version version : versions) { 12 | sb.append(version.id); 13 | sb.append(" "); 14 | } 15 | 16 | return sb.toString(); 17 | } 18 | 19 | public boolean hasVersion(String version) { 20 | for (Version item : versions) { 21 | if (item.id.equals(version)) { 22 | return true; 23 | } 24 | } 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rutkai/Mjolnir-Authentication-Server/92fb676f0730489561f6ec777801c3bd1e5eb567/static/.gitkeep -------------------------------------------------------------------------------- /test/authenticate_fallback_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('authserver.httpPort'); 4 | 5 | if (config.get('drivers').length !== 2) { 6 | return; 7 | } 8 | 9 | frisby.create('Missing user gives authentication error') 10 | .post('http://localhost:' + httpPort + '/authenticate', { 11 | "username": "nonexistent", 12 | "password": "asdf" 13 | }) 14 | .expectStatus(200) 15 | .expectHeaderContains('content-type', 'application/json') 16 | .expectJSON({ 17 | "error": "ForbiddenOperationException", 18 | "errorMessage": "Invalid credentials. Invalid username or password." 19 | }) 20 | .expectJSONTypes({ 21 | "error": String, 22 | "errorMessage": String 23 | }) 24 | .toss(); 25 | 26 | frisby.create('Wrong password for config user gives authentication error') 27 | .post('http://localhost:' + httpPort + '/authenticate', { 28 | "username": "test", 29 | "password": "asdf" 30 | }) 31 | .expectStatus(200) 32 | .expectHeaderContains('content-type', 'application/json') 33 | .expectJSON({ 34 | "error": "ForbiddenOperationException", 35 | "errorMessage": "Invalid credentials. Invalid username or password." 36 | }) 37 | .expectJSONTypes({ 38 | "error": String, 39 | "errorMessage": String 40 | }) 41 | .toss(); 42 | 43 | frisby.create('Valid credentials in config user') 44 | .post('http://localhost:' + httpPort + '/authenticate', { 45 | "username": "test", 46 | "password": "test" 47 | }) 48 | .expectStatus(200) 49 | .expectHeaderContains('content-type', 'application/json') 50 | .expectJSONTypes({ 51 | "accessToken": String, 52 | "clientToken": String 53 | }) 54 | .toss(); 55 | 56 | frisby.create('Wrong password in mongodb user') 57 | .post('http://localhost:' + httpPort + '/authenticate', { 58 | "username": "dbUser", 59 | "password": "test" 60 | }) 61 | .expectStatus(200) 62 | .expectHeaderContains('content-type', 'application/json') 63 | .expectJSON({ 64 | "error": "ForbiddenOperationException", 65 | "errorMessage": "Invalid credentials. Invalid username or password." 66 | }) 67 | .expectJSONTypes({ 68 | "error": String, 69 | "errorMessage": String 70 | }) 71 | .toss(); 72 | 73 | frisby.create('Valid credentials using mongodb user') 74 | .post('http://localhost:' + httpPort + '/authenticate', { 75 | "username": "dbUser", 76 | "password": "db" 77 | }) 78 | .expectStatus(200) 79 | .expectHeaderContains('content-type', 'application/json') 80 | .expectJSONTypes({ 81 | "accessToken": String, 82 | "clientToken": String 83 | }) 84 | .toss(); 85 | 86 | frisby.create('Config user overlaps mongodb user') 87 | .post('http://localhost:' + httpPort + '/authenticate', { 88 | "agent": { 89 | "name": "Minecraft", 90 | "version": 1 91 | }, 92 | "username": "overlapUser", 93 | "password": "asdf" 94 | }) 95 | .expectStatus(200) 96 | .expectHeaderContains('content-type', 'application/json') 97 | .expectJSON({ 98 | "availableProfiles": [ 99 | { 100 | "id": "0e565137f98349feac6115adfe19e962", 101 | "name": "overlapPlayer" 102 | } 103 | ], 104 | "selectedProfile": { 105 | "id": "0e565137f98349feac6115adfe19e962", 106 | "name": "overlapPlayer" 107 | } 108 | }) 109 | .expectJSONTypes({ 110 | "accessToken": String, 111 | "clientToken": String 112 | }) 113 | .toss(); 114 | -------------------------------------------------------------------------------- /test/authenticate_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('authserver.httpPort'); 4 | 5 | frisby.create('Nothing gives authentication error') 6 | .get('http://localhost:' + httpPort + '/authenticate') 7 | .expectStatus(200) 8 | .expectHeaderContains('content-type', 'application/json') 9 | .expectJSON({ 10 | "error": "ForbiddenOperationException", 11 | "errorMessage": "Invalid credentials. Invalid username or password." 12 | }) 13 | .expectJSONTypes({ 14 | "error": String, 15 | "errorMessage": String 16 | }) 17 | .toss(); 18 | 19 | frisby.create('Missing user gives authentication error') 20 | .post('http://localhost:' + httpPort + '/authenticate', { 21 | "username": "nonexistent", 22 | "password": "asdf" 23 | }) 24 | .expectStatus(200) 25 | .expectHeaderContains('content-type', 'application/json') 26 | .expectJSON({ 27 | "error": "ForbiddenOperationException", 28 | "errorMessage": "Invalid credentials. Invalid username or password." 29 | }) 30 | .expectJSONTypes({ 31 | "error": String, 32 | "errorMessage": String 33 | }) 34 | .toss(); 35 | 36 | frisby.create('Wrong password gives authentication error') 37 | .post('http://localhost:' + httpPort + '/authenticate', { 38 | "username": "test", 39 | "password": "asdf" 40 | }) 41 | .expectStatus(200) 42 | .expectHeaderContains('content-type', 'application/json') 43 | .expectJSON({ 44 | "error": "ForbiddenOperationException", 45 | "errorMessage": "Invalid credentials. Invalid username or password." 46 | }) 47 | .expectJSONTypes({ 48 | "error": String, 49 | "errorMessage": String 50 | }) 51 | .toss(); 52 | 53 | frisby.create('Valid credentials without clientToken and agent token') 54 | .post('http://localhost:' + httpPort + '/authenticate', { 55 | "username": "test", 56 | "password": "test" 57 | }) 58 | .expectStatus(200) 59 | .expectHeaderContains('content-type', 'application/json') 60 | .expectJSONTypes({ 61 | "accessToken": String, 62 | "clientToken": String 63 | }) 64 | .toss(); 65 | 66 | frisby.create('Valid credentials with clientToken and agent token') 67 | .post('http://localhost:' + httpPort + '/authenticate', { 68 | "username": "test", 69 | "password": "test", 70 | "clientToken": "test-client-token" 71 | }) 72 | .expectStatus(200) 73 | .expectHeaderContains('content-type', 'application/json') 74 | .expectJSON({ 75 | "clientToken": "test-client-token" 76 | }) 77 | .expectJSONTypes({ 78 | "accessToken": String, 79 | "clientToken": String 80 | }) 81 | .toss(); 82 | 83 | frisby.create('Valid credentials with agent token') 84 | .post('http://localhost:' + httpPort + '/authenticate', { 85 | "agent": { 86 | "name": "Minecraft", 87 | "version": 1 88 | }, 89 | "username": "test", 90 | "password": "test" 91 | }) 92 | .expectStatus(200) 93 | .expectHeaderContains('content-type', 'application/json') 94 | .expectJSON({ 95 | "availableProfiles": [ 96 | { 97 | "id": "650bed2c9ef54b5fb02c61fa493c68b5", 98 | "name": "testPlayer" 99 | } 100 | ], 101 | "selectedProfile": { 102 | "id": "650bed2c9ef54b5fb02c61fa493c68b5", 103 | "name": "testPlayer" 104 | } 105 | }) 106 | .expectJSONTypes({ 107 | "accessToken": String, 108 | "clientToken": String 109 | }) 110 | .toss(); -------------------------------------------------------------------------------- /test/invalidate_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('authserver.httpPort'); 4 | var syncTestRunner = require('./synchronousTestRunner'); 5 | 6 | 7 | frisby.create('Nothing gives empty response') 8 | .get('http://localhost:' + httpPort + '/invalidate') 9 | .expectStatus(200) 10 | .expectHeaderContains('content-type', 'application/json') 11 | .expectJSONLength(0) 12 | .toss(); 13 | 14 | frisby.create('Invalid access token gives empty response') 15 | .post('http://localhost:' + httpPort + '/invalidate', { 16 | "accessToken": "nonexistent" 17 | }) 18 | .expectStatus(200) 19 | .expectHeaderContains('content-type', 'application/json') 20 | .expectJSONLength(0) 21 | .toss(); 22 | 23 | frisby.create('Invalid client token without access token gives empty response') 24 | .post('http://localhost:' + httpPort + '/invalidate', { 25 | "clientToken": "nonexistent" 26 | }) 27 | .expectStatus(200) 28 | .expectHeaderContains('content-type', 'application/json') 29 | .expectJSONLength(0) 30 | .toss(); 31 | 32 | syncTestRunner.registerTest( 33 | frisby.create('Authenticating for invalidating') 34 | .post('http://localhost:' + httpPort + '/authenticate', { 35 | "username": "test", 36 | "password": "test", 37 | "clientToken": "test-client-token" 38 | }) 39 | .afterJSON(function (response) { 40 | frisby.create('then invalidating without client token') 41 | .post('http://localhost:' + httpPort + '/invalidate', { 42 | "accessToken": response.accessToken 43 | }) 44 | .expectStatus(200) 45 | .expectHeaderContains('content-type', 'application/json') 46 | .expectJSONLength(0) 47 | .after(function () { 48 | frisby.create('invalidates the user session') 49 | .post('http://localhost:' + httpPort + '/validate', { 50 | "accessToken": response.accessToken 51 | }) 52 | .expectStatus(200) 53 | .expectHeaderContains('content-type', 'application/json') 54 | .expectJSON({ 55 | "error": "ForbiddenOperationException", 56 | "errorMessage": "Invalid token" 57 | }) 58 | .expectJSONTypes({ 59 | "error": String, 60 | "errorMessage": String 61 | }) 62 | .after(function () { 63 | syncTestRunner.runNext(); 64 | }) 65 | .toss(); 66 | }) 67 | .toss(); 68 | }) 69 | ); 70 | 71 | syncTestRunner.registerTest( 72 | frisby.create('Authenticating for invalidating') 73 | .post('http://localhost:' + httpPort + '/authenticate', { 74 | "username": "test", 75 | "password": "test", 76 | "clientToken": "test-client-token" 77 | }) 78 | .afterJSON(function (response) { 79 | frisby.create('then invalidating with wrong client token') 80 | .post('http://localhost:' + httpPort + '/invalidate', { 81 | "accessToken": response.accessToken, 82 | "clientToken": "wrong-client-token" 83 | }) 84 | .expectStatus(200) 85 | .expectHeaderContains('content-type', 'application/json') 86 | .expectJSONLength(0) 87 | .after(function () { 88 | frisby.create('does not invalidate the user session') 89 | .post('http://localhost:' + httpPort + '/validate', { 90 | "accessToken": response.accessToken 91 | }) 92 | .expectStatus(200) 93 | .expectHeaderContains('content-type', 'application/json') 94 | .expectJSONLength(0) 95 | .after(function () { 96 | syncTestRunner.runNext(); 97 | }) 98 | .toss(); 99 | }) 100 | .toss(); 101 | }) 102 | ); 103 | 104 | syncTestRunner.registerTest( 105 | frisby.create('Authenticating for invalidating') 106 | .post('http://localhost:' + httpPort + '/authenticate', { 107 | "username": "test", 108 | "password": "test", 109 | "clientToken": "test-client-token" 110 | }) 111 | .afterJSON(function (response) { 112 | frisby.create('then invalidating with valid client token') 113 | .post('http://localhost:' + httpPort + '/invalidate', { 114 | "accessToken": response.accessToken, 115 | "clientToken": "test-client-token" 116 | }) 117 | .expectStatus(200) 118 | .expectHeaderContains('content-type', 'application/json') 119 | .expectJSONLength(0) 120 | .after(function () { 121 | frisby.create('invalidates the user session') 122 | .post('http://localhost:' + httpPort + '/validate', { 123 | "accessToken": response.accessToken 124 | }) 125 | .expectStatus(200) 126 | .expectHeaderContains('content-type', 'application/json') 127 | .expectJSON({ 128 | "error": "ForbiddenOperationException", 129 | "errorMessage": "Invalid token" 130 | }) 131 | .expectJSONTypes({ 132 | "error": String, 133 | "errorMessage": String 134 | }) 135 | .after(function () { 136 | syncTestRunner.runNext(); 137 | }) 138 | .toss(); 139 | }) 140 | .toss(); 141 | }) 142 | ); 143 | -------------------------------------------------------------------------------- /test/playernameToUuid_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('apiserver.httpPort'); 4 | 5 | frisby.create('Getting a non-existent user gives empty response') 6 | .get('http://localhost:' + httpPort + '/users/profiles/minecraft/nonexistent') 7 | .expectStatus(204) 8 | .toss(); 9 | 10 | frisby.create('Getting a valid user gives userid and playername') 11 | .get('http://localhost:' + httpPort + '/users/profiles/minecraft/testPlayer') 12 | .expectStatus(200) 13 | .expectHeaderContains('content-type', 'application/json') 14 | .expectJSON({ 15 | "id": "650bed2c9ef54b5fb02c61fa493c68b5", 16 | "name": "testPlayer" 17 | }) 18 | .expectJSONTypes({ 19 | "id": String, 20 | "name": String 21 | }) 22 | .toss(); 23 | -------------------------------------------------------------------------------- /test/playernamesToUuid_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('apiserver.httpPort'); 4 | 5 | frisby.create('Nothing gives nothing') 6 | .get('http://localhost:' + httpPort + '/profiles/minecraft') 7 | .expectStatus(200) 8 | .expectHeaderContains('content-type', 'application/json') 9 | .expectJSON([]) 10 | .toss(); 11 | 12 | frisby.create('Getting one invalid user gives nothing') 13 | .post('http://localhost:' + httpPort + '/profiles/minecraft', [ 14 | 'nonexistent' 15 | ]) 16 | .expectStatus(200) 17 | .expectHeaderContains('content-type', 'application/json') 18 | .expectJSON([]) 19 | .toss(); 20 | 21 | frisby.create('More than a hundred users gives error') 22 | .post('http://localhost:' + httpPort + '/profiles/minecraft', generateNames(101)) 23 | .expectStatus(200) 24 | .expectHeaderContains('content-type', 'application/json') 25 | .expectJSON({ 26 | "error": "IllegalArgumentException", 27 | "errorMessage": "Too many names." 28 | }) 29 | .expectJSONTypes({ 30 | "error": String, 31 | "errorMessage": String 32 | }) 33 | .toss(); 34 | 35 | frisby.create('Getting one valid user gives userid and playername') 36 | .post('http://localhost:' + httpPort + '/profiles/minecraft', [ 37 | 'testPlayer' 38 | ]) 39 | .expectStatus(200) 40 | .expectHeaderContains('content-type', 'application/json') 41 | .expectJSON([{ 42 | "id": "650bed2c9ef54b5fb02c61fa493c68b5", 43 | "name": "testPlayer" 44 | }]) 45 | .expectJSONTypes([{ 46 | "id": String, 47 | "name": String 48 | }]) 49 | .toss(); 50 | 51 | frisby.create('Getting one valid user corrects invalid username case') 52 | .post('http://localhost:' + httpPort + '/profiles/minecraft', [ 53 | 'tEstPLaYer' 54 | ]) 55 | .expectStatus(200) 56 | .expectHeaderContains('content-type', 'application/json') 57 | .expectJSON([{ 58 | "id": "650bed2c9ef54b5fb02c61fa493c68b5", 59 | "name": "testPlayer" 60 | }]) 61 | .expectJSONTypes([{ 62 | "id": String, 63 | "name": String 64 | }]) 65 | .toss(); 66 | 67 | frisby.create('Getting an empty username gives exception') 68 | .post('http://localhost:' + httpPort + '/profiles/minecraft', [ 69 | 'testPlayer', 70 | '', 71 | 'somebody' 72 | ]) 73 | .expectStatus(200) 74 | .expectHeaderContains('content-type', 'application/json') 75 | .expectJSON({ 76 | "error": "IllegalArgumentException", 77 | "errorMessage": "Empty username." 78 | }) 79 | .expectJSONTypes({ 80 | "error": String, 81 | "errorMessage": String 82 | }) 83 | .toss(); 84 | 85 | frisby.create('Getting multiple valid users gives userid and playername') 86 | .post('http://localhost:' + httpPort + '/profiles/minecraft', [ 87 | 'testPlayer', 88 | 'testPlayerOld' 89 | ]) 90 | .expectStatus(200) 91 | .expectHeaderContains('content-type', 'application/json') 92 | .expectJSON([ 93 | { 94 | "id": "650bed2c9ef54b5fb02c61fa493c68b5", 95 | "name": "testPlayer" 96 | }, 97 | { 98 | "id": "1294fda6159c4218be4c89b660d9cf32", 99 | "name": "testPlayerOld" 100 | } 101 | ]) 102 | .expectJSONTypes([{ 103 | "id": String, 104 | "name": String 105 | }]) 106 | .toss(); 107 | 108 | 109 | function generateNames(amount) { 110 | var names = []; 111 | 112 | while (names.length < amount) { 113 | names.push('name' + names.length); 114 | } 115 | 116 | return names; 117 | } 118 | -------------------------------------------------------------------------------- /test/refresh_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('authserver.httpPort'); 4 | var syncTestRunner = require('./synchronousTestRunner'); 5 | 6 | frisby.create('Nothing gives illegal argument error') 7 | .get('http://localhost:' + httpPort + '/refresh') 8 | .expectStatus(200) 9 | .expectHeaderContains('content-type', 'application/json') 10 | .expectJSON({ 11 | "error": "IllegalArgumentException", 12 | "errorMessage": "Access Token can not be null or empty." 13 | }) 14 | .expectJSONTypes({ 15 | "error": String, 16 | "errorMessage": String 17 | }) 18 | .toss(); 19 | 20 | frisby.create('Missing client token gives invalid token error') 21 | .post('http://localhost:' + httpPort + '/refresh', { 22 | "accessToken": "nonexistent" 23 | }) 24 | .expectStatus(200) 25 | .expectHeaderContains('content-type', 'application/json') 26 | .expectJSON({ 27 | "error": "ForbiddenOperationException", 28 | "errorMessage": "Invalid token." 29 | }) 30 | .expectJSONTypes({ 31 | "error": String, 32 | "errorMessage": String 33 | }) 34 | .toss(); 35 | 36 | syncTestRunner.registerTest( 37 | frisby.create('Authenticating for refresh') 38 | .post('http://localhost:' + httpPort + '/authenticate', { 39 | "username": "test", 40 | "password": "test", 41 | "clientToken": "test-client-token" 42 | }) 43 | .afterJSON(function () { 44 | frisby.create('then wrong access token gives invalid token error') 45 | .post('http://localhost:' + httpPort + '/refresh', { 46 | "accessToken": "nonexistent", 47 | "clientToken": "test-client-token" 48 | }) 49 | .expectStatus(200) 50 | .expectHeaderContains('content-type', 'application/json') 51 | .expectJSON({ 52 | "error": "ForbiddenOperationException", 53 | "errorMessage": "Invalid token." 54 | }) 55 | .expectJSONTypes({ 56 | "error": String, 57 | "errorMessage": String 58 | }) 59 | .after(function () { 60 | syncTestRunner.runNext(); 61 | }) 62 | .toss(); 63 | }) 64 | ); 65 | 66 | syncTestRunner.registerTest( 67 | frisby.create('Authenticating for refresh') 68 | .post('http://localhost:' + httpPort + '/authenticate', { 69 | "username": "test", 70 | "password": "test", 71 | "clientToken": "test-client-token" 72 | }) 73 | .afterJSON(function (response) { 74 | frisby.create('then wrong client token gives invalid token error') 75 | .post('http://localhost:' + httpPort + '/refresh', { 76 | "accessToken": response.accessToken, 77 | "clientToken": "nonexistent" 78 | }) 79 | .expectStatus(200) 80 | .expectHeaderContains('content-type', 'application/json') 81 | .expectJSON({ 82 | "error": "ForbiddenOperationException", 83 | "errorMessage": "Invalid token." 84 | }) 85 | .expectJSONTypes({ 86 | "error": String, 87 | "errorMessage": String 88 | }) 89 | .after(function () { 90 | syncTestRunner.runNext(); 91 | }) 92 | .toss(); 93 | }) 94 | ); 95 | 96 | syncTestRunner.registerTest( 97 | frisby.create('Authenticating for refresh') 98 | .post('http://localhost:' + httpPort + '/authenticate', { 99 | "username": "test", 100 | "password": "test", 101 | "clientToken": "test-client-token" 102 | }) 103 | .afterJSON(function (response) { 104 | frisby.create('then refreshing with valid tokens gives new access token') 105 | .post('http://localhost:' + httpPort + '/refresh', { 106 | "accessToken": response.accessToken, 107 | "clientToken": "test-client-token" 108 | }) 109 | .expectStatus(200) 110 | .expectHeaderContains('content-type', 'application/json') 111 | .expectJSON({ 112 | accessToken: function (val) { 113 | expect(val).not.toEqual(response.accessToken) 114 | }, 115 | "clientToken": "test-client-token" 116 | }) 117 | .expectJSONTypes({ 118 | "accessToken": String, 119 | "clientToken": String 120 | }) 121 | .after(function () { 122 | syncTestRunner.runNext(); 123 | }) 124 | .toss(); 125 | }) 126 | ); 127 | 128 | syncTestRunner.registerTest( 129 | frisby.create('Authenticating for refresh') 130 | .post('http://localhost:' + httpPort + '/authenticate', { 131 | "username": "test", 132 | "password": "test", 133 | "clientToken": "test-client-token" 134 | }) 135 | .afterJSON(function (response) { 136 | frisby.create('then refreshing with valid tokens and selectedProfile gives the same selectedProfile') 137 | .post('http://localhost:' + httpPort + '/refresh', { 138 | "accessToken": response.accessToken, 139 | "clientToken": "test-client-token", 140 | "selectedProfile": { 141 | "id": "test0123456789abcdef", 142 | "name": "testPlayer" 143 | } 144 | }) 145 | .expectStatus(200) 146 | .expectHeaderContains('content-type', 'application/json') 147 | .expectJSON({ 148 | "selectedProfile": { 149 | "id": "test0123456789abcdef", 150 | "name": "testPlayer" 151 | } 152 | }) 153 | .expectJSONTypes({ 154 | "selectedProfile": Object 155 | }) 156 | .after(function () { 157 | syncTestRunner.runNext(); 158 | }) 159 | .toss(); 160 | }) 161 | ); 162 | -------------------------------------------------------------------------------- /test/root_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('authserver.httpPort'); 4 | 5 | frisby.create('Invalid url throws not found error') 6 | .get('http://localhost:' + httpPort + '/invalid-url-sample') 7 | .expectStatus(404) 8 | .expectHeaderContains('content-type', 'application/json') 9 | .expectJSON({ 10 | "error": "Not Found", 11 | "errorMessage": "The server has not found anything matching the request URI" 12 | }) 13 | .expectJSONTypes({ 14 | "error": String, 15 | "errorMessage": String 16 | }) 17 | .toss(); 18 | 19 | frisby.create('Root path shows basic information') 20 | .get('http://localhost:' + httpPort) 21 | .expectStatus(200) 22 | .expectHeaderContains('content-type', 'application/json') 23 | .expectJSON({ 24 | "Status": "OK", 25 | "Application-Name": "mjolnir.auth.server", 26 | "Application-Owner": "Tester" 27 | }) 28 | .expectJSONTypes({ 29 | "Status": String, 30 | "Runtime-Mode": String, 31 | "Application-Author": String, 32 | "Application-Description": String, 33 | "Specification-Version": String, 34 | "Application-Name": String, 35 | "Implementation-Version": String, 36 | "Application-Owner": String 37 | }) 38 | .toss(); -------------------------------------------------------------------------------- /test/sessionJoin_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('sessionserver.httpPort'); 4 | var syncTestRunner = require('./synchronousTestRunner'); 5 | 6 | frisby.create('Nothing gives illegal argument error') 7 | .get('http://localhost:' + httpPort + '/session/minecraft/join') 8 | .expectStatus(200) 9 | .expectHeaderContains('content-type', 'application/json') 10 | .expectJSON({ 11 | "error": "IllegalArgumentException", 12 | "errorMessage": "accessToken.getServerId() can not be null or empty." 13 | }) 14 | .expectJSONTypes({ 15 | "error": String, 16 | "errorMessage": String 17 | }) 18 | .toss(); 19 | 20 | frisby.create('Missing serverId gives illegal argument exception') 21 | .post('http://localhost:' + httpPort + '/session/minecraft/join', { 22 | "accessToken": "nonexistent" 23 | }) 24 | .expectStatus(200) 25 | .expectHeaderContains('content-type', 'application/json') 26 | .expectJSON({ 27 | "error": "IllegalArgumentException", 28 | "errorMessage": "accessToken.getServerId() can not be null or empty." 29 | }) 30 | .expectJSONTypes({ 31 | "error": String, 32 | "errorMessage": String 33 | }) 34 | .toss(); 35 | 36 | frisby.create('Missing accessToken gives illegal argument exception') 37 | .post('http://localhost:' + httpPort + '/session/minecraft/join', { 38 | "serverId": "nonexistent" 39 | }) 40 | .expectStatus(200) 41 | .expectHeaderContains('content-type', 'application/json') 42 | .expectJSON({ 43 | "error": "IllegalArgumentException", 44 | "errorMessage": "Access Token can not be null or empty." 45 | }) 46 | .expectJSONTypes({ 47 | "error": String, 48 | "errorMessage": String 49 | }) 50 | .toss(); 51 | 52 | frisby.create('Invalid access token gives exception') 53 | .post('http://localhost:' + httpPort + '/session/minecraft/join', { 54 | "accessToken": "nonexistent", 55 | "selectedProfile": "asdf", 56 | "serverId": "xxx" 57 | }) 58 | .expectStatus(200) 59 | .expectHeaderContains('content-type', 'application/json') 60 | .expectJSON({ 61 | "error": "ForbiddenOperationException", 62 | "errorMessage": "Invalid token" 63 | }) 64 | .expectJSONTypes({ 65 | "error": String, 66 | "errorMessage": String 67 | }) 68 | .toss(); 69 | 70 | syncTestRunner.registerTest( 71 | frisby.create('Authenticating for session join') 72 | .post('http://localhost:' + httpPort + '/authenticate', { 73 | "username": "test", 74 | "password": "test" 75 | }) 76 | .afterJSON(function (response) { 77 | frisby.create('then missing selected profile gives exception') 78 | .post('http://localhost:' + httpPort + '/session/minecraft/join', { 79 | "accessToken": response.accessToken, 80 | "serverId": "random" 81 | }) 82 | .expectStatus(200) 83 | .expectHeaderContains('content-type', 'application/json') 84 | .expectJSON({ 85 | "error": "IllegalArgumentException", 86 | "errorMessage": "selectedProfile can not be null." 87 | }) 88 | .expectJSONTypes({ 89 | "error": String, 90 | "errorMessage": String 91 | }) 92 | .after(function () { 93 | syncTestRunner.runNext(); 94 | }) 95 | .toss(); 96 | }) 97 | ); 98 | 99 | syncTestRunner.registerTest( 100 | frisby.create('Authenticating for session join') 101 | .post('http://localhost:' + httpPort + '/authenticate', { 102 | "username": "test", 103 | "password": "test" 104 | }) 105 | .afterJSON(function (response) { 106 | frisby.create('then sending a serverId with invalid selectedProfile and valid accessToken gives exception') 107 | .post('http://localhost:' + httpPort + '/session/minecraft/join', { 108 | "accessToken": response.accessToken, 109 | "selectedProfile": "nonexistent", 110 | "serverId": "random" 111 | }) 112 | .expectStatus(200) 113 | .expectHeaderContains('content-type', 'application/json') 114 | .expectJSON({ 115 | "error": "ForbiddenOperationException", 116 | "errorMessage": "Invalid token" 117 | }) 118 | .expectJSONTypes({ 119 | "error": String, 120 | "errorMessage": String 121 | }) 122 | .after(function () { 123 | syncTestRunner.runNext(); 124 | }) 125 | .toss(); 126 | }) 127 | ); 128 | 129 | syncTestRunner.registerTest( 130 | frisby.create('Authenticating for session join') 131 | .post('http://localhost:' + httpPort + '/authenticate', { 132 | "agent": { 133 | "name": "Minecraft", 134 | "version": 1 135 | }, 136 | "username": "test", 137 | "password": "test" 138 | }) 139 | .afterJSON(function (response) { 140 | frisby.create('then sending a serverId with valid selectedProfile and accessToken gives no response') 141 | .post('http://localhost:' + httpPort + '/session/minecraft/join', { 142 | "accessToken": response.accessToken, 143 | "selectedProfile": response.selectedProfile.id, 144 | "serverId": "5555" 145 | }) 146 | .expectStatus(200) 147 | .expectHeaderContains('content-type', 'application/json') 148 | .expectJSONLength(0) 149 | .after(function () { 150 | syncTestRunner.runNext(); 151 | }) 152 | .toss(); 153 | }) 154 | ); 155 | -------------------------------------------------------------------------------- /test/sessionUuidToProfile_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var moment = require('moment'); 4 | var crypto = require('crypto'); 5 | var fs = require('fs'); 6 | var httpPort = config.get('sessionserver.httpPort'); 7 | 8 | frisby.create('Getting a non-existent UUID gives empty response') 9 | .get('http://localhost:' + httpPort + '/session/minecraft/profile/nonexistent') 10 | .expectStatus(204) 11 | .toss(); 12 | 13 | frisby.create('Getting a valid UUID gives player data without cape') 14 | .get('http://localhost:' + httpPort + '/session/minecraft/profile/650bed2c9ef54b5fb02c61fa493c68b5') 15 | .expectStatus(200) 16 | .expectHeaderContains('content-type', 'application/json') 17 | .expectJSON({ 18 | "id": "650bed2c9ef54b5fb02c61fa493c68b5", 19 | "name": "testPlayer", 20 | "properties": function (value) { 21 | expect(value).not.toBe(undefined); 22 | expect(value[0]).not.toBe(undefined); 23 | expect(value[0].name).toBe('textures'); 24 | textureValueValidator(value[0].value); 25 | signatureValidator(value[0].value, value[0].signature); 26 | } 27 | }) 28 | .expectJSONTypes({ 29 | "id": String, 30 | "name": String, 31 | "properties": function (value) { 32 | expect(typeof value).toBe('object'); 33 | expect(typeof value[0]).toBe('object'); 34 | expect(typeof value[0].name).toBe('string'); 35 | expect(typeof value[0].value).toBe('string'); 36 | expect(typeof value[0].signature).toBe('string'); 37 | } 38 | }) 39 | .toss(); 40 | 41 | frisby.create('Getting a valid UUID gives player data with cape') 42 | .get('http://localhost:' + httpPort + '/session/minecraft/profile/1294fda6159c4218be4c89b660d9cf32') 43 | .expectStatus(200) 44 | .expectHeaderContains('content-type', 'application/json') 45 | .expectJSON({ 46 | "id": "1294fda6159c4218be4c89b660d9cf32", 47 | "name": "testPlayerOld", 48 | "properties": function (value) { 49 | var properties = base64Decode(value[0].value); 50 | 51 | expect(typeof properties.textures.CAPE).toBe('object'); 52 | expect(typeof properties.textures.CAPE.url).toBe('string'); 53 | expect(properties.textures.CAPE.url).toBe('https://authserver.mojang.com/images/cape/mycape.png'); 54 | } 55 | }) 56 | .toss(); 57 | 58 | frisby.create('Getting a valid UUID gives no signature if we don\'t want it') 59 | .get('http://localhost:' + httpPort + '/session/minecraft/profile/650bed2c9ef54b5fb02c61fa493c68b5?unsigned=true') 60 | .expectStatus(200) 61 | .expectHeaderContains('content-type', 'application/json') 62 | .expectJSON({ 63 | "id": "650bed2c9ef54b5fb02c61fa493c68b5", 64 | "name": "testPlayer", 65 | "properties": function (value) { 66 | expect(typeof value[0].signature).toBe('undefined'); 67 | } 68 | }) 69 | .toss(); 70 | 71 | 72 | function textureValueValidator(value) { 73 | value = base64Decode(value); 74 | 75 | expect(typeof value).toBe('object'); 76 | 77 | expect(typeof value.timestamp).toBe('number'); 78 | expect(Math.abs(moment().unix() - value.timestamp)).toBeLessThan(60); 79 | 80 | expect(typeof value.profileId).toBe('string'); 81 | expect(value.profileId).toBe('650bed2c9ef54b5fb02c61fa493c68b5'); 82 | 83 | expect(typeof value.profileName).toBe('string'); 84 | expect(value.profileName).toBe('testPlayer'); 85 | 86 | expect(typeof value.isPublic).toBe('boolean'); 87 | expect(value.isPublic).toBe(true); 88 | 89 | expect(typeof value.textures).toBe('object'); 90 | expect(typeof value.textures.SKIN).toBe('object'); 91 | expect(typeof value.textures.SKIN.url).toBe('string'); 92 | expect(value.textures.SKIN.url).toBe('https://authserver.mojang.com/images/skin/steve.png'); 93 | 94 | return true; 95 | } 96 | 97 | function signatureValidator(value, signature) { 98 | var crt = fs.readFileSync('./cert/sessionserver/certificate.crt', 'utf8'); 99 | var verifier = crypto.createVerify('sha1WithRSAEncryption'); 100 | 101 | verifier.update(value); 102 | expect(verifier.verify(crt, signature, 'base64')).toBe(true); 103 | return true; 104 | } 105 | 106 | function base64Decode(str) { 107 | var buffer = new Buffer(str, 'base64'); 108 | 109 | try { 110 | return JSON.parse(buffer.toString('ascii')); 111 | } catch (err) { 112 | return null; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /test/session_hasJoined_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var moment = require('moment'); 4 | var crypto = require('crypto'); 5 | var fs = require('fs'); 6 | var httpPort = config.get('sessionserver.httpPort'); 7 | var syncTestRunner = require('./synchronousTestRunner'); 8 | 9 | frisby.create('Nothing gives empty response') 10 | .get('http://localhost:' + httpPort + '/session/minecraft/hasJoined') 11 | .expectStatus(200) 12 | .expectHeaderContains('content-type', 'application/json') 13 | .expectJSONLength(0) 14 | .toss(); 15 | 16 | frisby.create('Missing username gives empty response') 17 | .get('http://localhost:' + httpPort + '/session/minecraft/hasJoined?serverId=1234') 18 | .expectStatus(200) 19 | .expectHeaderContains('content-type', 'application/json') 20 | .expectJSONLength(0) 21 | .toss(); 22 | 23 | frisby.create('Missing serverId gives empty response') 24 | .get('http://localhost:' + httpPort + '/session/minecraft/hasJoined?username=test') 25 | .expectStatus(200) 26 | .expectHeaderContains('content-type', 'application/json') 27 | .expectJSONLength(0) 28 | .toss(); 29 | 30 | frisby.create('Invalid serverId gives empty response') 31 | .get('http://localhost:' + httpPort + '/session/minecraft/hasJoined?username=test&serverId=1234') 32 | .expectStatus(200) 33 | .expectHeaderContains('content-type', 'application/json') 34 | .expectJSONLength(0) 35 | .toss(); 36 | 37 | syncTestRunner.registerTest( 38 | frisby.create('Authenticating for session join') 39 | .post('http://localhost:' + httpPort + '/authenticate', { 40 | "agent": { 41 | "name": "Minecraft", 42 | "version": 1 43 | }, 44 | "username": "test", 45 | "password": "test" 46 | }) 47 | .afterJSON(function (response) { 48 | frisby.create('then sending a serverId with valid selectedProfile and accessToken gives no response') 49 | .post('http://localhost:' + httpPort + '/session/minecraft/join', { 50 | "accessToken": response.accessToken, 51 | "selectedProfile": response.selectedProfile.id, 52 | "serverId": "5555" 53 | }) 54 | .expectStatus(200) 55 | .expectHeaderContains('content-type', 'application/json') 56 | .expectJSONLength(0) 57 | .afterJSON(function () { 58 | frisby.create('then checking the has joined should be successful and returns the required data.') 59 | .get('http://localhost:' + httpPort + '/session/minecraft/hasJoined?username=' + response.selectedProfile.name + '&serverId=5555') 60 | .expectStatus(200) 61 | .expectHeaderContains('content-type', 'application/json') 62 | .expectJSON({ 63 | "id": "650bed2c9ef54b5fb02c61fa493c68b5", 64 | "name": "testPlayer", 65 | "properties": function (value) { 66 | expect(value).not.toBe(undefined); 67 | expect(value[0]).not.toBe(undefined); 68 | expect(value[0].name).toBe('textures'); 69 | textureValueValidator(value[0].value); 70 | signatureValidator(value[0].value, value[0].signature); 71 | } 72 | }) 73 | .expectJSONTypes({ 74 | "id": String, 75 | "name": String, 76 | "properties": function (value) { 77 | expect(typeof value).toBe('object'); 78 | expect(typeof value[0]).toBe('object'); 79 | expect(typeof value[0].name).toBe('string'); 80 | expect(typeof value[0].value).toBe('string'); 81 | expect(typeof value[0].signature).toBe('string'); 82 | } 83 | }) 84 | .after(function () { 85 | syncTestRunner.runNext(); 86 | }) 87 | .toss(); 88 | }) 89 | .toss(); 90 | }) 91 | ); 92 | 93 | 94 | function textureValueValidator(value) { 95 | value = base64Decode(value); 96 | 97 | expect(typeof value).toBe('object'); 98 | 99 | expect(typeof value.timestamp).toBe('number'); 100 | expect(Math.abs(moment().unix() - value.timestamp)).toBeLessThan(60); 101 | 102 | expect(typeof value.profileId).toBe('string'); 103 | expect(value.profileId).toBe('650bed2c9ef54b5fb02c61fa493c68b5'); 104 | 105 | expect(typeof value.textures).toBe('object'); 106 | expect(typeof value.textures.SKIN).toBe('object'); 107 | expect(typeof value.textures.SKIN.url).toBe('string'); 108 | expect(value.textures.SKIN.url).toBe('https://authserver.mojang.com/images/skin/steve.png'); 109 | 110 | return true; 111 | } 112 | 113 | function signatureValidator(value, signature) { 114 | var crt = fs.readFileSync('./cert/sessionserver/certificate.crt', 'utf8'); 115 | var verifier = crypto.createVerify('sha1WithRSAEncryption'); 116 | 117 | verifier.update(value); 118 | expect(verifier.verify(crt, signature, 'base64')).toBe(true); 119 | return true; 120 | } 121 | 122 | function base64Decode(str) { 123 | var buffer = new Buffer(str, 'base64'); 124 | 125 | try { 126 | return JSON.parse(buffer.toString('ascii')); 127 | } catch (err) { 128 | return null; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /test/signOut_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('authserver.httpPort'); 4 | var syncTestRunner = require('./synchronousTestRunner'); 5 | 6 | frisby.create('Nothing gives illegal argument error') 7 | .get('http://localhost:' + httpPort + '/signout') 8 | .expectStatus(200) 9 | .expectHeaderContains('content-type', 'application/json') 10 | .expectJSON({ 11 | "error": "IllegalArgumentException", 12 | "errorMessage": "Access Token can not be null or empty." 13 | }) 14 | .expectJSONTypes({ 15 | "error": String, 16 | "errorMessage": String 17 | }) 18 | .toss(); 19 | 20 | frisby.create('Invalid user gives exception') 21 | .post('http://localhost:' + httpPort + '/signout', { 22 | "username": "non-existent-user", 23 | "password": "random" 24 | }) 25 | .expectStatus(200) 26 | .expectHeaderContains('content-type', 'application/json') 27 | .expectJSON({ 28 | "error": "ForbiddenOperationException", 29 | "errorMessage": "Invalid credentials. Invalid username or password." 30 | }) 31 | .expectJSONTypes({ 32 | "error": String, 33 | "errorMessage": String 34 | }) 35 | .toss(); 36 | 37 | frisby.create('Empty password gives exception') 38 | .post('http://localhost:' + httpPort + '/signout', { 39 | "username": "test" 40 | }) 41 | .expectStatus(200) 42 | .expectHeaderContains('content-type', 'application/json') 43 | .expectJSON({ 44 | "error": "ForbiddenOperationException", 45 | "errorMessage": "Invalid credentials. Invalid username or password." 46 | }) 47 | .expectJSONTypes({ 48 | "error": String, 49 | "errorMessage": String 50 | }) 51 | .toss(); 52 | 53 | syncTestRunner.registerTest( 54 | frisby.create('Authenticating for signing out') 55 | .post('http://localhost:' + httpPort + '/authenticate', { 56 | "username": "test", 57 | "password": "test", 58 | "clientToken": "test-client-token" 59 | }) 60 | .afterJSON(function (response) { 61 | frisby.create('then logging out with invalid credentials do not invalidate the session') 62 | .post('http://localhost:' + httpPort + '/signout', { 63 | "username": "test", 64 | "password": "wrong-password" 65 | }) 66 | .expectStatus(200) 67 | .expectHeaderContains('content-type', 'application/json') 68 | .expectJSON({ 69 | "error": "ForbiddenOperationException", 70 | "errorMessage": "Invalid credentials. Invalid username or password." 71 | }) 72 | .expectJSONTypes({ 73 | "error": String, 74 | "errorMessage": String 75 | }) 76 | .after(function () { 77 | frisby.create('so validate accepts the accessToken') 78 | .post('http://localhost:' + httpPort + '/validate', { 79 | "accessToken": response.accessToken 80 | }) 81 | .expectStatus(200) 82 | .expectHeaderContains('content-type', 'application/json') 83 | .expectJSONLength(0) 84 | .after(function () { 85 | syncTestRunner.runNext(); 86 | }) 87 | .toss(); 88 | }) 89 | .toss(); 90 | }) 91 | ); 92 | 93 | syncTestRunner.registerTest( 94 | frisby.create('Authenticating for signing out') 95 | .post('http://localhost:' + httpPort + '/authenticate', { 96 | "username": "test", 97 | "password": "test", 98 | "clientToken": "test-client-token" 99 | }) 100 | .afterJSON(function (response) { 101 | frisby.create('then logging out with valid credentials invalidate the session') 102 | .post('http://localhost:' + httpPort + '/signout', { 103 | "username": "test", 104 | "password": "test" 105 | }) 106 | .expectStatus(200) 107 | .expectHeaderContains('content-type', 'application/json') 108 | .expectJSONLength(0) 109 | .after(function () { 110 | frisby.create('so validate rejects the accessToken') 111 | .post('http://localhost:' + httpPort + '/validate', { 112 | "accessToken": response.accessToken 113 | }) 114 | .expectStatus(200) 115 | .expectHeaderContains('content-type', 'application/json') 116 | .expectJSON({ 117 | "error": "ForbiddenOperationException", 118 | "errorMessage": "Invalid token" 119 | }) 120 | .expectJSONTypes({ 121 | "error": String, 122 | "errorMessage": String 123 | }) 124 | .after(function () { 125 | syncTestRunner.runNext(); 126 | }) 127 | .toss(); 128 | }) 129 | .toss(); 130 | }) 131 | ); 132 | -------------------------------------------------------------------------------- /test/synchronousTestRunner.js: -------------------------------------------------------------------------------- 1 | var tests = []; 2 | 3 | 4 | exports.registerTest = registerTest; 5 | function registerTest(test) { 6 | tests.push(test) 7 | } 8 | 9 | exports.runNext = runNext; 10 | function runNext() { 11 | if (!tests.length) { 12 | return; 13 | } 14 | 15 | tests.shift().toss(); 16 | } 17 | -------------------------------------------------------------------------------- /test/uuidToName_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('apiserver.httpPort'); 4 | 5 | frisby.create('Getting a non-existent UUID gives empty response') 6 | .get('http://localhost:' + httpPort + '/user/profiles/nonexistent/names') 7 | .expectStatus(204) 8 | .toss(); 9 | 10 | frisby.create('Getting a valid user gives userid and playername') 11 | .get('http://localhost:' + httpPort + '/user/profiles/650bed2c9ef54b5fb02c61fa493c68b5/names') 12 | .expectStatus(200) 13 | .expectHeaderContains('content-type', 'application/json') 14 | .expectJSON([{ 15 | "name": "testPlayer" 16 | }]) 17 | .expectJSONTypes([{ 18 | "name": String 19 | }]) 20 | .toss(); 21 | -------------------------------------------------------------------------------- /test/validate_spec.js: -------------------------------------------------------------------------------- 1 | var frisby = require('frisby'); 2 | var config = require('config'); 3 | var httpPort = config.get('authserver.httpPort'); 4 | var syncTestRunner = require('./synchronousTestRunner'); 5 | 6 | 7 | frisby.create('Nothing gives illegal argument error') 8 | .get('http://localhost:' + httpPort + '/validate') 9 | .expectStatus(200) 10 | .expectHeaderContains('content-type', 'application/json') 11 | .expectJSON({ 12 | "error": "IllegalArgumentException", 13 | "errorMessage": "Access Token can not be null or empty." 14 | }) 15 | .expectJSONTypes({ 16 | "error": String, 17 | "errorMessage": String 18 | }) 19 | .toss(); 20 | 21 | frisby.create('Invalid access token gives exception') 22 | .post('http://localhost:' + httpPort + '/validate', { 23 | "accessToken": "nonexistent" 24 | }) 25 | .expectStatus(200) 26 | .expectHeaderContains('content-type', 'application/json') 27 | .expectJSON({ 28 | "error": "ForbiddenOperationException", 29 | "errorMessage": "Invalid token" 30 | }) 31 | .expectJSONTypes({ 32 | "error": String, 33 | "errorMessage": String 34 | }) 35 | .toss(); 36 | 37 | frisby.create('Old login returns exception') 38 | .post('http://localhost:' + httpPort + '/validate', { 39 | "username": "testOld", 40 | "password": "test", 41 | "accessToken": "d41d8cd98f00b204e9800998ecf8427e" 42 | }) 43 | .expectStatus(200) 44 | .expectHeaderContains('content-type', 'application/json') 45 | .expectJSON({ 46 | "error": "ForbiddenOperationException", 47 | "errorMessage": "Invalid token" 48 | }) 49 | .expectJSONTypes({ 50 | "error": String, 51 | "errorMessage": String 52 | }) 53 | .toss(); 54 | 55 | syncTestRunner.registerTest( 56 | frisby.create('After authentication') 57 | .post('http://localhost:' + httpPort + '/authenticate', { 58 | "username": "test", 59 | "password": "test", 60 | "clientToken": "test-client-token" 61 | }) 62 | .afterJSON(function (response) { 63 | frisby.create('the validate accepts the accessToken') 64 | .post('http://localhost:' + httpPort + '/validate', { 65 | "accessToken": response.accessToken 66 | }) 67 | .expectStatus(200) 68 | .expectHeaderContains('content-type', 'application/json') 69 | .expectJSONLength(0) 70 | .after(function () { 71 | syncTestRunner.runNext(); 72 | }) 73 | .toss(); 74 | }) 75 | ); 76 | 77 | syncTestRunner.runNext(); --------------------------------------------------------------------------------