Revision 47450
Added by Antonis Lempesis almost 7 years ago
modules/uoa-validator-admin/trunk/deploy.info | ||
---|---|---|
1 |
{ |
|
2 |
"type_source": "SVN", |
|
3 |
"goal": "package -U -T 4C source:jar", |
|
4 |
"url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-validator-admin/trunk", |
|
5 |
"deploy_repository": "dnet4-snapshots", |
|
6 |
"version": "4", |
|
7 |
"mail": "nikonas@di.uoa.gr, antleb@di.uoa.gr, kiatrop@di.uoa.gr", |
|
8 |
"deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", |
|
9 |
"name": "uoa-validator-admin" |
|
10 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/users/EditUser.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.users; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
import org.apache.struts2.interceptor.SessionAware; |
|
7 |
|
|
8 |
import com.opensymphony.xwork2.Action; |
|
9 |
|
|
10 |
import eu.dnetlib.domain.functionality.UserProfile; |
|
11 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
12 |
import eu.dnetlib.validator.admin.config.Constants; |
|
13 |
|
|
14 |
public class EditUser extends BaseValidatorAction implements SessionAware { |
|
15 |
|
|
16 |
private static final long serialVersionUID = -362061491263257713L; |
|
17 |
private Logger logger = Logger.getLogger(EditUser.class); |
|
18 |
|
|
19 |
private UserProfile user; |
|
20 |
|
|
21 |
private Map<String, Object> session; |
|
22 |
|
|
23 |
public String execute() { |
|
24 |
this.clearErrorsAndMessages(); |
|
25 |
try { |
|
26 |
logger.debug("getting for edit user " + (String) session.get(Constants.loggedInField)); |
|
27 |
user = this.getUserAPI().getUser((String) session.get(Constants.loggedInField)); |
|
28 |
return Action.SUCCESS; |
|
29 |
} catch (Exception e) { |
|
30 |
logger.error("error getting for edit user " + (String) session.get(Constants.loggedInField), e); |
|
31 |
this.addActionError(this.getText("generic.error")); |
|
32 |
reportException(e); |
|
33 |
return "exception"; |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
public String edit() { |
|
38 |
this.clearErrorsAndMessages(); |
|
39 |
try { |
|
40 |
logger.debug("editing user " + (String) session.get(Constants.loggedInField)); |
|
41 |
this.getUserAPI().editUser(user); |
|
42 |
this.addActionMessage(this.getText("editUser.success")); |
|
43 |
return Action.SUCCESS; |
|
44 |
} catch (Exception e) { |
|
45 |
logger.error("error editing user " + (String) session.get(Constants.loggedInField), e); |
|
46 |
this.addActionError(this.getText("generic.error")); |
|
47 |
reportException(e); |
|
48 |
return "exception"; |
|
49 |
} |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
|
|
54 |
public UserProfile getUser() { |
|
55 |
return user; |
|
56 |
} |
|
57 |
|
|
58 |
public void setUser(UserProfile user) { |
|
59 |
this.user = user; |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public void setSession(Map<String, Object> session) { |
|
64 |
this.session = session; |
|
65 |
} |
|
66 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/users/Register.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.users; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.regex.Pattern; |
|
5 |
|
|
6 |
import org.apache.log4j.Logger; |
|
7 |
|
|
8 |
import com.opensymphony.xwork2.Action; |
|
9 |
|
|
10 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
11 |
|
|
12 |
public class Register extends BaseValidatorAction { |
|
13 |
|
|
14 |
private static final long serialVersionUID = 4906485913149844710L; |
|
15 |
private Logger logger = Logger.getLogger(Register.class); |
|
16 |
|
|
17 |
private String email, password, repassword; |
|
18 |
private String username, firstName, lastName, institution; |
|
19 |
|
|
20 |
public String execute() { |
|
21 |
this.clearErrorsAndMessages(); |
|
22 |
try { |
|
23 |
logger.debug("registering user " + email); |
|
24 |
String activationId = null; |
|
25 |
|
|
26 |
activationId = this.getUserAPI().addUser(username, email, password, firstName, lastName, institution); |
|
27 |
|
|
28 |
this.addActionMessage((this.getText("registration.successful"))); |
|
29 |
this.addActionMessage((this.getText("general.unblock") + " " + this.getEmailer().getFrom())); |
|
30 |
|
|
31 |
ArrayList<String> to = new ArrayList<String>(); |
|
32 |
to.add(this.getEmail()); |
|
33 |
|
|
34 |
this.getEmailer().sendMail(to, this.getText("registration.mail.subject"), this.getText("registration.mail.message") + ": " + this.getValBaseUrl() + "/activateAccount.action?activationId=" + activationId, false, null); |
|
35 |
|
|
36 |
return Action.SUCCESS; |
|
37 |
} catch (Exception e) { |
|
38 |
logger.error("error registering user " + email, e); |
|
39 |
this.addActionError(this.getText("generic.error")); |
|
40 |
reportException(e); |
|
41 |
return "exception"; |
|
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
public void validate() { |
|
46 |
this.clearErrors(); |
|
47 |
if (this.getEmail() == null || this.getEmail().length() == 0) |
|
48 |
this.addFieldError("email", this.getText("compulsoryField")); |
|
49 |
if (this.getPassword() == null || this.getPassword().length() == 0) |
|
50 |
this.addFieldError("password", this.getText("compulsoryField")); |
|
51 |
if (this.getRepassword() == null || this.getRepassword().length() == 0) |
|
52 |
this.addFieldError("repassword", this.getText("compulsoryField")); |
|
53 |
if (this.getUsername() == null || this.getUsername().length() == 0) |
|
54 |
this.addFieldError("username", this.getText("compulsoryField")); |
|
55 |
if (this.getFirstName() == null || this.getFirstName().length() == 0) |
|
56 |
this.addFieldError("firstName", this.getText("compulsoryField")); |
|
57 |
if (this.getLastName() == null || this.getLastName().length() == 0) |
|
58 |
this.addFieldError("lastName", this.getText("compulsoryField")); |
|
59 |
|
|
60 |
if (!this.getPassword().equals(this.getRepassword())) |
|
61 |
this.addFieldError("password", this.getText("identicalPasswords")); |
|
62 |
|
|
63 |
Pattern rfc2822 = Pattern.compile("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"); |
|
64 |
if (!rfc2822.matcher(this.getEmail().trim().toLowerCase()).matches()) { |
|
65 |
this.addFieldError("email", this.getText("notValidEmail")); |
|
66 |
} |
|
67 |
|
|
68 |
try { |
|
69 |
if (this.getUserAPI().userExists(this.getEmail())) |
|
70 |
this.addFieldError("email", this.getText("userAlreadyExists")); |
|
71 |
if (this.getUserAPI().usernameExists(this.getUsername())) |
|
72 |
this.addFieldError("username", this.getText("userAlreadyExists")); |
|
73 |
|
|
74 |
} catch (Exception e) { |
|
75 |
this.addFieldError("email", this.getText("userAlreadyExists")); |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
public String getEmail() { |
|
80 |
return email; |
|
81 |
} |
|
82 |
|
|
83 |
public void setEmail(String email) { |
|
84 |
this.email = email; |
|
85 |
} |
|
86 |
|
|
87 |
public String getPassword() { |
|
88 |
return password; |
|
89 |
} |
|
90 |
|
|
91 |
public void setPassword(String password) { |
|
92 |
this.password = password; |
|
93 |
} |
|
94 |
|
|
95 |
public String getRepassword() { |
|
96 |
return repassword; |
|
97 |
} |
|
98 |
|
|
99 |
public void setRepassword(String repassword) { |
|
100 |
this.repassword = repassword; |
|
101 |
} |
|
102 |
|
|
103 |
public String getUsername() { |
|
104 |
return username; |
|
105 |
} |
|
106 |
|
|
107 |
public void setUsername(String username) { |
|
108 |
this.username = username; |
|
109 |
} |
|
110 |
|
|
111 |
public String getFirstName() { |
|
112 |
return firstName; |
|
113 |
} |
|
114 |
|
|
115 |
public void setFirstName(String firstName) { |
|
116 |
this.firstName = firstName; |
|
117 |
} |
|
118 |
|
|
119 |
public String getLastName() { |
|
120 |
return lastName; |
|
121 |
} |
|
122 |
|
|
123 |
public void setLastName(String lastName) { |
|
124 |
this.lastName = lastName; |
|
125 |
} |
|
126 |
|
|
127 |
public String getInstitution() { |
|
128 |
return institution; |
|
129 |
} |
|
130 |
|
|
131 |
public void setInstitution(String institution) { |
|
132 |
this.institution = institution; |
|
133 |
} |
|
134 |
|
|
135 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/users/ActivateAccount.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.users; |
|
2 |
|
|
3 |
import org.apache.log4j.Logger; |
|
4 |
|
|
5 |
import com.opensymphony.xwork2.Action; |
|
6 |
|
|
7 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
8 |
|
|
9 |
public class ActivateAccount extends BaseValidatorAction { |
|
10 |
|
|
11 |
private static final long serialVersionUID = 4680016183168923054L; |
|
12 |
private Logger logger = Logger.getLogger(ActivateAccount.class); |
|
13 |
|
|
14 |
private String activationId; |
|
15 |
|
|
16 |
public String execute() { |
|
17 |
this.clearErrorsAndMessages(); |
|
18 |
try { |
|
19 |
logger.debug("activating user account with activation id " + activationId); |
|
20 |
if (this.getUserAPI().activateUser(this.getActivationId())) |
|
21 |
this.addActionMessage(this.getText("registration.okAccountActivation")); |
|
22 |
else |
|
23 |
this.addActionMessage(this.getText("registration.okAccountAlreadyActivation")); |
|
24 |
return Action.SUCCESS; |
|
25 |
} catch (Exception e) { |
|
26 |
logger.error("error activating user account with activation id " + activationId, e); |
|
27 |
this.addActionError(this.getText("generic.error")); |
|
28 |
reportException(e); |
|
29 |
return "exception"; |
|
30 |
} |
|
31 |
} |
|
32 |
|
|
33 |
public void validate() { |
|
34 |
this.clearErrors(); |
|
35 |
if (this.getActivationId() == null || this.getActivationId().length() == 0) { |
|
36 |
this.addActionError(this.getText("noActivationId")); |
|
37 |
return; |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 |
public String getActivationId() { |
|
42 |
return activationId; |
|
43 |
} |
|
44 |
|
|
45 |
public void setActivationId(String activationId) { |
|
46 |
this.activationId = activationId; |
|
47 |
} |
|
48 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/rulesets/DeleteRuleSet.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.rulesets; |
|
2 |
|
|
3 |
|
|
4 |
import org.apache.log4j.Logger; |
|
5 |
|
|
6 |
import com.opensymphony.xwork2.Action; |
|
7 |
|
|
8 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
9 |
|
|
10 |
public class DeleteRuleSet extends BaseValidatorAction { |
|
11 |
|
|
12 |
private static final long serialVersionUID = 4858147485197818532L; |
|
13 |
private int setId; |
|
14 |
private static final Logger logger = Logger.getLogger(DeleteRuleSet.class); |
|
15 |
|
|
16 |
public int getSetId() { |
|
17 |
return setId; |
|
18 |
} |
|
19 |
|
|
20 |
public void setSetId(int setId) { |
|
21 |
this.setId = setId; |
|
22 |
} |
|
23 |
|
|
24 |
public String execute() { |
|
25 |
this.clearErrorsAndMessages(); |
|
26 |
try { |
|
27 |
logger.debug("deleting rule set "+setId); |
|
28 |
this.getValidatorAdminAPI().deleteRuleSet(setId); |
|
29 |
this.addActionMessage(this.getText("deleteRuleSet.success")); |
|
30 |
return Action.SUCCESS; |
|
31 |
} |
|
32 |
catch(Exception e) { |
|
33 |
logger.error("Error deleting ruleset", e); |
|
34 |
this.addActionError(this.getText("generic.error")); |
|
35 |
reportException(e); |
|
36 |
return "exception"; |
|
37 |
} |
|
38 |
} |
|
39 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/rulesets/GetRuleSets.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.rulesets; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
8 |
|
|
9 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
|
10 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
11 |
|
|
12 |
public class GetRuleSets extends BaseValidatorAction { |
|
13 |
|
|
14 |
private static final long serialVersionUID = -5220242100308666597L; |
|
15 |
private List<RuleSet> sets; |
|
16 |
private static final Logger logger = Logger.getLogger(GetRuleSets.class); |
|
17 |
|
|
18 |
public List<RuleSet> getSets() { |
|
19 |
return sets; |
|
20 |
} |
|
21 |
|
|
22 |
public void setSets(List<RuleSet> sets) { |
|
23 |
this.sets = sets; |
|
24 |
} |
|
25 |
|
|
26 |
public String execute() throws Exception { |
|
27 |
this.clearErrorsAndMessages(); |
|
28 |
try { |
|
29 |
logger.debug("getting all rule sets"); |
|
30 |
sets = this.getValidatorAdminAPI().getRuleSets(); |
|
31 |
return Action.SUCCESS; |
|
32 |
} catch (Exception e) { |
|
33 |
logger.error("Error getting rule sets", e); |
|
34 |
this.addActionError(this.getText("generic.error")); |
|
35 |
reportException(e); |
|
36 |
return "exception"; |
|
37 |
} |
|
38 |
} |
|
39 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/rulesets/CreateRuleSet.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.rulesets; |
|
2 |
|
|
3 |
import java.util.Set; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
8 |
|
|
9 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
|
10 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
11 |
|
|
12 |
public class CreateRuleSet extends BaseValidatorAction { |
|
13 |
|
|
14 |
private static final long serialVersionUID = 5623461974078831740L; |
|
15 |
|
|
16 |
private Set<Integer> chosenContentRules = null; |
|
17 |
private Set<Integer> chosenUsageRules = null; |
|
18 |
private String funct = null; |
|
19 |
private RuleSet ruleSet; |
|
20 |
private static final Logger logger = Logger.getLogger(CreateRuleSet.class); |
|
21 |
|
|
22 |
public String execute() { |
|
23 |
this.clearErrorsAndMessages(); |
|
24 |
try { |
|
25 |
logger.debug("creating a new rule set "+ruleSet.getName()); |
|
26 |
ruleSet.setUsageRulesIds(chosenUsageRules); |
|
27 |
ruleSet.setContentRulesIds(chosenContentRules); |
|
28 |
if(funct.equals("create")) { |
|
29 |
this.getValidatorAdminAPI().storeRuleSet(ruleSet, false); |
|
30 |
this.addActionMessage(this.getText("createRuleSet.success")); |
|
31 |
} |
|
32 |
else if(funct.equals("edit")) { |
|
33 |
logger.debug("chosen content: " + chosenContentRules); |
|
34 |
this.getValidatorAdminAPI().storeRuleSet(ruleSet, true); |
|
35 |
this.addActionMessage(this.getText("createRuleSet.success")); |
|
36 |
} |
|
37 |
return Action.SUCCESS; |
|
38 |
} |
|
39 |
catch(Exception e) { |
|
40 |
logger.error("Error creating/editing ruleset", e); |
|
41 |
this.addActionError(this.getText("generic.error")); |
|
42 |
reportException(e); |
|
43 |
return "exception"; |
|
44 |
} |
|
45 |
} |
|
46 |
|
|
47 |
public void validate() { |
|
48 |
this.clearErrors(); |
|
49 |
if((chosenContentRules == null || chosenContentRules.isEmpty())||(chosenUsageRules == null || chosenUsageRules.isEmpty())) |
|
50 |
this.addActionError(this.getText("createRuleSets.atLeastOneRule")); |
|
51 |
if(funct == null) |
|
52 |
this.addActionError(this.getText("uknownError")); |
|
53 |
} |
|
54 |
|
|
55 |
public String getFunct() { |
|
56 |
return funct; |
|
57 |
} |
|
58 |
public void setFunct(String funct) { |
|
59 |
this.funct = funct; |
|
60 |
} |
|
61 |
|
|
62 |
public Set<Integer> getChosenContentRules() { |
|
63 |
return chosenContentRules; |
|
64 |
} |
|
65 |
|
|
66 |
public void setChosenContentRules(Set<Integer> chosenContentRules) { |
|
67 |
this.chosenContentRules = chosenContentRules; |
|
68 |
} |
|
69 |
|
|
70 |
public Set<Integer> getChosenUsageRules() { |
|
71 |
return chosenUsageRules; |
|
72 |
} |
|
73 |
|
|
74 |
public void setChosenUsageRules(Set<Integer> chosenUsageRules) { |
|
75 |
this.chosenUsageRules = chosenUsageRules; |
|
76 |
} |
|
77 |
|
|
78 |
public RuleSet getRuleSet() { |
|
79 |
return ruleSet; |
|
80 |
} |
|
81 |
|
|
82 |
public void setRuleSet(RuleSet ruleSet) { |
|
83 |
this.ruleSet = ruleSet; |
|
84 |
} |
|
85 |
|
|
86 |
|
|
87 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/rulesets/GetRules.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.rulesets; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.HashSet; |
|
5 |
import java.util.List; |
|
6 |
import java.util.Set; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
|
|
10 |
import com.opensymphony.xwork2.Action; |
|
11 |
|
|
12 |
import eu.dnetlib.domain.functionality.validator.Rule; |
|
13 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
|
14 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
15 |
import eu.dnetlib.validator.admin.constants.TypesAndTableNames; |
|
16 |
|
|
17 |
public class GetRules extends BaseValidatorAction { |
|
18 |
|
|
19 |
private static final long serialVersionUID = 3336444896590055688L; |
|
20 |
private int setId = -1; |
|
21 |
private List<Rule> rulesContent; |
|
22 |
private List<Rule> rulesUsage; |
|
23 |
private Set<Integer> ruleIdsContent; |
|
24 |
private Set<Integer> ruleIdsUsage; |
|
25 |
private List<String> deployEnvironments; |
|
26 |
private String funct = null; |
|
27 |
private RuleSet ruleSet; |
|
28 |
|
|
29 |
private static final Logger logger = Logger.getLogger(GetRules.class); |
|
30 |
|
|
31 |
public String execute() { |
|
32 |
this.clearErrorsAndMessages(); |
|
33 |
try { |
|
34 |
logger.debug("getting rules in rule set "+setId); |
|
35 |
ruleIdsContent = new HashSet<Integer>(); |
|
36 |
ruleIdsUsage = new HashSet<Integer>(); |
|
37 |
rulesContent = new ArrayList<Rule>(); |
|
38 |
rulesUsage = new ArrayList<Rule>(); |
|
39 |
this.splitRules(this.getValidatorAdminAPI().getAllRules(),rulesContent, rulesUsage); |
|
40 |
this.deployEnvironments = TypesAndTableNames.deployEnvironments; |
|
41 |
if (setId == -1) { |
|
42 |
ruleSet = new RuleSet(); |
|
43 |
ruleSet.setId(-1); |
|
44 |
funct = "create"; |
|
45 |
} else { |
|
46 |
funct = "edit"; |
|
47 |
ruleSet = this.getValidatorAdminAPI().getRuleSet(setId); |
|
48 |
ruleIdsContent=ruleSet.getContentRulesIds(); |
|
49 |
ruleIdsUsage=ruleSet.getUsageRulesIds(); |
|
50 |
// visibility = Utilities.convertListToString(set.getVisibility()); |
|
51 |
} |
|
52 |
return Action.SUCCESS; |
|
53 |
} |
|
54 |
catch(Exception e) { |
|
55 |
logger.error("Error getting rules", e); |
|
56 |
this.addActionError(this.getText("generic.error")); |
|
57 |
reportException(e); |
|
58 |
return "exception"; |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
private void splitRules(List<Rule> totalRules, List<Rule> contentRules, List<Rule> usageRules) { |
|
63 |
logger.debug("splitting rules.."); |
|
64 |
for (Rule rule : totalRules) { |
|
65 |
if (rule.getJob_type().equals("content")) { |
|
66 |
contentRules.add(rule); |
|
67 |
} else if (rule.getJob_type().equals("usage")) { |
|
68 |
usageRules.add(rule); |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
public String getFunct() { |
|
74 |
return funct; |
|
75 |
} |
|
76 |
|
|
77 |
public void setFunct(String funct) { |
|
78 |
this.funct = funct; |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
public RuleSet getRuleSet() { |
|
83 |
return ruleSet; |
|
84 |
} |
|
85 |
|
|
86 |
public void setRuleSet(RuleSet ruleSet) { |
|
87 |
this.ruleSet = ruleSet; |
|
88 |
} |
|
89 |
|
|
90 |
public int getSetId() { |
|
91 |
return setId; |
|
92 |
} |
|
93 |
|
|
94 |
public void setSetId(int setId) { |
|
95 |
this.setId = setId; |
|
96 |
} |
|
97 |
|
|
98 |
|
|
99 |
public List<Rule> getRulesContent() { |
|
100 |
return rulesContent; |
|
101 |
} |
|
102 |
|
|
103 |
|
|
104 |
public void setRulesContent(List<Rule> rulesContent) { |
|
105 |
this.rulesContent = rulesContent; |
|
106 |
} |
|
107 |
|
|
108 |
|
|
109 |
public List<Rule> getRulesUsage() { |
|
110 |
return rulesUsage; |
|
111 |
} |
|
112 |
|
|
113 |
|
|
114 |
public void setRulesUsage(List<Rule> rulesUsage) { |
|
115 |
this.rulesUsage = rulesUsage; |
|
116 |
} |
|
117 |
|
|
118 |
public Set<Integer> getRuleIdsContent() { |
|
119 |
return ruleIdsContent; |
|
120 |
} |
|
121 |
|
|
122 |
public void setRuleIdsContent(Set<Integer> ruleIdsContent) { |
|
123 |
this.ruleIdsContent = ruleIdsContent; |
|
124 |
} |
|
125 |
|
|
126 |
public Set<Integer> getRuleIdsUsage() { |
|
127 |
return ruleIdsUsage; |
|
128 |
} |
|
129 |
|
|
130 |
public void setRuleIdsUsage(Set<Integer> ruleIdsUsage) { |
|
131 |
this.ruleIdsUsage = ruleIdsUsage; |
|
132 |
} |
|
133 |
|
|
134 |
public List<String> getDeployEnvironments() { |
|
135 |
return deployEnvironments; |
|
136 |
} |
|
137 |
|
|
138 |
public void setDeployEnvironments(List<String> deployEnvironments) { |
|
139 |
this.deployEnvironments = deployEnvironments; |
|
140 |
} |
|
141 |
|
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
|
|
146 |
|
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/help/HelpPage.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.help; |
|
2 |
|
|
3 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
@SuppressWarnings("serial") |
|
6 |
public class HelpPage extends BaseValidatorAction{ |
|
7 |
|
|
8 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/login/ForgotPasswordPage.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.login; |
|
2 |
|
|
3 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
@SuppressWarnings("serial") |
|
6 |
public class ForgotPasswordPage extends BaseValidatorAction{ |
|
7 |
|
|
8 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/login/LoginPage.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.login; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import org.apache.struts2.interceptor.SessionAware; |
|
6 |
|
|
7 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
8 |
|
|
9 |
@SuppressWarnings("serial") |
|
10 |
public class LoginPage extends BaseValidatorAction implements SessionAware{ |
|
11 |
|
|
12 |
@Override |
|
13 |
public String execute() throws Exception { |
|
14 |
this.clearErrorsAndMessages(); |
|
15 |
String email = (String) session.get("email"); |
|
16 |
|
|
17 |
if ( email!=null && !email.trim().isEmpty() ) |
|
18 |
return INPUT; |
|
19 |
|
|
20 |
return SUCCESS; |
|
21 |
} |
|
22 |
|
|
23 |
private Map<String, Object> session; |
|
24 |
@Override |
|
25 |
public void setSession(Map<String, Object> session) { |
|
26 |
this.session = session; |
|
27 |
} |
|
28 |
|
|
29 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/login/ResetPassword.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.login; |
|
2 |
|
|
3 |
import org.apache.log4j.Logger; |
|
4 |
|
|
5 |
import com.opensymphony.xwork2.Action; |
|
6 |
|
|
7 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
8 |
|
|
9 |
public class ResetPassword extends BaseValidatorAction { |
|
10 |
|
|
11 |
private static final long serialVersionUID = -4565098546731325693L; |
|
12 |
private Logger logger = Logger.getLogger(ResetPassword.class); |
|
13 |
|
|
14 |
private String password, repassword, securityCode; |
|
15 |
|
|
16 |
public String execute() { |
|
17 |
this.clearErrorsAndMessages(); |
|
18 |
try { |
|
19 |
logger.debug("reseting password with security code " + securityCode); |
|
20 |
this.getUserAPI().resetPassword(this.getSecurityCode(), this.getPassword()); |
|
21 |
this.addActionMessage(this.getText("resetPassword.success")); |
|
22 |
return Action.SUCCESS; |
|
23 |
} catch (Exception e) { |
|
24 |
logger.error("error reseting password with security code " + securityCode, e); |
|
25 |
this.addActionError(this.getText("generic.error")); |
|
26 |
return "exception"; |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
public void validate() { |
|
31 |
this.clearErrors(); |
|
32 |
try { |
|
33 |
if (this.getSecurityCode() == null || this.getSecurityCode().length() == 0) { |
|
34 |
this.addFieldError("securityCode", this.getText("resetPassword.wrongSecurityCode")); |
|
35 |
return; |
|
36 |
} |
|
37 |
if (!this.getPassword().equals(this.getRepassword())) { |
|
38 |
this.addFieldError("password", this.getText("identicalPasswords")); |
|
39 |
return; |
|
40 |
} |
|
41 |
} catch (Exception e) { |
|
42 |
this.addActionError(""); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
public String getPassword() { |
|
47 |
return password; |
|
48 |
} |
|
49 |
|
|
50 |
public void setPassword(String password) { |
|
51 |
this.password = password; |
|
52 |
} |
|
53 |
|
|
54 |
public String getRepassword() { |
|
55 |
return repassword; |
|
56 |
} |
|
57 |
|
|
58 |
public void setRepassword(String repassword) { |
|
59 |
this.repassword = repassword; |
|
60 |
} |
|
61 |
|
|
62 |
public String getSecurityCode() { |
|
63 |
return securityCode; |
|
64 |
} |
|
65 |
|
|
66 |
public void setSecurityCode(String securityCode) { |
|
67 |
this.securityCode = securityCode; |
|
68 |
} |
|
69 |
|
|
70 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/login/AdminInterceptor.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.login; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import com.opensymphony.xwork2.Action; |
|
6 |
import com.opensymphony.xwork2.ActionInvocation; |
|
7 |
import com.opensymphony.xwork2.interceptor.Interceptor; |
|
8 |
|
|
9 |
import eu.dnetlib.validator.admin.api.UserApi; |
|
10 |
import eu.dnetlib.validator.admin.api.ValidatorAdminAPI; |
|
11 |
import eu.dnetlib.validator.admin.config.Constants; |
|
12 |
|
|
13 |
public class AdminInterceptor implements Interceptor { |
|
14 |
|
|
15 |
private static final long serialVersionUID = -172948943490485824L; |
|
16 |
private UserApi userAPI = null; |
|
17 |
private ValidatorAdminAPI validatorAdminAPI = null; |
|
18 |
|
|
19 |
// private Logger logger = Logger.getLogger(AdminInterceptor.class); |
|
20 |
|
|
21 |
@Override |
|
22 |
public void destroy() { |
|
23 |
|
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public void init() { |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
public String intercept(ActionInvocation actionInvocation) throws Exception { |
|
33 |
Map<String, Object> session = actionInvocation.getInvocationContext().getSession(); |
|
34 |
String auth = (String) session.get(Constants.loggedInField); |
|
35 |
|
|
36 |
if (this.getUserAPI().isAdmin(auth) || this.getValidatorAdminAPI().userIsMasterAdmin(auth) || this.getValidatorAdminAPI().userIsSecondaryAdmin(auth)) |
|
37 |
return actionInvocation.invoke(); |
|
38 |
else |
|
39 |
return Action.LOGIN; |
|
40 |
} |
|
41 |
|
|
42 |
public UserApi getUserAPI() { |
|
43 |
return userAPI; |
|
44 |
} |
|
45 |
|
|
46 |
public void setUserAPI(UserApi userAPI) { |
|
47 |
this.userAPI = userAPI; |
|
48 |
} |
|
49 |
|
|
50 |
public ValidatorAdminAPI getValidatorAdminAPI() { |
|
51 |
return validatorAdminAPI; |
|
52 |
} |
|
53 |
|
|
54 |
public void setValidatorAdminAPI(ValidatorAdminAPI validatorAdminAPI) { |
|
55 |
this.validatorAdminAPI = validatorAdminAPI; |
|
56 |
} |
|
57 |
|
|
58 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/login/Login.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.login; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
import java.util.regex.Pattern; |
|
5 |
|
|
6 |
import javax.servlet.http.HttpServletResponse; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
import org.apache.struts2.interceptor.ServletResponseAware; |
|
10 |
import org.apache.struts2.interceptor.SessionAware; |
|
11 |
|
|
12 |
import com.opensymphony.xwork2.Action; |
|
13 |
|
|
14 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
15 |
import eu.dnetlib.validator.admin.config.Constants; |
|
16 |
|
|
17 |
public class Login extends BaseValidatorAction implements SessionAware, ServletResponseAware { |
|
18 |
|
|
19 |
private static final long serialVersionUID = -6021271413570776229L; |
|
20 |
private String email_username, password_login; |
|
21 |
private boolean rememberme; |
|
22 |
private Map<String, Object> session; |
|
23 |
private HttpServletResponse response; |
|
24 |
|
|
25 |
private String url; |
|
26 |
private String params; |
|
27 |
|
|
28 |
private transient Logger logger = Logger.getLogger(Login.class); |
|
29 |
|
|
30 |
public String execute() { |
|
31 |
this.clearErrorsAndMessages(); |
|
32 |
try { |
|
33 |
if(this.email_username == null || this.email_username.trim().equals("")) |
|
34 |
return "login"; |
|
35 |
logger.debug("logging-in user " + this.getEmail()); |
|
36 |
session.put(Constants.loggedInField, this.getEmail()); |
|
37 |
session.put("email", this.getEmail()); |
|
38 |
if (this.getUserAPI().isAdmin(email_username) || this.getValidatorAdminAPI().userIsMasterAdmin(email_username)) |
|
39 |
session.put("isAdmin", "true"); |
|
40 |
if (this.getValidatorAdminAPI().userIsMasterAdmin(email_username)) |
|
41 |
session.put("isAdmin", "true"); |
|
42 |
if (this.getValidatorAdminAPI().userIsSecondaryAdmin(email_username)) |
|
43 |
session.put("isAdmin", "true"); |
|
44 |
this.addActionMessage("Logged-in successfully"); |
|
45 |
|
|
46 |
if (url != null && (url.equals("/go2login") || url.equals("/Login") || url.equals("/portalLogin"))) { |
|
47 |
url = ""; |
|
48 |
return "welcome"; |
|
49 |
} |
|
50 |
|
|
51 |
return Action.SUCCESS; |
|
52 |
} catch (Exception e) { |
|
53 |
logger.error("error logging-in user " + this.getEmail(), e); |
|
54 |
this.addActionError(this.getText("generic.error")); |
|
55 |
reportException(e); |
|
56 |
return "exception"; |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
public void validate() { |
|
61 |
this.clearErrors(); |
|
62 |
try { |
|
63 |
if(this.email_username == null || this.email_username.trim().equals("")) |
|
64 |
return; |
|
65 |
|
|
66 |
|
|
67 |
String username = this.email_username; |
|
68 |
|
|
69 |
Pattern rfc2822 = Pattern.compile("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"); |
|
70 |
if (!rfc2822.matcher(this.getEmail().trim().toLowerCase()).matches()) { |
|
71 |
logger.debug("user logged in using username"); |
|
72 |
this.email_username = this.getUserAPI().getEmailFromUsername(this.getEmail()); |
|
73 |
} |
|
74 |
|
|
75 |
if (this.email_username == null) { |
|
76 |
this.email_username = username; |
|
77 |
this.addActionError(this.getText("login.userNotExists")); |
|
78 |
return; |
|
79 |
} |
|
80 |
|
|
81 |
if (!this.getUserAPI().userExists(this.getEmail())) { |
|
82 |
this.email_username = username; |
|
83 |
this.addActionError(this.getText("login.userNotExists")); |
|
84 |
return; |
|
85 |
} |
|
86 |
if (!this.getUserAPI().isUserActivated(this.getEmail())) { |
|
87 |
this.email_username = username; |
|
88 |
this.addActionError(this.getText("login.notActivated")); |
|
89 |
return; |
|
90 |
} |
|
91 |
if (!this.getUserAPI().correctCreds(this.getEmail(), this.getPassword_login())) { |
|
92 |
this.email_username = username; |
|
93 |
this.addActionError(this.getText("login.incorrectCreds")); |
|
94 |
return; |
|
95 |
} |
|
96 |
} catch (Exception e) { |
|
97 |
logger.error("", e); |
|
98 |
this.addActionError(e.toString()); |
|
99 |
reportException(e); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
|
|
104 |
public String getEmail() { |
|
105 |
return email_username; |
|
106 |
} |
|
107 |
|
|
108 |
public void setEmail_username(String email_username) { |
|
109 |
this.email_username = email_username; |
|
110 |
} |
|
111 |
|
|
112 |
public String getPassword_login() { |
|
113 |
return password_login; |
|
114 |
} |
|
115 |
|
|
116 |
public void setPassword_login(String password_login) { |
|
117 |
this.password_login = password_login; |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
public void setSession(Map<String, Object> session) { |
|
122 |
this.session = session; |
|
123 |
} |
|
124 |
|
|
125 |
public void setRememberme(boolean rememberme) { |
|
126 |
this.rememberme = rememberme; |
|
127 |
} |
|
128 |
|
|
129 |
public boolean isRememberme() { |
|
130 |
return rememberme; |
|
131 |
} |
|
132 |
|
|
133 |
public void setServletResponse(HttpServletResponse response) { |
|
134 |
this.response = response; |
|
135 |
} |
|
136 |
|
|
137 |
public HttpServletResponse getServletResponse() { |
|
138 |
return response; |
|
139 |
} |
|
140 |
|
|
141 |
public String getUrl() { |
|
142 |
return url; |
|
143 |
} |
|
144 |
|
|
145 |
public void setUrl(String url) { |
|
146 |
this.url = url; |
|
147 |
} |
|
148 |
|
|
149 |
public String getParams() { |
|
150 |
return params; |
|
151 |
} |
|
152 |
|
|
153 |
public void setParams(String params) { |
|
154 |
this.params = params; |
|
155 |
} |
|
156 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/login/Logout.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.login; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import org.apache.struts2.interceptor.SessionAware; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
8 |
|
|
9 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
10 |
import eu.dnetlib.validator.admin.config.Constants; |
|
11 |
|
|
12 |
public class Logout extends BaseValidatorAction implements SessionAware { |
|
13 |
|
|
14 |
private static final long serialVersionUID = -5304052800228900726L; |
|
15 |
private Map<String, Object> session; |
|
16 |
|
|
17 |
|
|
18 |
public String execute() { |
|
19 |
this.clearErrorsAndMessages(); |
|
20 |
session.remove(Constants.loggedInField); |
|
21 |
session.remove("email"); |
|
22 |
session.remove("isAdmin"); |
|
23 |
this.addActionMessage("Logged-out successfully"); |
|
24 |
|
|
25 |
return Action.SUCCESS; |
|
26 |
} |
|
27 |
|
|
28 |
@Override |
|
29 |
public void setSession(Map<String, Object> session) { |
|
30 |
this.session = session; |
|
31 |
} |
|
32 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/login/PortalLogin.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.login; |
|
2 |
|
|
3 |
import java.util.Calendar; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import javax.crypto.Mac; |
|
7 |
import javax.crypto.spec.SecretKeySpec; |
|
8 |
import javax.servlet.http.HttpServletRequest; |
|
9 |
|
|
10 |
import org.apache.commons.codec.binary.Base64; |
|
11 |
import org.apache.commons.codec.binary.Hex; |
|
12 |
import org.apache.log4j.Logger; |
|
13 |
import org.apache.struts2.interceptor.ServletRequestAware; |
|
14 |
import org.apache.struts2.interceptor.SessionAware; |
|
15 |
|
|
16 |
import com.opensymphony.xwork2.Action; |
|
17 |
|
|
18 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
19 |
import eu.dnetlib.validator.admin.config.Constants; |
|
20 |
|
|
21 |
public class PortalLogin extends BaseValidatorAction implements ServletRequestAware, SessionAware { |
|
22 |
|
|
23 |
private static final long serialVersionUID = -6312800103845446815L; |
|
24 |
private transient Logger logger = Logger.getLogger(PortalLogin.class); |
|
25 |
|
|
26 |
private HttpServletRequest request; |
|
27 |
private Map<String, Object> session; |
|
28 |
|
|
29 |
private String user, ip, valid, signature; |
|
30 |
private String key; |
|
31 |
private String email; |
|
32 |
|
|
33 |
public void validate() { |
|
34 |
this.clearErrors(); |
|
35 |
logger.debug("validating log-in from portal link " + user + ", " + ip + ", " + valid + ", " + signature); |
|
36 |
if (user == null || ip == null || valid == null) { |
|
37 |
this.addActionError(this.getText("login.manual")); |
|
38 |
return; |
|
39 |
} |
|
40 |
if (user.trim().equals("") || ip.trim().equals("") || valid.trim().equals("")) { |
|
41 |
this.addActionError(this.getText("login.manual")); |
|
42 |
return; |
|
43 |
} |
|
44 |
long millisUntil = 0; |
|
45 |
try { |
|
46 |
millisUntil = Long.parseLong(valid); |
|
47 |
} catch (Exception e) { |
|
48 |
logger.error("", e); |
|
49 |
this.addActionError(this.getText("login.manual")); |
|
50 |
return; |
|
51 |
} |
|
52 |
|
|
53 |
try { |
|
54 |
if (!signatureIsValid((user + ip + valid).trim(), signature.trim())) { |
|
55 |
logger.debug("signature was not valid"); |
|
56 |
this.addActionError(this.getText("login.manual")); |
|
57 |
return; |
|
58 |
} |
|
59 |
} catch (Exception e) { |
|
60 |
logger.error("", e); |
|
61 |
this.addActionError(this.getText("login.manual")); |
|
62 |
return; |
|
63 |
} |
|
64 |
|
|
65 |
Calendar cal = Calendar.getInstance(); |
|
66 |
if (cal.getTime().getTime() > millisUntil) { |
|
67 |
logger.debug("link has expired current-time: "+cal.getTime().getTime()+" link-time: "+millisUntil); |
|
68 |
this.addActionError(this.getText("login.manual")); |
|
69 |
return; |
|
70 |
} |
|
71 |
|
|
72 |
if (!ip.trim().equals(request.getRemoteAddr().trim())) { |
|
73 |
logger.debug("ips are different "+ip+" "+request.getRemoteAddr()); |
|
74 |
this.addActionError(this.getText("login.manual")); |
|
75 |
return; |
|
76 |
} |
|
77 |
|
|
78 |
try { |
|
79 |
// if (isModeLdap()) |
|
80 |
this.email = this.getUserAPI().getEmailFromUsername(user); |
|
81 |
|
|
82 |
if (this.email == null) { |
|
83 |
this.email = ""; |
|
84 |
this.addActionError(this.getText("login.userNotExists")); |
|
85 |
return; |
|
86 |
} |
|
87 |
|
|
88 |
if (!this.getUserAPI().userExists(this.getEmail())) { |
|
89 |
this.email = ""; |
|
90 |
this.addActionError(this.getText("login.userNotExists")); |
|
91 |
return; |
|
92 |
} |
|
93 |
|
|
94 |
if (!this.getUserAPI().isUserActivated(this.getEmail())) { |
|
95 |
this.email = ""; |
|
96 |
this.addActionError(this.getText("login.notActivated")); |
|
97 |
return; |
|
98 |
} |
|
99 |
} catch (Exception e) { |
|
100 |
logger.error("", e); |
|
101 |
this.addActionError(e.toString()); |
|
102 |
} |
|
103 |
} |
|
104 |
|
|
105 |
public String execute() { |
|
106 |
this.clearErrorsAndMessages(); |
|
107 |
try { |
|
108 |
logger.debug("logging-in from portal link " + user + ", " + ip + ", " + valid + ", " + signature); |
|
109 |
session.put(Constants.loggedInField, this.getEmail()); |
|
110 |
session.put("email", this.getEmail()); |
|
111 |
if (this.getUserAPI().isAdmin(email)) |
|
112 |
session.put("isAdmin", "true"); |
|
113 |
|
|
114 |
this.addActionMessage("Logged-in successfully"); |
|
115 |
|
|
116 |
return Action.SUCCESS; |
|
117 |
} catch (Exception e) { |
|
118 |
logger.error("error logging-in from portal link " + user + ", " + ip + ", " + valid + ", " + signature, e); |
|
119 |
this.addActionError(this.getText("generic.error")); |
|
120 |
reportException(e); |
|
121 |
return "exception"; |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
public boolean signatureIsValid(String message, String signature) throws Exception { |
|
126 |
byte[] encode = Hex.decodeHex(new String(Base64.decodeBase64(signature.getBytes())).toCharArray()); |
|
127 |
|
|
128 |
SecretKeySpec key = new SecretKeySpec(this.key.getBytes(), "HmacSHA1"); |
|
129 |
Mac mac = Mac.getInstance(key.getAlgorithm()); |
|
130 |
|
|
131 |
mac.init(key); |
|
132 |
|
|
133 |
byte[] myEncode = mac.doFinal(message.getBytes()); |
|
134 |
|
|
135 |
logger.debug("given encode: "+new String(encode)+" my-encode: "+new String(myEncode)); |
|
136 |
|
|
137 |
if (encode.length != myEncode.length) |
|
138 |
return false; |
|
139 |
|
|
140 |
for (int i = 0; i < encode.length; i++) |
|
141 |
if (encode[i] != myEncode[i]) |
|
142 |
return false; |
|
143 |
return true; |
|
144 |
} |
|
145 |
|
|
146 |
public void setServletRequest(HttpServletRequest request) { |
|
147 |
this.request = request; |
|
148 |
} |
|
149 |
|
|
150 |
public HttpServletRequest getServletRequest() { |
|
151 |
return request; |
|
152 |
} |
|
153 |
|
|
154 |
@Override |
|
155 |
public void setSession(Map<String, Object> session) { |
|
156 |
this.session = session; |
|
157 |
} |
|
158 |
|
|
159 |
public String getUser() { |
|
160 |
return user; |
|
161 |
} |
|
162 |
|
|
163 |
public void setUser(String user) { |
|
164 |
this.user = user; |
|
165 |
} |
|
166 |
|
|
167 |
public String getIp() { |
|
168 |
return ip; |
|
169 |
} |
|
170 |
|
|
171 |
public void setIp(String ip) { |
|
172 |
this.ip = ip; |
|
173 |
} |
|
174 |
|
|
175 |
public String getValid() { |
|
176 |
return valid; |
|
177 |
} |
|
178 |
|
|
179 |
public void setValid(String valid) { |
|
180 |
this.valid = valid; |
|
181 |
} |
|
182 |
|
|
183 |
public String getSignature() { |
|
184 |
return signature; |
|
185 |
} |
|
186 |
|
|
187 |
public void setSignature(String signature) { |
|
188 |
this.signature = signature; |
|
189 |
} |
|
190 |
|
|
191 |
public String getKey() { |
|
192 |
return key; |
|
193 |
} |
|
194 |
|
|
195 |
public void setKey(String key) { |
|
196 |
this.key = key; |
|
197 |
} |
|
198 |
|
|
199 |
public String getEmail() { |
|
200 |
return email; |
|
201 |
} |
|
202 |
|
|
203 |
public void setEmail(String email) { |
|
204 |
this.email = email; |
|
205 |
} |
|
206 |
|
|
207 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/login/SendPassword.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.login; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.apache.log4j.Logger; |
|
7 |
|
|
8 |
import com.opensymphony.xwork2.Action; |
|
9 |
|
|
10 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
11 |
|
|
12 |
public class SendPassword extends BaseValidatorAction { |
|
13 |
|
|
14 |
private static final long serialVersionUID = 7540821478579531671L; |
|
15 |
private Logger logger = Logger.getLogger(SendPassword.class); |
|
16 |
|
|
17 |
private String email; |
|
18 |
|
|
19 |
public String execute() { |
|
20 |
this.clearErrorsAndMessages(); |
|
21 |
try { |
|
22 |
logger.debug("sending password to user " + email); |
|
23 |
List<String> to = new ArrayList<String>(); |
|
24 |
to.add(this.getEmail()); |
|
25 |
String securityCode = this.getUserAPI().prepareResetPassword(this.getEmail()); |
|
26 |
this.getEmailer().sendMail(to, this.getText("forgotPassword.mail.Subject"), this.getText("forgotPassword.mail.Body1") + ": " + this.getValBaseUrl() + "/resetPassword.action?securityCode=" + securityCode + "\n\n" + this.getText("forgotPassword.mail.Body2") + ": " + securityCode, false, null); |
|
27 |
this.addActionMessage(this.getText("forgotPassword.message")); |
|
28 |
return Action.SUCCESS; |
|
29 |
} catch (Exception e) { |
|
30 |
logger.error("error sending password to user " + email, e); |
|
31 |
this.addActionError(this.getText("generic.error")); |
|
32 |
return "exception"; |
|
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
public void validate() { |
|
37 |
this.clearErrors(); |
|
38 |
try { |
|
39 |
if (!this.getUserAPI().userExists(this.getEmail())) { |
|
40 |
this.addActionError(this.getText("login.userNotExists")); |
|
41 |
return; |
|
42 |
} |
|
43 |
// if (!this.getUserAPI().isUserActivated(this.getEmail())) { |
|
44 |
// this.addActionError(this.getText("login.notActivated")); |
|
45 |
// return; |
|
46 |
// } |
|
47 |
} catch (Exception e) { |
|
48 |
this.addActionError(e.toString()); |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
public String getEmail() { |
|
53 |
return email; |
|
54 |
} |
|
55 |
|
|
56 |
public void setEmail(String email) { |
|
57 |
this.email = email; |
|
58 |
} |
|
59 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/login/AuthenticationInterceptor.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.login; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import com.opensymphony.xwork2.Action; |
|
6 |
import com.opensymphony.xwork2.ActionInvocation; |
|
7 |
import com.opensymphony.xwork2.interceptor.Interceptor; |
|
8 |
|
|
9 |
import eu.dnetlib.validator.admin.config.Constants; |
|
10 |
|
|
11 |
public class AuthenticationInterceptor implements Interceptor { |
|
12 |
|
|
13 |
private static final long serialVersionUID = 977098762082596481L; |
|
14 |
|
|
15 |
@Override |
|
16 |
public void destroy() { |
|
17 |
|
|
18 |
} |
|
19 |
|
|
20 |
@Override |
|
21 |
public void init() { |
|
22 |
|
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
public String intercept(ActionInvocation actionInvocation) throws Exception { |
|
27 |
Map<String, Object> session = actionInvocation.getInvocationContext().getSession(); |
|
28 |
String auth = (String) session.get(Constants.loggedInField); |
|
29 |
|
|
30 |
if (auth == null) { |
|
31 |
return Action.LOGIN; |
|
32 |
} |
|
33 |
return actionInvocation.invoke(); |
|
34 |
} |
|
35 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/DummyAction.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions; |
|
2 |
|
|
3 |
import com.opensymphony.xwork2.Action; |
|
4 |
|
|
5 |
public class DummyAction extends BaseValidatorAction { |
|
6 |
|
|
7 |
private static final long serialVersionUID = 4105253794510714980L; |
|
8 |
|
|
9 |
public String execute() { |
|
10 |
return Action.SUCCESS; |
|
11 |
|
|
12 |
} |
|
13 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/rules/FieldPair.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.rules; |
|
2 |
|
|
3 |
public class FieldPair { |
|
4 |
|
|
5 |
private String fieldName, fieldValue; |
|
6 |
|
|
7 |
public String getFieldName() { |
|
8 |
return fieldName; |
|
9 |
} |
|
10 |
|
|
11 |
public void setFieldName(String fieldName) { |
|
12 |
this.fieldName = fieldName; |
|
13 |
} |
|
14 |
|
|
15 |
public String getFieldValue() { |
|
16 |
return fieldValue; |
|
17 |
} |
|
18 |
|
|
19 |
public void setFieldValue(String fieldValue) { |
|
20 |
this.fieldValue = fieldValue; |
|
21 |
} |
|
22 |
|
|
23 |
|
|
24 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/rules/PrepareAddRule.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.rules; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Set; |
|
5 |
|
|
6 |
import org.apache.log4j.Logger; |
|
7 |
|
|
8 |
import com.opensymphony.xwork2.Action; |
|
9 |
|
|
10 |
import eu.dnetlib.domain.functionality.validator.Rule; |
|
11 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
12 |
import eu.dnetlib.validator.admin.api.ValidatorAdminException; |
|
13 |
import eu.dnetlib.validator.admin.constants.TypesAndTableNames; |
|
14 |
|
|
15 |
public class PrepareAddRule extends BaseValidatorAction { |
|
16 |
|
|
17 |
private static final long serialVersionUID = -8414397033694574297L; |
|
18 |
private Logger logger = Logger.getLogger(PrepareAddRule.class); |
|
19 |
|
|
20 |
private String type; |
|
21 |
private Boolean forCris, forUsage = false; |
|
22 |
private List<String> labels; |
|
23 |
private String jobType; |
|
24 |
private Set<String> entityTypes; |
|
25 |
private List<Rule> rules; |
|
26 |
|
|
27 |
|
|
28 |
public String execute() { |
|
29 |
this.clearErrorsAndMessages(); |
|
30 |
logger.debug("preparing to add rule of type " + type ); |
|
31 |
logger.debug("cris: " + forCris); |
|
32 |
entityTypes = TypesAndTableNames.getCrisEntities().keySet(); |
|
33 |
|
|
34 |
if (jobType.equals("usage")) |
|
35 |
forUsage = true; |
|
36 |
try { |
|
37 |
labels = getValidatorAdminAPI().getRuleLabels(type, forUsage, forCris); |
|
38 |
} catch (ValidatorAdminException e) { |
|
39 |
return Action.ERROR; |
|
40 |
} |
|
41 |
if (type.equals("ChainRule")) { |
|
42 |
try { |
|
43 |
rules = this.getValidatorAdminAPI().getAllRules(); |
|
44 |
} catch (ValidatorAdminException e) { |
|
45 |
return Action.ERROR; |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
return Action.SUCCESS; |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
public List<String> getLabels() { |
|
54 |
return labels; |
|
55 |
} |
|
56 |
|
|
57 |
public void setLabels(List<String> labels) { |
|
58 |
this.labels = labels; |
|
59 |
} |
|
60 |
|
|
61 |
public String getType() { |
|
62 |
return type; |
|
63 |
} |
|
64 |
|
|
65 |
public String getJobType() { |
|
66 |
return jobType; |
|
67 |
} |
|
68 |
|
|
69 |
public void setJobType(String jobType) { |
|
70 |
this.jobType = jobType; |
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
public void setType(String type) { |
|
75 |
this.type = type; |
|
76 |
} |
|
77 |
|
|
78 |
public List<Rule> getRules() { |
|
79 |
return rules; |
|
80 |
} |
|
81 |
|
|
82 |
public void setRules(List<Rule> rules) { |
|
83 |
this.rules = rules; |
|
84 |
} |
|
85 |
|
|
86 |
public Set<String> getEntityTypes() { |
|
87 |
return entityTypes; |
|
88 |
} |
|
89 |
|
|
90 |
public void setEntityTypes(Set<String> entityTypes) { |
|
91 |
this.entityTypes = entityTypes; |
|
92 |
} |
|
93 |
|
|
94 |
public Boolean getForCris() { |
|
95 |
return forCris; |
|
96 |
} |
|
97 |
|
|
98 |
public void setForCris(Boolean forCris) { |
|
99 |
this.forCris = forCris; |
|
100 |
} |
|
101 |
} |
modules/uoa-validator-admin/trunk/src/main/java/eu/dnetlib/validator/admin/actions/rules/AddRule.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.admin.actions.rules; |
|
2 |
|
|
3 |
|
|
4 |
import org.apache.log4j.Logger; |
|
5 |
|
|
6 |
import com.opensymphony.xwork2.Action; |
|
7 |
|
|
8 |
import eu.dnetlib.domain.functionality.validator.Rule; |
|
9 |
import eu.dnetlib.validator.admin.actions.BaseValidatorAction; |
|
10 |
|
|
11 |
public class AddRule extends BaseValidatorAction { |
|
12 |
|
|
13 |
private static final long serialVersionUID = -4636737264204104816L; |
|
14 |
private String[] inputs; |
|
15 |
private String type, jobType; |
|
16 |
private boolean forCris; |
Also available in: Unified diff
moving to dnet45