Android Open Source - PasswordDroid Customizable






From Project

Back to project page PasswordDroid.

License

The source code is released under:

GNU General Public License

If you think the Android project PasswordDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.wuthoehle.passworddroid.service.model.entries;
//from w  w  w. ja  v  a2  s . c  om
/* Copyright (c) 2015 Marco Huenseler <marcoh.huenseler+git@gmail.com>
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

public class Customizable implements EntryElement {
    public static final byte ID_UPPER_CASE = 1;
    public static final byte ID_LOWER_CASE = 2;
    public static final byte ID_NUMBERS = 4;
    public static final byte ID_SPECIAL = 8;

    public static final String CHARACTERS_UPPER_CASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    public static final String CHARACTERS_LOWER_CASE = "abcdefghijklmnopqrstuvwxyz";
    public static final String CHARACTERS_NUMBERS = "0123456789";
    public static final String CHARACTERS_SPECIAL = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";

    private Entry parent;
    private String characters;
    private String ud_characters;
    private int length;
    private byte mask;

    public Customizable(Entry parent, byte mask, String ud_characters, int length) {
        this.parent = parent;
        this.mask = mask;
        setCharacters(mask);
        setCharacters(ud_characters);
        this.length = length;
        this.parent.setPassword_known(false);
    }

    public Customizable(Entry parent, byte mask, int length) {
        this(parent, mask, "", length);
    }

    public String getCharacters() {
        return this.characters + this.ud_characters;
    }

    public void setCharacters(byte mask) {
        String characters = "";

        // 1-bit is set
        if ((mask & 0b1) == ID_UPPER_CASE) {
            characters += CHARACTERS_UPPER_CASE;
        }

        // 2-bit is set
        if ((mask & 0b10) == ID_LOWER_CASE) {
            characters += CHARACTERS_LOWER_CASE;
        }

        // 4-bit is set
        if ((mask & 0b100) == ID_NUMBERS) {
            characters += CHARACTERS_NUMBERS;
        }

        // 8-bit is set
        if ((mask & 0b1000) == ID_SPECIAL) {
            characters += CHARACTERS_SPECIAL;
        }

        this.characters = characters;
        this.parent.setPassword_known(false);
    }

    public String getAdditionalCharacters() {
        return this.ud_characters;
    }

    public void setCharacters(String characters) {
        this.ud_characters = characters;
        this.parent.setPassword_known(false);
    }

    public int getLength() {
        return this.length;
    }

    public void setLength(int length) {
        this.length = length;
        parent.setPassword_known(false);
    }

    public byte getMask() {
        return this.mask;
    }

    public void setMask(byte mask) {
        this.mask = mask;
        setCharacters(mask);
        parent.setPassword_known(false);
    }

    @Override
    public void accept(EntryVisitor visitor) {
        visitor.visit(this);
    }
}




Java Source Code List

com.lambdaworks.crypto.PBKDF.java
com.lambdaworks.crypto.SCrypt.java
de.wuthoehle.passworddroid.ApplicationTest.java
de.wuthoehle.passworddroid.PasswordDerivateActivity.java
de.wuthoehle.passworddroid.crypto.AESprng.java
de.wuthoehle.passworddroid.crypto.DerivationRunnableFactory.java
de.wuthoehle.passworddroid.crypto.Util.java
de.wuthoehle.passworddroid.crypto.SCryptParameters.SCryptParametersFactory.java
de.wuthoehle.passworddroid.crypto.SCryptParameters.SCryptParameters.java
de.wuthoehle.passworddroid.service.PasswordDroidService.java
de.wuthoehle.passworddroid.service.model.Category.java
de.wuthoehle.passworddroid.service.model.Container.java
de.wuthoehle.passworddroid.service.model.Database.java
de.wuthoehle.passworddroid.service.model.DerivatorCategory.java
de.wuthoehle.passworddroid.service.model.DerivatorDatabase.java
de.wuthoehle.passworddroid.service.model.FileFormat.java
de.wuthoehle.passworddroid.service.model.entries.Commentable.java
de.wuthoehle.passworddroid.service.model.entries.Countable.java
de.wuthoehle.passworddroid.service.model.entries.Customizable.java
de.wuthoehle.passworddroid.service.model.entries.DerivatorEntry.java
de.wuthoehle.passworddroid.service.model.entries.EntryElement.java
de.wuthoehle.passworddroid.service.model.entries.EntryFactory.java
de.wuthoehle.passworddroid.service.model.entries.EntryVisitor.java
de.wuthoehle.passworddroid.service.model.entries.Entry.java
de.wuthoehle.passworddroid.service.model.entries.GetBundleVisitor.java
de.wuthoehle.passworddroid.service.model.entries.SaltVisitor.java
de.wuthoehle.passworddroid.service.model.entries.Saltable.java
de.wuthoehle.passworddroid.service.model.entries.WriteVisitor.java