1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.io.cyprus;
|
11
|
|
12
|
import org.apache.log4j.Logger;
|
13
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
14
|
import org.springframework.security.core.Authentication;
|
15
|
import org.springframework.security.core.context.SecurityContextHolder;
|
16
|
import org.springframework.stereotype.Component;
|
17
|
|
18
|
import eu.etaxonomy.cdm.io.common.CdmImportBase;
|
19
|
import eu.etaxonomy.cdm.model.common.User;
|
20
|
|
21
|
/**
|
22
|
* @author a.babadshanjan
|
23
|
* @created 08.01.2009
|
24
|
* @version 1.0
|
25
|
*/
|
26
|
|
27
|
@Component
|
28
|
public class CyprusUserImport extends CdmImportBase<CyprusImportConfigurator, CyprusImportState> {
|
29
|
private static final Logger logger = Logger.getLogger(CyprusUserImport.class);
|
30
|
|
31
|
@Override
|
32
|
protected boolean isIgnore(CyprusImportState state) {
|
33
|
return ! state.getConfig().isDoTaxa();
|
34
|
}
|
35
|
|
36
|
|
37
|
/* (non-Javadoc)
|
38
|
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase)
|
39
|
*/
|
40
|
@Override
|
41
|
protected boolean doCheck(CyprusImportState state) {
|
42
|
logger.warn("DoCheck not yet implemented for CyprusExcelImport");
|
43
|
return true;
|
44
|
}
|
45
|
|
46
|
|
47
|
@Override
|
48
|
protected void doInvoke(CyprusImportState state) {
|
49
|
this.getAuthenticationManager();
|
50
|
|
51
|
String username = "cmi";
|
52
|
String password = "fasfowjo0490";
|
53
|
String personTitle = "Cyprus initial import";
|
54
|
User user = User.NewInstance(personTitle, username, password);
|
55
|
// user.setAccountNonLocked(false);
|
56
|
// user.setEnabled(false);
|
57
|
getUserService().save(user);
|
58
|
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
|
59
|
Authentication authentication = getAuthenticationManager().authenticate(token);
|
60
|
|
61
|
SecurityContextHolder.getContext().setAuthentication(authentication);
|
62
|
|
63
|
|
64
|
username = "zypern";
|
65
|
password = "r4i6wpo";
|
66
|
personTitle = "Cyprus editor";
|
67
|
User userZypern = User.NewInstance(personTitle, username, password);
|
68
|
getUserService().save(userZypern);
|
69
|
|
70
|
|
71
|
|
72
|
return;
|
73
|
}
|
74
|
|
75
|
|
76
|
|
77
|
}
|