Skip to content

Commit

Permalink
Merge pull request #3 from WBerredo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
WBerredo committed Dec 31, 2015
2 parents c620a19 + 55ff88e commit a3a65f9
Show file tree
Hide file tree
Showing 8 changed files with 521 additions and 41 deletions.
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties


7 changes: 7 additions & 0 deletions js/clipboard.js/clipboard.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 82 additions & 24 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,107 @@
/**
* Created by berredo on 11/5/15.
*/
var b64pad = "=";
var b64pad = "=";
var randomLength = 10;

var inputs = ['username', 'password', 'created', 'nonce'];
var username = document.getElementById('username');
var password = document.getElementById('password');
var created = document.getElementById('created');
var nonce = document.getElementById('nonce');

var checks = ['autodate', 'autononce', 'autoMD5'];
var autodate = document.getElementById('autodate');
var autononce = document.getElementById('autononce');
var autoMD5 = document.getElementById('autoMD5');

var result = document.getElementById('result');
clipResult = new Clipboard('#generateBtn');

document.getElementById('generateBtn').addEventListener('click', function generate() {
if (autononce.checked) {
nonce.value = getRandomText(randomLength);
}
document.addEventListener('DOMContentLoaded', function () {
getLastData();

if(autodate.checked) {
created.value = getW3CDate(new Date());
}
// save last data on inputs
inputs.forEach(function (input) {
var inputElement = window[input];

var encodedNonce = base64encode(nonce.value);
var passwordDigest = b64_sha1(nonce.value + created.value + password.value);
inputElement.addEventListener('change', function () {
saveLastData(event)
});
});

result.value = "X-WSSE: UsernameToken Username=\""
+ username.value + "\", PasswordDigest=\""
+ passwordDigest + "\", Nonce=\""
+ encodedNonce + "\", Created=\""
+ created.value + "\"\n";
// save last data on checkboxes
checks.forEach(function (check) {
var checkElement = window[check];

saveLastHeader();
});
checkElement.addEventListener('change', function () {
saveLastData(event);
});
});


// generate a header
document.getElementById('generateBtn').addEventListener('click', function generate() {
var changeEvt = document.createEvent("HTMLEvents");
changeEvt.initEvent("change", false, true);

if (autononce.checked) {
nonce.value = getRandomText(randomLength);
nonce.dispatchEvent(changeEvt);
}

if (autodate.checked) {
created.value = getW3CDate(new Date());
created.dispatchEvent(changeEvt);
}

var encodedNonce = base64encode(nonce.value);

var passwordDigest;

if(autoMD5.checked){
passwordDigest = b64_sha1(nonce.value + created.value + toMd5(password.value));
}else{
passwordDigest = b64_sha1(nonce.value + created.value + password.value);
}


result.value = "X-WSSE: UsernameToken Username=\""
+ username.value + "\", PasswordDigest=\""
+ passwordDigest + "\", Nonce=\""
+ encodedNonce + "\", Created=\""
+ created.value + "\"\n";
});

document.addEventListener('DOMContentLoaded', function () {
//alert(1);
});

function saveLastHeader() {
localStorage['username'] = username.value;
localStorage['password'] = password.value;
localStorage['created'] = created.value;
localStorage['nonce'] = nonce.value;
function getLastData() {
inputs.forEach(function (input) {
var inputElement = window[input];

if (localStorage[input]) {
inputElement.value = localStorage[input];
}
});

checks.forEach(function (check) {
var checkElement = window[check];

if (localStorage[check] == "true") {
checkElement.checked = true;
}
});
}

function saveLastData(e) {
if (e.srcElement.value) {
var value;

if (e.srcElement.type == 'text' || e.srcElement.type == 'password') {
value = e.srcElement.value;
} else if (e.srcElement.type == 'checkbox') {
value = e.srcElement.checked;
}
localStorage[e.srcElement.id] = value;
}
}
Loading

0 comments on commit a3a65f9

Please sign in to comment.