From 0e07f47d6f448b68fe87fa5acecccebb0dcc62c4 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Mon, 18 Nov 2013 09:47:53 +0000 Subject: [PATCH] Removed tmp js examples --- examples/js/index.html | 25 -------- examples/js/keycloak.js | 126 ------------------------------------- examples/js/testrealm.json | 60 ------------------ 3 files changed, 211 deletions(-) delete mode 100644 examples/js/index.html delete mode 100644 examples/js/keycloak.js delete mode 100755 examples/js/testrealm.json diff --git a/examples/js/index.html b/examples/js/index.html deleted file mode 100644 index 4a7b8d27958..00000000000 --- a/examples/js/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - diff --git a/examples/js/keycloak.js b/examples/js/keycloak.js deleted file mode 100644 index 39cad7788f1..00000000000 --- a/examples/js/keycloak.js +++ /dev/null @@ -1,126 +0,0 @@ -window.keycloak = (function () { - var kc = {}; - var config = { - baseUrl: null, - clientId: null, - clientSecret: null, - realm: null, - redirectUri: null - }; - - kc.init = function (c) { - for (var prop in config) { - if (c[prop]) { - config[prop] = c[prop]; - } - - if (!config[prop]) { - throw new Error(prop + 'not defined'); - } - } - - if (!processCallback()) { - window.location.href = getLoginUrl() + '&prompt=none'; - } - } - - kc.login = function () { - window.location.href = getLoginUrl(); - } - - return kc; - - function getLoginUrl(fragment) { - var state = createUUID(); - if (fragment) { - state += '#' + fragment; - } - sessionStorage.state = state; - var url = config.baseUrl + '/rest/realms/' + encodeURIComponent(config.realm) + '/tokens/login?response_type=code&client_id=' - + encodeURIComponent(config.clientId) + '&redirect_uri=' + encodeURIComponent(config.redirectUri) + '&state=' + encodeURIComponent(state); - return url; - } - - function parseToken(token) { - return JSON.parse(atob(token.split('.')[1])); - } - - function processCallback() { - var code = getQueryParam('code'); - var error = getQueryParam('error'); - var state = getQueryParam('state'); - - if (!(code || error)) { - return false; - } - - if (state != sessionStorage.state) { - console.error('Invalid state'); - return true; - } - - if (code) { - console.info('Received code'); - - var clientId = encodeURIComponent(config.clientId); - var clientSecret = encodeURIComponent(config.clientSecret); - var realm = encodeURIComponent(config.realm); - - var params = 'code=' + code + '&client_id=' + clientId + '&password=' + clientSecret; - var url = config.baseUrl + '/rest/realms/' + realm + '/tokens/access/codes' - - var http = new XMLHttpRequest(); - http.open('POST', url, false); - http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); - - http.send(params); - if (http.status == 200) { - kc.token = JSON.parse(http.responseText)['access_token']; - kc.tokenParsed = parseToken(kc.token); - kc.authenticated = true; - kc.user = kc.tokenParsed.prn; - - console.info('Authenticated'); - } - - updateLocation(state); - return true; - } else if (error) { - console.info('Error ' + error); - updateLocation(state); - return true; - } - } - - function updateLocation(state) { - var fragment = ''; - if (state && state.indexOf('#') != -1) { - fragment = state.substr(state.indexOf('#')); - } - - window.history.replaceState({}, document.title, location.protocol + "//" + location.host + location.pathname + fragment); - } - - function getQueryParam(name) { - var params = window.location.search.substring(1).split('&'); - for (var i = 0; i < params.length; i++) { - var p = params[i].split('='); - if (decodeURIComponent(p[0]) == name) { - return p[1]; - } - } - } - - function createUUID() { - var s = []; - var hexDigits = '0123456789abcdef'; - for (var i = 0; i < 36; i++) { - s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); - } - s[14] = '4'; - s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); - s[8] = s[13] = s[18] = s[23] = '-'; - var uuid = s.join(''); - return uuid; - } -})(); \ No newline at end of file diff --git a/examples/js/testrealm.json b/examples/js/testrealm.json deleted file mode 100755 index ee723000390..00000000000 --- a/examples/js/testrealm.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "id": "test", - "realm": "test", - "enabled": true, - "tokenLifespan": 300, - "accessCodeLifespan": 10, - "accessCodeLifespanUserAction": 600, - "sslNotRequired": true, - "cookieLoginAllowed": true, - "registrationAllowed": true, - "accountManagement": true, - "resetPasswordAllowed": true, - "privateKey": "MIICXAIBAAKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQABAoGAfmO8gVhyBxdqlxmIuglbz8bcjQbhXJLR2EoS8ngTXmN1bo2L90M0mUKSdc7qF10LgETBzqL8jYlQIbt+e6TH8fcEpKCjUlyq0Mf/vVbfZSNaVycY13nTzo27iPyWQHK5NLuJzn1xvxxrUeXI6A2WFpGEBLbHjwpx5WQG9A+2scECQQDvdn9NE75HPTVPxBqsEd2z10TKkl9CZxu10Qby3iQQmWLEJ9LNmy3acvKrE3gMiYNWb6xHPKiIqOR1as7L24aTAkEAtyvQOlCvr5kAjVqrEKXalj0Tzewjweuxc0pskvArTI2Oo070h65GpoIKLc9jf+UA69cRtquwP93aZKtW06U8dQJAF2Y44ks/mK5+eyDqik3koCI08qaC8HYq2wVl7G2QkJ6sbAaILtcvD92ToOvyGyeE0flvmDZxMYlvaZnaQ0lcSQJBAKZU6umJi3/xeEbkJqMfeLclD27XGEFoPeNrmdx0q10Azp4NfJAY+Z8KRyQCR2BEG+oNitBOZ+YXF9KCpH3cdmECQHEigJhYg+ykOvr1aiZUMFT72HU0jnmQe2FVekuG+LJUt2Tm7GtMjTFoGpf0JwrVuZN39fOYAlo+nTixgeW7X8Y=", - "publicKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB", - "requiredCredentials": [ "password" ], - "requiredApplicationCredentials": [ "password" ], - "requiredOAuthClientCredentials": [ "password" ], - "defaultRoles": [ "user" ], - "users" : [ - { - "username" : "test-user@localhost", - "enabled": true, - "email" : "test-user@localhost", - "credentials" : [ - { "type" : "password", - "value" : "password" } - ] - } - ], - "roles": [ - { - "name": "user", - "description": "Have User privileges" - }, - { - "name": "admin", - "description": "Have Administrator privileges" - } - ], - "roleMappings": [ - { - "username": "test-user@localhost", - "roles": ["user"] - } - ], - "applications": [ - { - "name": "test-app", - "enabled": true, - "adminUrl": "http://localhost:8081/app/logout", - "webOrigins": [ "http://localhost", "http://localhost:8000", "http://localhost:8080" ], - "credentials": [ - { - "type": "password", - "value": "password" - } - ] - } - ] -}