Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
feat(policy): add password min symbols policy pattern
Browse files Browse the repository at this point in the history
Signed-off-by: Rafa Hernandez <rhernandez@teclib.com>
  • Loading branch information
rafaelje authored and ajsb85 committed May 18, 2018
1 parent aa010f1 commit dd68b39
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 26 deletions.
@@ -0,0 +1,54 @@
package org.flyve.mdm.agent.policies;

import android.content.Context;

import org.flyve.mdm.agent.services.PoliciesDeviceManager;
import org.flyve.mdm.agent.utils.FlyveLog;

/*
* Copyright © 2018 Teclib. All rights reserved.
*
* This file is part of flyve-mdm-android
*
* flyve-mdm-android is a subproject of Flyve MDM. Flyve MDM is a mobile
* device management software.
*
* Flyve MDM is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* Flyve MDM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ------------------------------------------------------------------------------
* @author rafael hernandez
* @date 15/5/18
* @copyright Copyright © 2018 Teclib. All rights reserved.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/flyve-mdm/flyve-mdm-android
* @link https://flyve-mdm.com
* ------------------------------------------------------------------------------
*/

public class PasswordMinSymbolsPolicy extends BasePolicies {

private static final String POLICY_NAME = "passwordMinSymbols";

public PasswordMinSymbolsPolicy(Context context) {
super(context, POLICY_NAME);
}

@Override
protected boolean process() {
try {
int minimum = Integer.parseInt(this.policyValue.toString());
new PoliciesDeviceManager(context).setPasswordMinimumSymbols(minimum);
return true;
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
return false;
}
}
}
Expand Up @@ -56,6 +56,7 @@
import org.flyve.mdm.agent.policies.PasswordMinLowerCasePolicy;
import org.flyve.mdm.agent.policies.PasswordMinNonLetterPolicy;
import org.flyve.mdm.agent.policies.PasswordMinNumericPolicy;
import org.flyve.mdm.agent.policies.PasswordMinSymbolsPolicy;
import org.flyve.mdm.agent.policies.PasswordMinUpperCasePolicy;
import org.flyve.mdm.agent.policies.PasswordQualityPolicy;
import org.flyve.mdm.agent.policies.RoamingPolicy;
Expand Down Expand Up @@ -722,7 +723,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception {
String taskId = jsonObj.getString("taskId");

// execute the policy
policiesController.passwordMinSymbols(taskId, minimum, priority);
PasswordMinSymbolsPolicy passwordMinSymbolsPolicy = new PasswordMinSymbolsPolicy(getApplicationContext());
passwordMinSymbolsPolicy.setMQTTparameters(this.client, topic, taskId);
passwordMinSymbolsPolicy.setValue(minimum);
passwordMinSymbolsPolicy.setPriority(priority);
passwordMinSymbolsPolicy.execute();

}
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());
Expand Down
Expand Up @@ -399,31 +399,6 @@ public void removeFile(String taskId, String removeFile) {
}
}

public void passwordMinSymbols(String taskId, int minimum, int priority) {
try {
// Set on database and get priority value
Object priorityValue = cache.setPasswordMinimumSymbols(minimum, priority);

// check Priority
if(priorityValue!=null) {
minimum = Integer.parseInt(priorityValue.toString());
}

// Execute the policy
PoliciesDeviceManager mdm = new PoliciesDeviceManager(this.context);
mdm.setPasswordMinimumSymbols(minimum);
broadcastReceivedLog(Helpers.broadCastMessage(MQTT_SEND, "passwordMinSymbols", String.valueOf(minimum)));

// return the status of the task
sendTaskStatus(taskId, FEEDBACK_DONE);
} catch (Exception ex) {
FlyveLog.e(ex.getMessage());

// return the status of the task
sendTaskStatus(taskId, FEEDBACK_FAILED);
}
}

public void maximumFailedPasswordsForWipe(String taskId, int maximum, int priority) {
try {
// Set on database and get priority value
Expand Down

0 comments on commit dd68b39

Please sign in to comment.