Project

General

Profile

« Previous | Next » 

Revision 31524

[maven-release-plugin] copy for tag dnet-modular-ui-2.0.0

View differences:

modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-modular-ui/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-modular-ui"}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/test/java/eu/dnetlib/functionality/modular/ui/users/SimpleSSOAuthorizationManagerTest.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
import static org.junit.Assert.*;
4

  
5
import org.junit.Before;
6
import org.junit.Test;
7
import org.springframework.core.io.ClassPathResource;
8

  
9
public class SimpleSSOAuthorizationManagerTest {
10
	
11
	private final static String PAYLOAD = "{\"uid\":\"michele.artini\",\"fullname\":\"Michele Artini\",\"email\":\"michele.artini@isti.cnr.it\"}";
12
	private final static String SIGNATURE = "89f7a05d39d7a1e6489506c0a27f6087cf4ca0c7f0298c29d61464f5522be146363e8ad63312cc3d7fdcf5b5f1ff7b26e64ed1009b52b6562deebbd267dc6f49e25714f54a8cd2936db6b15e27e9dfc7ab762728d33449e8734101265bbb8b70e5efe2845d5ae2da6e43f25ab75e531fa6cc15e31497bb344b1cca6d687ecf2501c407316423c3eecbe98df43a0721b63f3a1a07fc1e7d75855cc6dc9dce18817b008d60fb4b225d462755d5671fdd01d3c7b08d5d039524e45a78a808377a3cc44b13c0c8e314aa1893e88cd32120e8beeacf5df8412c8228c1e8aa046a159ea1d6a36de160456f32001e23978b1b2d15490a07943d95a56d9dfd0f7bc6b4c6";
13

  
14
	private SimpleSSOAuthorizationManager manager = new SimpleSSOAuthorizationManager();
15
	
16
	
17
	@Before
18
	public void setup() throws Exception {
19
		manager.setPubKeyAlgo("RSA");
20
		manager.setPubKeyFile(new ClassPathResource("/eu/dnetlib/functionality/modular/ui/users/pubkey.der"));
21
		manager.setSignatureAlgo("SHA1withRSA");
22
		manager.init();
23
	}
24
	@Test
25
	public void testIsValidMessage() {
26
		assertTrue(manager.isValidMessage(PAYLOAD, SIGNATURE));
27
		assertFalse(manager.isValidMessage(PAYLOAD.toLowerCase(), SIGNATURE));
28
		assertFalse(manager.isValidMessage(PAYLOAD + "123", SIGNATURE));
29
		assertFalse(manager.isValidMessage(PAYLOAD, SIGNATURE + "123"));
30
		assertFalse(manager.isValidMessage(PAYLOAD + PAYLOAD, SIGNATURE));
31
		assertFalse(manager.isValidMessage("aaa", "aaa"));
32
		assertFalse(manager.isValidMessage(null, SIGNATURE));
33
		assertFalse(manager.isValidMessage(PAYLOAD, null));
34
		assertFalse(manager.isValidMessage("", SIGNATURE));
35
		assertFalse(manager.isValidMessage(PAYLOAD, ""));
36
		assertFalse(manager.isValidMessage(null, ""));
37
		assertFalse(manager.isValidMessage("", null));
38
		assertFalse(manager.isValidMessage("", ""));
39
		assertFalse(manager.isValidMessage(null, null));
40
	}
41

  
42
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/EntryPointsAggregator.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import java.util.Collections;
4
import java.util.HashMap;
5
import java.util.List;
6
import java.util.Map;
7

  
8
import org.springframework.beans.factory.annotation.Autowired;
9

  
10
import com.google.common.collect.Lists;
11
import com.google.common.collect.Sets;
12

  
13
import eu.dnetlib.functionality.modular.ui.users.AccessLimited;
14
import eu.dnetlib.functionality.modular.ui.users.PermissionLevel;
15
import eu.dnetlib.functionality.modular.ui.users.User;
16

  
17
public class EntryPointsAggregator {
18
	
19
	@Autowired(required=false)
20
	private List<ModuleEntryPoint> entryPoints = Lists.newArrayList();;
21
	
22
	@Autowired(required=false)
23
	private List<AbstractMenu> otherMenus = Lists.newArrayList();
24

  
25
	public List<ModuleEntryPoint> getEntryPoints() {
26
		return entryPoints;
27
	}
28

  
29
	public void setEntryPoints(List<ModuleEntryPoint> entryPoints) {
30
		this.entryPoints = entryPoints;
31
	}
32
		
33
	public List<AbstractMenu> getMenus(User user) {
34
		final Map<String, ModulesMenu> map = new HashMap<String, ModulesMenu>();
35
		
36
		for (ModuleEntryPoint entry : entryPoints) {
37
			if (entry.isValidMenuEntry() && verifyAuthorization(entry, user)) {
38
				final String group = entry.getGroup();
39
				if (!map.containsKey(group)) {
40
					map.put(group, new ModulesMenu(group));
41
				}
42
				map.get(group).addEntry(entry);
43
			}
44
		}
45
		final List<AbstractMenu> items = Lists.newArrayList();
46
		
47
		for (AbstractMenu menu : otherMenus) {
48
			if (menu instanceof AccessLimited) {
49
				 if (verifyAuthorization((AccessLimited) menu, user) && menu.getEntries().size() > 0) {
50
					 items.add(menu);
51
				 }
52
			} else if (menu.getEntries().size() > 0) {
53
				items.add(menu);
54
			}
55
		}
56

  
57
		for (ModulesMenu item : map.values()) {
58
			item.complete();
59
			items.add(item);
60
		}
61
	
62
		Collections.sort(items);
63
		return items;
64
	}
65
	
66
	private boolean verifyAuthorization(AccessLimited entry, User user) {
67
		if (user.getPermissionLevels().contains(PermissionLevel.SUPER_ADMIN)) return true;
68
		
69
		return (Sets.intersection(user.getPermissionLevels(), entry.getPermissionLevels()).size() > 0);
70
	}
71
	
72
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/UsersInternalController.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import java.io.IOException;
4
import java.util.Collections;
5
import java.util.List;
6
import java.util.Map;
7
import java.util.Set;
8

  
9
import javax.annotation.Resource;
10
import javax.servlet.http.HttpServletResponse;
11

  
12
import org.apache.commons.logging.Log;
13
import org.apache.commons.logging.LogFactory;
14
import org.springframework.stereotype.Controller;
15
import org.springframework.web.bind.annotation.RequestBody;
16
import org.springframework.web.bind.annotation.RequestMapping;
17
import org.springframework.web.bind.annotation.RequestMethod;
18
import org.springframework.web.bind.annotation.ResponseBody;
19

  
20
import com.google.common.collect.Lists;
21
import com.google.common.collect.Maps;
22

  
23
import eu.dnetlib.functionality.modular.ui.users.AuthorizationDAO;
24
import eu.dnetlib.functionality.modular.ui.users.PermissionLevel;
25
import eu.dnetlib.functionality.modular.ui.users.User;
26

  
27
@Controller
28
public class UsersInternalController {
29
	
30
	@Resource(name="modularUiAuthorizationDao")
31
	private AuthorizationDAO dao;
32
	
33
	private static final Log log = LogFactory.getLog(UsersInternalController.class);
34
	
35
	@RequestMapping(value = "/ui/users.get")
36
	public @ResponseBody List<User> listUsers(HttpServletResponse response) throws IOException {
37
		final List<User> list = Lists.newArrayList();
38
		for (Map.Entry<String, Set<PermissionLevel>> e : dao.getPermissionLevels().entrySet()) {
39
			final User user = new User(e.getKey());
40
			user.setPermissionLevels(e.getValue());
41
			list.add(user);
42
		}
43
		Collections.sort(list);
44
		
45
		return list;
46
	}
47

  
48
	@RequestMapping(value = "/ui/saveusers.do", method=RequestMethod.POST)
49
	public @ResponseBody boolean updateUsers(@RequestBody final List<User> users) {
50
		
51
		log.info("Saving " + users.size() + " user(s)");
52
		final Map<String, Set<PermissionLevel>> map = Maps.newHashMap();
53
		for (User u : users) {
54
			map.put(u.getId(), u.getPermissionLevels());
55
		}
56
		dao.updatePermissionLevels(map);
57
		return true;
58
	}
59

  
60
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/UsersController.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import java.util.List;
4
import java.util.Map;
5

  
6
import javax.servlet.http.HttpServletRequest;
7
import javax.servlet.http.HttpServletResponse;
8

  
9
import org.springframework.ui.ModelMap;
10

  
11
import com.google.common.collect.Lists;
12
import com.google.common.collect.Maps;
13

  
14
import eu.dnetlib.functionality.modular.ui.users.PermissionLevel;
15

  
16
public class UsersController extends ModuleEntryPoint {
17

  
18
	private List<Map<String, String>> listAvailableLevels = Lists.newArrayList();; 
19
		
20
	@Override
21
	protected void initialize(ModelMap map, HttpServletRequest request,	HttpServletResponse response) throws Exception {
22
		map.addAttribute("availableLevels", listPermissionLevels());
23
	}
24
	
25
	private List<Map<String, String>> listPermissionLevels() {
26
		if (listAvailableLevels.isEmpty()) {
27
			for (PermissionLevel level : PermissionLevel.values()) {
28
				final Map<String, String> map = Maps.newHashMap();
29
				map.put("level", level.toString());
30
				map.put("label", level.getLabel());
31
				map.put("details", level.getDetails());
32
				listAvailableLevels.add(map);
33
			}
34
		}
35
		return listAvailableLevels;
36
	}
37
	
38
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/error/ErrorMessage.java
1
package eu.dnetlib.functionality.modular.ui.error;
2

  
3
import org.apache.commons.lang.exception.ExceptionUtils;
4

  
5
public class ErrorMessage {
6
	private String message;
7
	private String stacktrace;
8
	
9
	public ErrorMessage() {}
10
	
11
	public static ErrorMessage newInstance(final Exception e) {
12
		return new ErrorMessage(e.getMessage(), ExceptionUtils.getStackTrace(e));
13
	}
14
 	
15
	public ErrorMessage(final String message, final String stacktrace) {
16
    	this.message = message;
17
    	this.stacktrace = stacktrace;
18
    }
19

  
20
	public String getMessage() {
21
		return message;
22
	}
23

  
24
	public void setMessage(final String message) {
25
		this.message = message;
26
	}
27

  
28
	public String getStacktrace() {
29
		return stacktrace;
30
	}
31

  
32
	public void setStacktrace(final String stacktrace) {
33
		this.stacktrace = stacktrace;
34
	}
35
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/AbstractAjaxController.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import org.springframework.http.HttpStatus;
4
import org.springframework.web.bind.annotation.ExceptionHandler;
5
import org.springframework.web.bind.annotation.ResponseBody;
6
import org.springframework.web.bind.annotation.ResponseStatus;
7

  
8
import eu.dnetlib.functionality.modular.ui.error.ErrorMessage;
9

  
10
public abstract class AbstractAjaxController {
11
	
12
	@ExceptionHandler(Exception.class)
13
	@ResponseStatus(value=HttpStatus.INTERNAL_SERVER_ERROR)
14
	public @ResponseBody ErrorMessage handleException(final Exception e) {
15
		return ErrorMessage.newInstance(e);
16
	}
17

  
18
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/utils/ShutdownUtils.java
1
package eu.dnetlib.functionality.modular.ui.utils;
2

  
3
import java.util.List;
4

  
5
import org.apache.commons.logging.Log;
6
import org.apache.commons.logging.LogFactory;
7
import org.springframework.beans.factory.annotation.Autowired;
8

  
9
import com.google.common.collect.Lists;
10

  
11
import eu.dnetlib.enabling.common.Stoppable;
12
import eu.dnetlib.enabling.common.StoppableDetails;
13
import eu.dnetlib.enabling.common.StoppableDetails.StopStatus;
14

  
15
public class ShutdownUtils {
16

  
17
	@Autowired(required=false)
18
	private List<Stoppable> stoppables = Lists.newArrayList();
19
		
20
	private StopStatus status = StopStatus.RUNNING;
21
	
22
	private static final Log log = LogFactory.getLog(ShutdownUtils.class);
23
	
24
	public  List<StoppableDetails> listStoppableDetails() {
25
		final List<StoppableDetails> list = Lists.newArrayList();
26
		
27
		for (Stoppable s : stoppables) {
28
			list.add(s.getStopDetails());
29
		}
30
		
31
		return list;
32
	}
33
	
34
	public void stopAll() {
35
		this.status = StopStatus.STOPPING;
36
		
37
		for (Stoppable s : stoppables) {
38
			final StoppableDetails info = s.getStopDetails();
39
			if (info.getStatus() == StopStatus.RUNNING) {
40
				log.info("Stopping " + info.getName());
41
				s.stop();
42
			}
43
		}
44
	}
45
	
46
	public StopStatus currentStatus() {
47
		if (status == StopStatus.STOPPING) {
48
			int running = 0;
49
			for (Stoppable s : stoppables) {
50
				final StoppableDetails info = s.getStopDetails();
51
				if (info.getStatus() != StopStatus.STOPPED) {
52
					running++;
53
				}
54
			}
55
			if (running == 0) {
56
				status = StopStatus.STOPPED;
57
			}
58
		}
59
		return status;
60
	}
61
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/users/PermissionLevel.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
public enum PermissionLevel {
4
	SUPER_ADMIN("Super admin", "Authenticated user with ALL management rights"), 
5
	DS_ADMIN ("datasource administrator", "Authenticated user that can manage datasources"), 
6
	WF_ADMIN("workflow administrator", "Authenticated user that can manage workflows"),
7
	IS_ADMIN("information administrator", "Authenticated user that can update IS profiles"),
8
	USER("simple user", "Authenticated user with no management rights"), 
9
	GUEST ("guest", "Anonymous user");
10

  
11
	private String label;
12
	private String details;
13
	
14
	private PermissionLevel(final String label, final String details) {
15
		this.label = label;
16
		this.details = details;
17
	}
18

  
19
	public String getLabel() {
20
		return label;
21
	}
22

  
23
	public String getDetails() {
24
		return details;
25
	}
26

  
27

  
28
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/users/AuthorizationDAO.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
import java.util.Map;
4
import java.util.Set;
5

  
6
public interface AuthorizationDAO {
7
	void updatePermissionLevels(Map<String, Set<PermissionLevel>> map);
8
	Map<String, Set<PermissionLevel>> getPermissionLevels();
9
	Set<PermissionLevel> getPermissionLevels(String uid);
10
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/users/MongoAuthorizationDAO.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
import java.util.HashSet;
4
import java.util.List;
5
import java.util.Map;
6
import java.util.Map.Entry;
7
import java.util.Set;
8

  
9
import org.apache.commons.logging.Log;
10
import org.apache.commons.logging.LogFactory;
11
import org.springframework.beans.factory.annotation.Required;
12

  
13
import com.google.common.base.Joiner;
14
import com.google.common.base.Splitter;
15
import com.google.common.collect.Lists;
16
import com.google.common.collect.Maps;
17
import com.mongodb.BasicDBObject;
18
import com.mongodb.BasicDBObjectBuilder;
19
import com.mongodb.DB;
20
import com.mongodb.DBCollection;
21
import com.mongodb.DBCursor;
22
import com.mongodb.DBObject;
23

  
24
public class MongoAuthorizationDAO implements AuthorizationDAO {
25
	
26
	private DB db;
27

  
28
	private static final String AUTH_COLL = "users";
29

  
30

  
31
	private static final Log log = LogFactory.getLog(MongoAuthorizationDAO.class);
32
	
33
	@Override
34
	public void updatePermissionLevels(Map<String, Set<PermissionLevel>> map) {
35
		final DBCollection coll = db.getCollection(AUTH_COLL);
36
		final List<DBObject> list = Lists.newArrayList();
37

  
38
		for (Entry<String, Set<PermissionLevel>> e : map.entrySet()) {
39
			final Map<String, String> m = Maps.newHashMap();
40
			m.put("uid" , e.getKey());
41
			m.put("levels", serializeLevels(e.getValue()));
42
			list.add(BasicDBObjectBuilder.start(m).get());
43
		}
44
		coll.remove(new BasicDBObject());
45
		coll.insert(list);
46
	}
47
	
48
	@Override
49
	public Map<String, Set<PermissionLevel>> getPermissionLevels() {
50
		final DBCollection coll = db.getCollection(AUTH_COLL);
51
		final DBCursor cur = coll.find();
52
		
53
		final Map<String, Set<PermissionLevel>> res = Maps.newHashMap();
54
		while (cur.hasNext()) {
55
			final DBObject o = cur.next();
56
			res.put((String) o.get("uid"), readLevels(o));
57
		}
58
		
59
		return res;
60
	}	
61
	
62
	@Override
63
	public Set<PermissionLevel> getPermissionLevels(String uid) {
64
		final DBCollection coll = db.getCollection(AUTH_COLL);
65
		
66
		final DBObject obj = coll.findOne(new BasicDBObject("uid", uid));
67
		
68
		return readLevels(obj);
69
	}
70

  
71
	private Set<PermissionLevel> readLevels(final DBObject obj) {
72
		final Set<PermissionLevel> set = new HashSet<PermissionLevel>();
73
		
74
		if (obj != null) {
75
			final Object levels = obj.get("levels");
76
			if (levels != null) {
77
				for (String s : Splitter.on(",").omitEmptyStrings().trimResults().split(levels.toString())) {
78
					try {
79
						set.add(PermissionLevel.valueOf(s));
80
					} catch (Throwable e) {
81
						log.error("Invalid permissionLevel: " + s);
82
					}
83
				}
84
			}
85
		}
86
		return set;
87
	}
88
	
89
	private String serializeLevels(Set<PermissionLevel> levels) {
90
		return Joiner.on(",").skipNulls().join(levels);
91
	}
92
	
93
	public DB getDb() {
94
		return db;
95
	}
96

  
97
	@Required
98
	public void setDb(DB db) {
99
		this.db = db;
100
	}
101

  
102
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/users/MockAuthorizationManager.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
import javax.servlet.http.HttpServletRequest;
4

  
5
import com.google.common.collect.Sets;
6

  
7
public class MockAuthorizationManager implements AuthorizationManager {
8

  
9
	@Override
10
	public User obtainUserDetails(HttpServletRequest request) {
11
		final User userMock = new User();
12
		
13
		userMock.setId("mock");
14
		userMock.setFullname("Mock User");
15
		userMock.setPermissionLevels(Sets.newHashSet(PermissionLevel.SUPER_ADMIN));
16
		userMock.setEmail("mock@user.foo");
17
		return userMock;
18
	}
19

  
20
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/users/SimpleAuthorizationManager.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
import java.security.Principal;
4

  
5
import javax.servlet.http.HttpServletRequest;
6

  
7
import org.springframework.beans.factory.annotation.Required;
8

  
9
import com.google.common.collect.Sets;
10

  
11
public class SimpleAuthorizationManager implements AuthorizationManager {
12
	
13
	
14
	private AuthorizationDAO authorizationDAO;
15
	
16
	private String defaultSuperAdmin;
17
	
18
	@Override
19
	public User obtainUserDetails(final HttpServletRequest request) {
20
		final Principal principal = request.getUserPrincipal();
21
		
22
		final User user = new User();
23
		
24
		if (principal != null) {
25
	        final String username = principal.getName();
26
	        if (username != null) {
27
	        	user.setId(username);
28
	        	user.setFullname(username);
29
	        	user.setPermissionLevels(authorizationDAO.getPermissionLevels(username));
30
	        	if (username.equals(getDefaultSuperAdmin())) {
31
	        		user.getPermissionLevels().add(PermissionLevel.SUPER_ADMIN);
32
	        	}
33
	        } else {
34
	        	user.setId("anonymous");
35
	        	user.setFullname("anonymous");
36
	        	user.setPermissionLevels(Sets.newHashSet(PermissionLevel.GUEST));
37
	        }
38
	    }
39
		
40
		return user;
41
	}
42

  
43
	public AuthorizationDAO getAuthorizationDAO() {
44
		return authorizationDAO;
45
	}
46

  
47
	@Required
48
	public void setAuthorizationDAO(AuthorizationDAO authorizationDAO) {
49
		this.authorizationDAO = authorizationDAO;
50
	}
51

  
52
	public String getDefaultSuperAdmin() {
53
		return defaultSuperAdmin;
54
	}
55

  
56
	@Required
57
	public void setDefaultSuperAdmin(String defaultSuperAdmin) {
58
		this.defaultSuperAdmin = defaultSuperAdmin;
59
	}
60

  
61
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/users/AccessLimited.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
import java.util.Set;
4

  
5
public interface AccessLimited {
6
	public Set<PermissionLevel> getPermissionLevels();
7
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/users/SimpleSSOAuthorizationManager.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
import java.net.URLDecoder;
4
import java.security.KeyFactory;
5
import java.security.PublicKey;
6
import java.security.Signature;
7
import java.security.spec.KeySpec;
8
import java.security.spec.X509EncodedKeySpec;
9
import java.util.Map;
10

  
11
import javax.servlet.http.Cookie;
12
import javax.servlet.http.HttpServletRequest;
13

  
14
import org.apache.commons.codec.binary.Base64;
15
import org.apache.commons.codec.binary.Hex;
16
import org.apache.commons.io.IOUtils;
17
import org.apache.commons.logging.Log;
18
import org.apache.commons.logging.LogFactory;
19
import org.springframework.beans.factory.annotation.Required;
20
import org.springframework.core.io.ClassPathResource;
21
import org.springframework.core.io.Resource;
22

  
23
import com.google.gson.Gson;
24

  
25
public class SimpleSSOAuthorizationManager implements AuthorizationManager {
26

  
27
	private static final Log log = LogFactory.getLog(SimpleSSOAuthorizationManager.class);
28
		
29
	private Resource pubKeyFile = new ClassPathResource("/eu/dnetlib/functionality/modular/ui/users/pubkey.der");
30
	private String pubKeyAlgo = "RSA";
31
	private String signatureAlgo = "SHA1withRSA";
32
	private PublicKey publicKey;
33
	private AuthorizationDAO authorizationDAO;
34
	private String defaultSuperAdmin;
35

  
36
	@Override
37
	public User obtainUserDetails(final HttpServletRequest request) {
38

  
39
		if (request.getCookies() != null) {
40
			for (Cookie cookie : request.getCookies()) {
41
				if (cookie.getName().equalsIgnoreCase("rinfra-user")) {
42
					try {
43
						return processCookie(cookie.getValue());
44
					} catch (Exception e) {
45
						log.error("Error processing cookie: " + cookie.getValue(), e);
46
						return null;
47
					}
48
				}
49
			}
50
		}
51
		return null;
52
	}
53

  
54
	private User processCookie(final String s) throws Exception {
55
		if (s == null || s.isEmpty()) {
56
			return null;
57
		}
58
		final Gson gson = new Gson();
59

  
60
		final Map<?,?> map = gson.fromJson(new String(Base64.decodeBase64(URLDecoder.decode(s.trim(), "UTF-8"))), Map.class);
61
		final String message = (String) map.get("payload");
62
		final String signature = (String) map.get("signature");
63
		if (isValidMessage(message, signature)) {
64
			final Map<?,?> userMap = gson.fromJson(message, Map.class);
65
			if (userMap.containsKey("uid")) {
66
				final String uid = (String) userMap.get("uid");
67
				final User user = new User(uid);
68
				user.setEmail((String) userMap.get("email"));
69
				user.setFullname(userMap.containsKey("fullname") ? (String) userMap.get("fullname") : uid);
70
				user.setPermissionLevels(authorizationDAO.getPermissionLevels(uid));
71
				
72
				if (isDefaultSuperAdmin(uid)) {
73
					user.getPermissionLevels().add(PermissionLevel.SUPER_ADMIN);
74
				}
75
				return user;
76
			}
77
		}
78
		return null;
79
	}
80

  
81
	private boolean isDefaultSuperAdmin(final String uid) {
82
		return (uid != null && !uid.isEmpty() && uid.equals(getDefaultSuperAdmin()));
83
	}
84

  
85
	protected boolean isValidMessage(final String message, final String signature) {
86
		log.info("checking message " + message + " with sig " + signature);
87
		if (message == null || message.isEmpty() || signature == null || signature.isEmpty()) {
88
			log.error("Null  or empty values in message or signature");
89
			return false;
90
		}
91
		
92
		try {
93
			final Signature sg = Signature.getInstance(getSignatureAlgo());
94
			sg.initVerify(getPublicKey());
95
			sg.update(message.getBytes());
96
			return sg.verify(Hex.decodeHex(signature.toCharArray()));
97
		} catch(Exception e) {
98
			log.error("Error verifyng signature", e);
99
			return false;
100
		}
101
	}
102

  
103
	public void init() throws Exception {
104
		final byte[] keyBytes = IOUtils.toByteArray(getPubKeyFile().getInputStream());
105
		final KeySpec spec = new X509EncodedKeySpec(keyBytes);
106
		
107
		setPublicKey(KeyFactory.getInstance(getPubKeyAlgo()).generatePublic(spec));
108
	}
109

  
110
	public Resource getPubKeyFile() {
111
		return pubKeyFile;
112
	}
113
	
114
	@Required
115
	public void setPubKeyFile(Resource pubKeyFile) {
116
		this.pubKeyFile = pubKeyFile;
117
	}
118

  
119
	public String getPubKeyAlgo() {
120
		return pubKeyAlgo;
121
	}
122

  
123
	@Required
124
	public void setPubKeyAlgo(String pubKeyAlgo) {
125
		this.pubKeyAlgo = pubKeyAlgo;
126
	}
127

  
128
	public String getSignatureAlgo() {
129
		return signatureAlgo;
130
	}
131

  
132
	@Required
133
	public void setSignatureAlgo(String signatureAlgo) {
134
		this.signatureAlgo = signatureAlgo;
135
	}
136

  
137
	public PublicKey getPublicKey() {
138
		return publicKey;
139
	}
140

  
141
	public void setPublicKey(PublicKey publicKey) {
142
		this.publicKey = publicKey;
143
	}
144

  
145
	public AuthorizationDAO getAuthorizationDAO() {
146
		return authorizationDAO;
147
	}
148

  
149
	@Required
150
	public void setAuthorizationDAO(AuthorizationDAO authorizationDAO) {
151
		this.authorizationDAO = authorizationDAO;
152
	}
153

  
154
	public String getDefaultSuperAdmin() {
155
		return defaultSuperAdmin;
156
	}
157
	
158
	@Required
159
	public void setDefaultSuperAdmin(String defaultSuperAdmin) {
160
		this.defaultSuperAdmin = defaultSuperAdmin;
161
	}
162

  
163
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/users/AuthorizationManager.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
import javax.servlet.http.HttpServletRequest;
4

  
5
public interface AuthorizationManager {
6
	User obtainUserDetails(HttpServletRequest request);
7
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/users/User.java
1
package eu.dnetlib.functionality.modular.ui.users;
2

  
3
import java.util.Set;
4

  
5
public class User implements Comparable<User> {
6
	private String id;
7
	private String fullname;
8
	private String email;
9
	private Set<PermissionLevel> permissionLevels;
10
	
11
	public User() {}
12
	
13
	public User(final String id) {
14
		this.id = id;
15
	}
16
	
17
	public String getId() {
18
		return id;
19
	}
20
	public void setId(String id) {
21
		this.id = id;
22
	}
23
	public String getFullname() {
24
		return fullname;
25
	}
26
	public void setFullname(String fullname) {
27
		this.fullname = fullname;
28
	}
29
	public String getEmail() {
30
		return email;
31
	}
32
	public void setEmail(String email) {
33
		this.email = email;
34
	}
35
	public Set<PermissionLevel> getPermissionLevels() {
36
		return permissionLevels;
37
	}
38
	public void setPermissionLevels(Set<PermissionLevel> permissionLevels) {
39
		this.permissionLevels = permissionLevels;
40
	}
41
	
42
	@Override
43
	public int compareTo(final User o) {
44
		return getId().compareTo(o.getId());
45
	}
46
	
47
	
48
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/ModuleEntryPoint.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import java.net.URLEncoder;
4

  
5
import javax.annotation.Resource;
6
import javax.servlet.http.HttpServletRequest;
7
import javax.servlet.http.HttpServletResponse;
8

  
9
import org.apache.commons.lang.StringUtils;
10
import org.springframework.beans.factory.BeanNameAware;
11
import org.springframework.beans.factory.annotation.Required;
12
import org.springframework.beans.factory.annotation.Value;
13
import org.springframework.ui.ModelMap;
14
import org.springframework.web.servlet.ModelAndView;
15
import org.springframework.web.servlet.mvc.Controller;
16
import org.springframework.web.servlet.view.RedirectView;
17

  
18
import eu.dnetlib.functionality.modular.ui.users.AuthorizationManager;
19
import eu.dnetlib.functionality.modular.ui.users.User;
20
import eu.dnetlib.functionality.modular.ui.utils.ShutdownUtils;
21

  
22
public abstract class ModuleEntryPoint extends MenuEntry implements Controller, BeanNameAware {
23
	
24
	private String beanName;
25
	
26
	private boolean validMenuEntry = true;
27
	
28
	private String group;
29
	private int groupOrder = 50;
30
	
31
	@Value("${dnet.modular.ui.authentication.url}")
32
	private String authenticationUrl;
33
	
34
	@Value("${dnet.modular.ui.logout.url}")
35
	private String logoutUrl;
36
	
37
	@Resource
38
	protected EntryPointsAggregator aggregator;	
39
	
40
	@Resource
41
	private ShutdownUtils shutdownUtils;
42
	
43
	@Resource(name="modularUiAuthorizationManager")
44
	protected AuthorizationManager authorizationManager;
45
	
46
	@Override
47
	public ModelAndView handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
48
		
49
		
50
		final User user = authorizationManager.obtainUserDetails(request);
51
		if (user != null) {
52
			final ModelAndView mv = new ModelAndView();
53
			final ModelMap map = mv.getModelMap();
54
			map.addAttribute("ui_menu", getMenu());
55
			map.addAttribute("ui_title", getTitle());
56
			map.addAttribute("ui_description", getDescription());
57
			map.addAttribute("ui_group", getGroup());
58
			map.addAttribute("ui_modules", aggregator.getMenus(user));
59
			
60
			switch(shutdownUtils.currentStatus()) {
61
				case STOPPING:
62
					map.addAttribute("ui_navbar_class", "navbar-system-stopping");
63
					map.addAttribute("ui_message", "stopping system");
64
					break;
65
				case STOPPED:
66
					map.addAttribute("ui_navbar_class", "navbar-system-stopped");
67
					map.addAttribute("ui_message", "system stopped");
68
					break;
69
				default:
70
					map.addAttribute("ui_navbar_class", "navbar-inverse");
71
					break;
72
			}
73
			
74
			
75
			
76
	
77
			String baseUrl = "";
78
			for (int i=1; i < StringUtils.countMatches(beanName, "/"); i++) {
79
				baseUrl += "/..";
80
			}
81
			if (baseUrl.length() > 0) {
82
				baseUrl = baseUrl.substring(1);
83
			}
84
			
85
			map.addAttribute("ui_baseUrl", baseUrl);
86
			
87
			if (logoutUrl != null && !logoutUrl.isEmpty()) {
88
				map.addAttribute("ui_logoutUrl", logoutUrl);
89
			}
90
			
91
			map.addAttribute("ui_user", user);
92
			
93
			initialize(map, request, response);
94
			return mv;
95
		} else {
96
			final StringBuffer url = request.getRequestURL();
97
			final String queryString = request.getQueryString();
98
			if (queryString != null) {
99
			    url.append('?');
100
			    url.append(queryString);
101
			}
102
			return new ModelAndView(new RedirectView(authenticationUrl + "?url=" + URLEncoder.encode(url.toString(), "UTF-8")));
103
		}
104
	}
105
	
106
	abstract protected void initialize(ModelMap map, HttpServletRequest request, HttpServletResponse response) throws Exception;
107
	
108
	public String getBeanName() {
109
		return beanName;
110
	}
111
	
112
	@Override
113
	public void setBeanName(String beanName) {
114
		this.beanName = beanName;
115
	}
116
	
117
	public String getGroup() {
118
		return group;
119
	}
120
	@Required
121
	public void setGroup(String group) {
122
		this.group = group;
123
	}
124
	
125
	@Override
126
	public String getRelativeUrl() {
127
		return beanName;
128
	}
129

  
130
	public boolean isValidMenuEntry() {
131
		return validMenuEntry;
132
	}
133

  
134
	public void setValidMenuEntry(boolean validMenuEntry) {
135
		this.validMenuEntry = validMenuEntry;
136
	}
137

  
138
	public int getGroupOrder() {
139
		return groupOrder;
140
	}
141

  
142
	public void setGroupOrder(int groupOrder) {
143
		this.groupOrder = groupOrder;
144
	}
145
	
146
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/MenuEntry.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import java.util.Set;
4

  
5
import org.apache.commons.lang.math.NumberUtils;
6
import org.springframework.beans.factory.annotation.Required;
7

  
8
import eu.dnetlib.functionality.modular.ui.users.AccessLimited;
9
import eu.dnetlib.functionality.modular.ui.users.PermissionLevel;
10

  
11
public abstract class MenuEntry implements Comparable<MenuEntry>, AccessLimited {
12

  
13
	private String menu;
14
	private String title;
15
	private String description;
16
	private int order = 50;
17
	private Set<PermissionLevel> permissionLevels;
18
		
19
	@Override
20
	public int compareTo(MenuEntry o) {
21
		return NumberUtils.compare(this.getOrder(), o.getOrder());
22
	}
23
	
24
	abstract public String getRelativeUrl();
25
	
26
	public String getMenu() {
27
		return menu;
28
	}
29
	
30
	@Required
31
	public void setMenu(String menu) {
32
		this.menu = menu;
33
	}
34

  
35
	public String getTitle() {
36
		return title;
37
	}
38
	@Required
39
	public void setTitle(String title) {
40
		this.title = title;
41
	}
42

  
43
	public String getDescription() {
44
		return description;
45
	}
46
	@Required
47
	public void setDescription(String description) {
48
		this.description = description;
49
	}
50

  
51
	@Override
52
	public Set<PermissionLevel> getPermissionLevels() {
53
		return permissionLevels;
54
	}
55

  
56
	@Required
57
	public void setPermissionLevels(Set<PermissionLevel> permissionLevels) {
58
		this.permissionLevels = permissionLevels;
59
	}
60
	
61
	public int getOrder() {
62
		return order;
63
	}
64

  
65
	public void setOrder(int order) {
66
		this.order = order;
67
	}
68
	
69
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/UserDetailsController.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import javax.servlet.http.HttpServletRequest;
4
import javax.servlet.http.HttpServletResponse;
5

  
6
import org.springframework.ui.ModelMap;
7

  
8
public class UserDetailsController extends ModuleEntryPoint {
9

  
10
	@Override
11
	protected void initialize(ModelMap map, HttpServletRequest request,	HttpServletResponse response) throws Exception {}
12

  
13
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/MainController.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import javax.servlet.http.HttpServletRequest;
4
import javax.servlet.http.HttpServletResponse;
5

  
6
import org.springframework.ui.ModelMap;
7

  
8
public class MainController extends ModuleEntryPoint {
9

  
10
	@Override
11
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) {}
12

  
13
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/AbstractMenu.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import java.util.List;
4

  
5
import org.apache.commons.lang.math.NumberUtils;
6
import org.springframework.beans.factory.annotation.Required;
7

  
8
public abstract class AbstractMenu implements Comparable<AbstractMenu> {
9
	private String title;		
10

  
11
	abstract public int getOrder();
12

  
13
	abstract public List<? extends MenuEntry> getEntries();
14
	
15
	@Override
16
	public int compareTo(final AbstractMenu menu) {
17
		return NumberUtils.compare(getOrder(), menu.getOrder());
18
	}
19

  
20
	public String getTitle() {
21
		return title;
22
	}
23
	
24
	@Required
25
	public void setTitle(String title) {
26
		this.title = title;
27
	}
28
}
29

  
30

  
31

  
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/PrepareShutdownInternalController.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import java.util.List;
4

  
5
import javax.annotation.Resource;
6

  
7
import org.springframework.stereotype.Controller;
8
import org.springframework.web.bind.annotation.RequestMapping;
9
import org.springframework.web.bind.annotation.ResponseBody;
10

  
11
import eu.dnetlib.enabling.common.StoppableDetails;
12
import eu.dnetlib.functionality.modular.ui.utils.ShutdownUtils;
13

  
14
@Controller
15
public class PrepareShutdownInternalController {
16

  
17
	@Resource
18
	private ShutdownUtils shutdownUtils;
19

  
20
	@RequestMapping("/ui/shutdown/listStoppableDetails.json")
21
	public @ResponseBody List<StoppableDetails> listStoppableDetails() {
22
		return shutdownUtils.listStoppableDetails();
23
	}
24
	
25
	@RequestMapping("/ui/shutdown/stopAll.do")
26
	public @ResponseBody boolean stopAll() {
27
		shutdownUtils.stopAll();
28
		return true;
29
	}
30
	
31
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/CommonController.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import java.io.StringReader;
4

  
5
import javax.annotation.Resource;
6
import javax.servlet.http.HttpServletResponse;
7

  
8
import org.apache.commons.io.IOUtils;
9
import org.springframework.stereotype.Controller;
10
import org.springframework.web.bind.annotation.RequestMapping;
11
import org.springframework.web.bind.annotation.RequestParam;
12

  
13
import com.google.gson.Gson;
14

  
15
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
16
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
17
import eu.dnetlib.enabling.tools.ServiceLocator;
18

  
19
@Controller
20
public class CommonController {
21
	
22
	@Resource(name="lookupLocator")
23
	private ServiceLocator<ISLookUpService> lookupLocator;
24

  
25
	@Resource(name="registryLocator")
26
	private ServiceLocator<ISRegistryService> registryLocator;
27

  
28
	@RequestMapping(value="/ui/**/getProfile")
29
	public void getProfile(HttpServletResponse res, 
30
			@RequestParam(value="id", required=true) String id) throws Exception {
31
		res.setContentType("text/xml");
32
		String profile = lookupLocator.getService().getResourceProfile(id);
33
		IOUtils.copy(new StringReader(profile), res.getOutputStream());
34
	}
35
	
36
	@RequestMapping(value="/ui/**/getSchema")
37
	public void getSchema(HttpServletResponse res, 
38
				@RequestParam(value="name", required=true) String name) throws Exception {
39
		res.setContentType("text/xml");
40
		String schema = lookupLocator.getService().getResourceTypeSchema(name);
41
		IOUtils.copy(new StringReader(schema), res.getOutputStream());
42
	}
43
	
44
	@RequestMapping(value="/ui/**/validateProfile")
45
	public void validate(HttpServletResponse res, 
46
			@RequestParam(value="id", required=true) String id) throws Exception {
47
		String newId = registryLocator.getService().validateProfile(id);
48
		IOUtils.copy(new StringReader(new Gson().toJson(newId)), res.getOutputStream());
49
	}
50

  
51
	@RequestMapping(value="/ui/**/invalidateProfile")
52
	public void invalidateProfile(HttpServletResponse res, 
53
			@RequestParam(value="id", required=true) String id) throws Exception {
54
		String newId = registryLocator.getService().invalidateProfile(id);
55
		IOUtils.copy(new StringReader(new Gson().toJson(newId)), res.getOutputStream());
56
	}
57
	
58
	@RequestMapping(value="/ui/**/deleteProfile")
59
	public void deleteProfile(HttpServletResponse res, 
60
			@RequestParam(value="id", required=true) String id) throws Exception {
61
		boolean b = registryLocator.getService().deleteProfile(id);
62
		IOUtils.copy(new StringReader(new Gson().toJson(b)), res.getOutputStream());
63
	}
64
		
65
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/ModulesMenu.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import java.util.Collections;
4
import java.util.List;
5

  
6
import com.google.common.collect.Lists;
7

  
8
public class ModulesMenu extends AbstractMenu {
9

  
10
	private int order = Integer.MAX_VALUE;
11
	
12
	private List<ModuleEntryPoint> entries = Lists.newArrayList();
13
	
14
	public ModulesMenu(final String title) {
15
		super();
16
		setTitle(title);
17
	}
18
	
19
	public void addEntry(final ModuleEntryPoint entry) {
20
		entries.add(entry);
21
	}
22
	
23
	public void complete() {
24
		Collections.sort(entries);
25
		for (ModuleEntryPoint e : entries) {
26
			if (e.getGroupOrder() < this.order) {
27
				this.order = e.getGroupOrder();
28
			}
29
		}
30
	}
31

  
32
	@Override
33
	public int getOrder() {
34
		return order;
35
	}
36

  
37
	@Override
38
	public List<? extends MenuEntry> getEntries() {
39
		return entries;
40
	}
41
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/java/eu/dnetlib/functionality/modular/ui/PrepareShutdownController.java
1
package eu.dnetlib.functionality.modular.ui;
2

  
3
import javax.servlet.http.HttpServletRequest;
4
import javax.servlet.http.HttpServletResponse;
5

  
6
import org.springframework.ui.ModelMap;
7

  
8
public class PrepareShutdownController extends ModuleEntryPoint {
9

  
10
	@Override
11
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {}
12

  
13
}
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/resources/eu/dnetlib/functionality/modular/ui/applicationContext-modular-ui.properties
1
dnet.modular.ui.authorization.manager = mockUserAuthenticationManager
2
dnet.modular.ui.authorization.dao     = mongoAuthorizationDao
3
dnet.modular.ui.authentication.url    = http://146.48.87.97/
4
dnet.modular.ui.logout.url            = http://146.48.87.97/?logout
5
dnet.modular.ui.auth.signature.algo   = SHA1withRSA
6
dnet.modular.ui.auth.pubkey.derFile   = classpath:/eu/dnetlib/functionality/modular/ui/users/pubkey.der
7
dnet.modular.ui.auth.pubkey.algo      = RSA
8
dnet.modular.ui.authorization.default.superAdmin = michele.artini
9
dnet.modular.ui.authorization.mongo.host = localhost
10
dnet.modular.ui.authorization.mongo.port = 27017
11
dnet.modular.ui.authorization.mongo.db = dnet_auth
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/resources/eu/dnetlib/functionality/modular/ui/applicationContext-modular-ui.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
4
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
5

  
6
	<bean id="shutdownUtils" class="eu.dnetlib.functionality.modular.ui.utils.ShutdownUtils"/>
7

  
8
	<bean id="simpleSSOAuthorizationManager" 
9
		class="eu.dnetlib.functionality.modular.ui.users.SimpleSSOAuthorizationManager" 
10
		init-method="init"
11
		p:pubKeyAlgo="${dnet.modular.ui.auth.pubkey.algo}" 
12
		p:pubKeyFile="${dnet.modular.ui.auth.pubkey.derFile}" 
13
		p:signatureAlgo="${dnet.modular.ui.auth.signature.algo}" 
14
		p:authorizationDAO-ref="modularUiAuthorizationDao" 
15
		p:defaultSuperAdmin="${dnet.modular.ui.authorization.default.superAdmin}"/>
16

  
17

  
18
	<bean id="modularUiMongoServer" class="com.mongodb.Mongo">
19
		<constructor-arg index="0" type="com.mongodb.ServerAddress">
20
			<bean class="com.mongodb.ServerAddress">
21
				<constructor-arg index="0" value="${dnet.modular.ui.authorization.mongo.host}" />
22
				<constructor-arg index="1" value="${dnet.modular.ui.authorization.mongo.port}" />
23
			</bean>
24
		</constructor-arg>
25
	</bean>
26

  
27
	<bean id="mongoAuthorizationDao" 
28
		class="eu.dnetlib.functionality.modular.ui.users.MongoAuthorizationDAO">
29
		<property name="db">
30
			<bean factory-bean="modularUiMongoServer" factory-method="getDB">
31
				<constructor-arg index="0" value="${dnet.modular.ui.authorization.mongo.db}" />
32
			</bean>
33
		</property>
34
	</bean> 
35
	
36
	<bean id="mockUserAuthenticationManager" class="eu.dnetlib.functionality.modular.ui.users.MockAuthorizationManager" />
37

  
38
	<bean id="simpleAuthenticationManager" class="eu.dnetlib.functionality.modular.ui.users.SimpleAuthorizationManager" 
39
		p:authorizationDAO-ref="modularUiAuthorizationDao"
40
		p:defaultSuperAdmin="${dnet.modular.ui.authorization.default.superAdmin}"/>	
41

  
42
	<alias name="${dnet.modular.ui.authorization.manager}" alias="modularUiAuthorizationManager"/>
43
	<alias name="${dnet.modular.ui.authorization.dao}" alias="modularUiAuthorizationDao"/>
44

  
45
</beans>
modules/dnet-modular-ui/tags/dnet-modular-ui-2.0.0/src/main/resources/eu/dnetlib/functionality/modular/ui/views/common/master.st
1
<!DOCTYPE html>
2
<html lang="en">
3

  
4
<head>
5
	<title>$if(ui_title)$$ui_title$$else$No title$endif$</title>
6
	<meta charset="utf-8">
7
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
8
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9
	<link rel="stylesheet" type="text/css" media="screen" href="../resources/css/bootstrap-spacelab.min.css">
10
	<link rel="stylesheet" type="text/css" href="../resources/css/custom.css">
11
	<link rel="stylesheet" type="text/css" media="all"   href="../resources/css/jquery.pnotify.default.css">
12
	<script type="text/javascript" src="../resources/js/jquery-1.11.0.min.js" ></script>
13
	<script type="text/javascript" src="../resources/js/bootstrap.min.js" ></script>
14
	<script type="text/javascript" src="../resources/js/spin.js" ></script>
15
	<script type="text/javascript" src="../resources/js/jquery.pnotify.min.js"></script>
16
	<script type="text/javascript" src="../resources/js/custom.js"></script>
17
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
18

  
19
	$header$
20
</head>
21

  
22
<body role="document">
23
	<div class="navbar $ui_navbar_class$ navbar-fixed-top" role="navigation">
24
		<div class="container-fluid">
25
			<!-- Brand and toggle get grouped for better mobile display -->
26
			<div class="navbar-header">
27
				<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapsedNavbar">
28
					<span class="sr-only">Toggle navigation</span>
29
					<span class="icon-bar"></span>
30
					<span class="icon-bar"></span>
31
					<span class="icon-bar"></span>
32
				</button>
33
				<a class="navbar-brand" href="#">D-Net</a>
34
			</div>
35
	
36
			<!-- Collect the nav links, forms, and other content for toggling -->
37
			<div class="collapse navbar-collapse" id="collapsedNavbar">
38
				<ul class="nav navbar-nav">
39
				$ui_modules:{k|
40
				   <li class="dropdown">
41
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">$k.title$ <b class="caret"></b></a>
42
						<ul class="dropdown-menu">
43
							$k.entries:{ep|<li><a href="$ui_baseUrl$$ep.relativeUrl$">$ep.menu$</a></li> }$
44
						</ul>
45
					</li>
46
				}$
47
				</ul>
48
				
49
				$if(ui_user)$
50
					<ul class="nav navbar-nav navbar-right">
51
						<li class="dropdown">
52
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">$ui_user.fullname$ <b
53
									class="caret"></b></a>
54
							<ul class="dropdown-menu">
55
								<li><a href="userDetails.do">details</a></li>
56
								$if(ui_logoutUrl)$
57
									<li class="divider"></li>
58
									<li><a href="$ui_logoutUrl$">logout</a></li>
59
								$endif$
60
							</ul>
61
						</li>
62
					</ul>
63
				$endif$
64
			</div><!-- /.navbar-collapse -->
65
		</div><!-- /.container-fluid -->
66
	</div>
67
	
68
	$if(ui_message)$
69
		<div style="position: absolute; top: -4px; right: 10px; z-index: 99999;
70
			border: 1px solid grey; 
71
			background-color: #ffffff;
72
			padding: 3px 20px;
73
			opacity: 0.9;
74
			border-radius: 6px;
75
			font-size: 11px;">$ui_message$</div>
76
	$endif$
77
	
78
	<!-- Le spinning indicator for operation wait -->
79
	<div id="spinnerdiv" class="overlaydiv">
80
		<span class="grayRectangle"><!--The spinner is added on loading here--></span>
81
	</div>
82

  
83
	<!-- Le main container -->
84
	<div role="main" class="container-fluid" style="margin-top: 40px; margin-bottom: 70px;">
85
		<div class="row">
86
			<div class="col-xs-12">
87
				<h3 class="page-header">$if(ui_title)$$ui_title$$else$No title$endif$</h3>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff