2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.cyprus
;
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
;
18 import eu
.etaxonomy
.cdm
.io
.common
.CdmImportBase
;
19 import eu
.etaxonomy
.cdm
.model
.common
.User
;
22 * @author a.babadshanjan
28 public class CyprusUserImport
extends CdmImportBase
<CyprusImportConfigurator
, CyprusImportState
> {
29 private static final Logger logger
= Logger
.getLogger(CyprusUserImport
.class);
32 protected boolean isIgnore(CyprusImportState state
) {
33 return ! state
.getConfig().isDoTaxa();
38 * @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase)
41 protected boolean doCheck(CyprusImportState state
) {
42 logger
.warn("DoCheck not yet implemented for CyprusExcelImport");
48 protected boolean doInvoke(CyprusImportState state
) {
49 this.getAuthenticationManager();
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
);
61 SecurityContextHolder
.getContext().setAuthentication(authentication
);
66 personTitle
= "Cyprus editor";
67 User userZypern
= User
.NewInstance(personTitle
, username
, password
);
68 getUserService().save(userZypern
);