Skip to content

Commit

Permalink
Merge pull request #197 from mbarto/ldap_usergroup
Browse files Browse the repository at this point in the history
#195: Initial implementation of read-only LDAP User and UserGroup DAOs
  • Loading branch information
mbarto authored Nov 11, 2019
2 parents 15b4ac8 + a7201d6 commit 6061ba6
Show file tree
Hide file tree
Showing 24 changed files with 1,352 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ public void setRole(Role role) {
*
* @return
*/
@XmlTransient
public boolean isTrusted() {
return trusted;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
package it.geosolutions.geostore.core.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
Expand All @@ -42,7 +42,6 @@
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Index;
Expand Down Expand Up @@ -85,6 +84,22 @@ public class UserGroup implements Serializable {
@Column(nullable = false,updatable =true)
private boolean enabled=true;

private transient List<User> users = new ArrayList<User>();

@XmlTransient
public List<User> getUsers() {
return users;
}

/**
* Users belonging to this UserGroup.
*
* @param users
*/
public void setUsers(List<User> users) {
this.users = users;
}

/**
*
* @return the enabled flag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
*/
package it.geosolutions.geostore.core.model;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import org.junit.Test;

/**
Expand All @@ -39,14 +41,19 @@ public void testMarshallingString() throws Exception {
g0.setGroupName("group name");
g0.setDescription("desciption");
g0.setEnabled(true);


User u0 = new User();
u0.setName("user name");
u0.setEnabled(true);
g0.setUsers(Arrays.asList(u0));

doTheTest(g0);
}

private void doTheTest(UserGroup g0) {
String s = MARSHALER.marshal(g0);
UserGroup ug = MARSHALER.unmarshal(s);

assertEquals(0, ug.getUsers().size());
assertTrue(g0.equals(ug));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2019 GeoSolutions S.A.S.
* http://www.geo-solutions.it
*
* GPLv3 + Classpath exception
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package it.geosolutions.geostore.core.model;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

public class UserTest {
private final static Marshaler<User> MARSHALER = new Marshaler<User>(User.class);

public UserTest() {
}

@Test
public void testMarshallingString() throws Exception {
User u0 = new User();
u0.setName("user name");
u0.setEnabled(true);
u0.setTrusted(true);

doTheTest(u0);
}

private void doTheTest(User u0) {
String s = MARSHALER.marshal(u0);
User u = MARSHALER.unmarshal(s);

assertTrue(u0.equals(u));
assertFalse(u.isTrusted());
}
}
5 changes: 5 additions & 0 deletions src/core/persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>

<!-- =========================================================== -->
<!-- SPRING SECURITY -->
Expand Down
Loading

0 comments on commit 6061ba6

Please sign in to comment.