Commit 4ea27d63 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch 'master' into emailvalidation-igoshin

Conflicts:
	pom.xml
	src/main/java/org/genesys2/server/service/UserService.java
	src/main/java/org/genesys2/server/service/impl/UserServiceImpl.java
	src/main/java/org/genesys2/server/servlet/controller/UserProfileController.java
	src/main/resources/spring/spring.properties
	src/main/webapp/WEB-INF/jsp/user/profile.jsp
parents 3211dc28 ce2304ed
...@@ -101,11 +101,6 @@ ...@@ -101,11 +101,6 @@
<version>${commons.beanutils.version}</version> <version>${commons.beanutils.version}</version>
</dependency> </dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons.collections.version}</version>
</dependency>
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
...@@ -352,13 +347,16 @@ ...@@ -352,13 +347,16 @@
<artifactId>spring-aspects</artifactId> <artifactId>spring-aspects</artifactId>
<version>3.2.5.RELEASE</version> <version>3.2.5.RELEASE</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>
<dependency> <dependency>
<groupId>javax.mail</groupId> <groupId>javax.mail</groupId>
<artifactId>mail</artifactId> <artifactId>mail</artifactId>
<version>1.5.0-b01</version> <version>1.5.0-b01</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -26,8 +26,7 @@ public class CountryInfo implements Serializable { ...@@ -26,8 +26,7 @@ public class CountryInfo implements Serializable {
private final boolean active; private final boolean active;
private final Long refnameId; private final Long refnameId;
public CountryInfo(final String iso, final String iso3, public CountryInfo(final String iso, final String iso3, final String isoNum, final String name, final boolean active) {
final String isoNum, final String name, final boolean active) {
this.iso = iso; this.iso = iso;
this.iso3 = iso3; this.iso3 = iso3;
this.isoNum = isoNum; this.isoNum = isoNum;
...@@ -36,9 +35,7 @@ public class CountryInfo implements Serializable { ...@@ -36,9 +35,7 @@ public class CountryInfo implements Serializable {
this.refnameId = null; this.refnameId = null;
} }
public CountryInfo(final String iso, final String iso3, public CountryInfo(final String iso, final String iso3, final String isoNum, final String name, final Long refnameId, final boolean active) {
final String isoNum, final String name, final Long refnameId,
final boolean active) {
this.iso = iso; this.iso = iso;
this.iso3 = iso3; this.iso3 = iso3;
this.isoNum = isoNum; this.isoNum = isoNum;
...@@ -119,8 +116,6 @@ public class CountryInfo implements Serializable { ...@@ -119,8 +116,6 @@ public class CountryInfo implements Serializable {
@Override @Override
public String toString() { public String toString() {
return MessageFormat.format( return MessageFormat.format("Country iso={0} iso3={1} name={2} active={3}", iso, iso3, name, active);
"Country iso={0} iso3={1} name={2} active={3}", iso, iso3,
name, active);
} }
} }
\ No newline at end of file
...@@ -36,7 +36,7 @@ import org.apache.http.impl.client.DefaultHttpClient; ...@@ -36,7 +36,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
/** /**
* Fetch and parse country information from * Fetch and parse country information from
* http://www.davros.org/misc/iso3166.txt * http://www.davros.org/misc/iso3166.txt
* *
* @author mobreza * @author mobreza
*/ */
public class DavrosCountrySource { public class DavrosCountrySource {
...@@ -46,7 +46,7 @@ public class DavrosCountrySource { ...@@ -46,7 +46,7 @@ public class DavrosCountrySource {
/** /**
* Retrieve data from davros.org * Retrieve data from davros.org
* *
* @throws IOException * @throws IOException
*/ */
public static List<CountryInfo> fetchCountryData() throws IOException { public static List<CountryInfo> fetchCountryData() throws IOException {
...@@ -71,8 +71,7 @@ public class DavrosCountrySource { ...@@ -71,8 +71,7 @@ public class DavrosCountrySource {
try { try {
instream = entity.getContent(); instream = entity.getContent();
final BufferedReader inreader = new BufferedReader( final BufferedReader inreader = new BufferedReader(new InputStreamReader(instream));
new InputStreamReader(instream));
final List<CountryInfo> countries = new ArrayList<CountryInfo>(); final List<CountryInfo> countries = new ArrayList<CountryInfo>();
...@@ -85,8 +84,7 @@ public class DavrosCountrySource { ...@@ -85,8 +84,7 @@ public class DavrosCountrySource {
if (line.startsWith("# Table 1: current codes")) { if (line.startsWith("# Table 1: current codes")) {
active = true; active = true;
continue; continue;
} else if (line } else if (line.startsWith("# Table 2: codes withdrawn from use")) {
.startsWith("# Table 2: codes withdrawn from use")) {
active = false; active = false;
continue; continue;
} else if (line.length() == 0) { } else if (line.length() == 0) {
...@@ -116,16 +114,15 @@ public class DavrosCountrySource { ...@@ -116,16 +114,15 @@ public class DavrosCountrySource {
} }
/** /**
* *
* BQ ATB British Antarctic Territory * BQ ATB British Antarctic Territory
* *
* GB GBR 826 United Kingdom of Great Britain & N. Ireland * GB GBR 826 United Kingdom of Great Britain & N. Ireland
* *
* @param line * @param line
* @return * @return
*/ */
public static CountryInfo parseDavros(final String line, public static CountryInfo parseDavros(final String line, final boolean active) {
final boolean active) {
final String a = line.substring(0, 10); final String a = line.substring(0, 10);
final String b = line.substring(11); final String b = line.substring(11);
if (LOG.isTraceEnabled()) { if (LOG.isTraceEnabled()) {
......
...@@ -40,18 +40,17 @@ import au.com.bytecode.opencsv.CSVReader; ...@@ -40,18 +40,17 @@ import au.com.bytecode.opencsv.CSVReader;
/** /**
* Fetch and parse country information from * Fetch and parse country information from
* http://download.geonames.org/export/dump/countryInfo.txt * http://download.geonames.org/export/dump/countryInfo.txt
* *
* @author mobreza * @author mobreza
*/ */
public class GeoNamesCountrySource { public class GeoNamesCountrySource {
private static final String GEONAMES_ISO3166_URL = "http://download.geonames.org/export/dump/countryInfo.txt"; private static final String GEONAMES_ISO3166_URL = "http://download.geonames.org/export/dump/countryInfo.txt";
public static final Log LOG = LogFactory public static final Log LOG = LogFactory.getLog(GeoNamesCountrySource.class);
.getLog(GeoNamesCountrySource.class);
/** /**
* Retrieve data from davros.org * Retrieve data from davros.org
* *
* @throws IOException * @throws IOException
*/ */
public static List<CountryInfo> fetchCountryData() throws IOException { public static List<CountryInfo> fetchCountryData() throws IOException {
...@@ -76,8 +75,7 @@ public class GeoNamesCountrySource { ...@@ -76,8 +75,7 @@ public class GeoNamesCountrySource {
try { try {
instream = entity.getContent(); instream = entity.getContent();
final BufferedReader inreader = new BufferedReader( final BufferedReader inreader = new BufferedReader(new InputStreamReader(instream));
new InputStreamReader(instream));
// Find line that starts with // Find line that starts with
// #ISO ISO3 ISO-Numeric fips // #ISO ISO3 ISO-Numeric fips
...@@ -105,8 +103,7 @@ public class GeoNamesCountrySource { ...@@ -105,8 +103,7 @@ public class GeoNamesCountrySource {
if (StringUtils.isNotBlank(data[16])) { if (StringUtils.isNotBlank(data[16])) {
refnameId = Long.valueOf(data[16]); refnameId = Long.valueOf(data[16]);
} }
final CountryInfo countryInfo = new CountryInfo(data[0], final CountryInfo countryInfo = new CountryInfo(data[0], data[1], data[2], data[4], refnameId, true);
data[1], data[2], data[4], refnameId, true);
if (!countries.contains(countryInfo)) { if (!countries.contains(countryInfo)) {
countries.add(countryInfo); countries.add(countryInfo);
} }
......
...@@ -14,25 +14,24 @@ ...@@ -14,25 +14,24 @@
* limitations under the License. * limitations under the License.
**/ **/
package org.genesys2.server; package org.genesys2.server;
public class ApplicationException extends Exception { public class ApplicationException extends Exception {
private static final long serialVersionUID = 7077761656242902954L; private static final long serialVersionUID = 7077761656242902954L;
public ApplicationException() { public ApplicationException() {
super(); super();
} }
public ApplicationException(String message) { public ApplicationException(String message) {
super(message); super(message);
} }
public ApplicationException(String message, Throwable cause) { public ApplicationException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }
public ApplicationException(Throwable cause) { public ApplicationException(Throwable cause) {
super(cause); super(cause);
} }
} }
...@@ -14,94 +14,92 @@ ...@@ -14,94 +14,92 @@
* limitations under the License. * limitations under the License.
**/ **/
package org.genesys2.server; package org.genesys2.server;
public interface ServiceEndpoints { public interface ServiceEndpoints {
/*===============================================================*/ /* =============================================================== */
/*==================== Service endpoint /me =====================*/ /* ==================== Service endpoint /me ===================== */
/*===============================================================*/ /* =============================================================== */
//Retrieve current User profile
String ME = "/me";
//List Organizations that current User belongs to // Retrieve current User profile
String MY_ORGANIZATIONS = "/me/organizations"; String ME = "/me";
//List DataSets owned by current User // List Organizations that current User belongs to
String MY_DATA_SETS = "/me/datasets"; String MY_ORGANIZATIONS = "/me/organizations";
//List Traits owned by current User // List DataSets owned by current User
String MY_TRAITS = "/me/traits"; String MY_DATA_SETS = "/me/datasets";
/*===============================================================*/ // List Traits owned by current User
/*=============== Service endpoint /organizations ===============*/ String MY_TRAITS = "/me/traits";
/*===============================================================*/
//Lists all Traits associated with Organization $O /* =============================================================== */
String ORGANIZATION_TRAITS = "/organizations/{organizationId}/traits"; /* =============== Service endpoint /organizations =============== */
/* =============================================================== */
//Lists all DataSets associated with Organization $O // Lists all Traits associated with Organization $O
String ORGANIZATION_DATA_SETS = "/organizations/{organizationId}/datasets"; String ORGANIZATION_TRAITS = "/organizations/{organizationId}/traits";
//List all Licenses associated with Organization $O // Lists all DataSets associated with Organization $O
String ORGANIZATION_LICENSES = "/organizations/{organizationId}/licenses"; String ORGANIZATION_DATA_SETS = "/organizations/{organizationId}/datasets";
//Issue a request for current User to join Organization $O // List all Licenses associated with Organization $O
String JOIN_ORGANIZATION = "/organizations/{organizationId}/join"; String ORGANIZATION_LICENSES = "/organizations/{organizationId}/licenses";
/*===============================================================*/ // Issue a request for current User to join Organization $O
/*=============== Service endpoint /traits ======================*/ String JOIN_ORGANIZATION = "/organizations/{organizationId}/join";
/*===============================================================*/
//Lists all Traits available to Current User /* =============================================================== */
String TRAITS = "/traits"; /* =============== Service endpoint /traits ====================== */
/* =============================================================== */
//Remove Trait // Lists all Traits available to Current User
String REMOVE_TRAIT = "/traits/{traitId}"; String TRAITS = "/traits";
/*===============================================================*/ // Remove Trait
/*=============== Service endpoint /licenses ====================*/ String REMOVE_TRAIT = "/traits/{traitId}";
/*===============================================================*/
//Lists all Licenses available to Current User /* =============================================================== */
String LICENSES = "/licenses"; /* =============== Service endpoint /licenses ==================== */
/* =============================================================== */
//Remove License {licenseId} // Lists all Licenses available to Current User
String REMOVE_LICENSE = "/licenses/{licenseId}"; String LICENSES = "/licenses";
// Remove License {licenseId}
String REMOVE_LICENSE = "/licenses/{licenseId}";
/*===============================================================*/ /* =============================================================== */
/*=============== Service endpoint /datasets ====================*/ /* =============== Service endpoint /datasets ==================== */
/*===============================================================*/ /* =============================================================== */
//List available DataSets // List available DataSets
String DATASETS = "/datasets"; String DATASETS = "/datasets";
//Remove data set {dataSetId} // Remove data set {dataSetId}
String REMOVE_DATASET = "/datasets/{dataSetId}"; String REMOVE_DATASET = "/datasets/{dataSetId}";
//Get all Entries of DataSet {dataSetId} // Get all Entries of DataSet {dataSetId}
String DATASET_ENTRIES = "/datasets/{dataSetId}/data"; String DATASET_ENTRIES = "/datasets/{dataSetId}/data";
//Update Entry {dataEntryId} in DataSet {dataSetId} // Update Entry {dataEntryId} in DataSet {dataSetId}
String UPDATE_DATASET_ENTRY = "/datasets/{dataSetId}/data/{dataEntryId}"; String UPDATE_DATASET_ENTRY = "/datasets/{dataSetId}/data/{dataEntryId}";
//Delete Entry {dataEntryId} from DataSet {dataSetId} // Delete Entry {dataEntryId} from DataSet {dataSetId}
String REMOVE_DATASET_ENTRY = "/datasets/{dataSetId}/data/{dataEntryId}"; String REMOVE_DATASET_ENTRY = "/datasets/{dataSetId}/data/{dataEntryId}";
/*===============================================================*/ /* =============================================================== */
/*=============== Service endpoint /tokens ====================*/ /* =============== Service endpoint /tokens ==================== */
/*===============================================================*/ /* =============================================================== */
//List available Tokens // List available Tokens
String LIST_USER_TOKENS = "/users/{username}/list/tokens"; String LIST_USER_TOKENS = "/users/{username}/list/tokens";
String REVOKE_USER_TOKEN = "/users/{username}/tokens/revoke/{token}"; String REVOKE_USER_TOKEN = "/users/{username}/tokens/revoke/{token}";
String LIST_CLIENT_TOKEN = "/clients/{client}/list/tokens"; String LIST_CLIENT_TOKEN = "/clients/{client}/list/tokens";
String REVOKE_CLIENT_TOKEN = "/clients/{client}/tokens/revoke/{token}"; String REVOKE_CLIENT_TOKEN = "/clients/{client}/tokens/revoke/{token}";
} }
...@@ -20,7 +20,7 @@ import org.aspectj.lang.ProceedingJoinPoint; ...@@ -20,7 +20,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.genesys2.server.model.AclAwareModel; import org.genesys2.server.model.AclAwareModel;
import org.genesys2.server.service.AclAssignerService; import org.genesys2.server.service.AclService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -33,7 +33,7 @@ public class AclAssignerAspect { ...@@ -33,7 +33,7 @@ public class AclAssignerAspect {
private static final Logger LOG = LoggerFactory.getLogger(AclAssignerAspect.class); private static final Logger LOG = LoggerFactory.getLogger(AclAssignerAspect.class);
@Autowired @Autowired
private AclAssignerService aclAssignerService; private AclService aclService;
@Around("execution(* org.genesys2.server.persistence.domain.*.save(..))") @Around("execution(* org.genesys2.server.persistence.domain.*.save(..))")
public Object aroundSaveAclObject(ProceedingJoinPoint pjp) throws Throwable { public Object aroundSaveAclObject(ProceedingJoinPoint pjp) throws Throwable {
...@@ -50,7 +50,7 @@ public class AclAssignerAspect { ...@@ -50,7 +50,7 @@ public class AclAssignerAspect {
if (needsAcl) { if (needsAcl) {
AclAwareModel aclModel = (AclAwareModel) retval; AclAwareModel aclModel = (AclAwareModel) retval;
LOG.warn("Inserting ACL entries for owner: " + aclModel.getId()); LOG.warn("Inserting ACL entries for owner: " + aclModel.getId());
aclAssignerService.addCreatorPermissions(aclModel); aclService.addCreatorPermissions(aclModel);
} }
return retval; return retval;
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
**/ **/
package org.genesys2.server.aspect; package org.genesys2.server.aspect;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
...@@ -25,7 +24,7 @@ import java.lang.annotation.Target; ...@@ -25,7 +24,7 @@ import java.lang.annotation.Target;
@Documented @Documented
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD}) @Target({ ElementType.TYPE, ElementType.METHOD })
public @interface AsAdmin { public @interface AsAdmin {
} }
...@@ -48,7 +48,7 @@ public class AsAdminAspect { ...@@ -48,7 +48,7 @@ public class AsAdminAspect {
@Around("org.genesys2.server.aspect.SystemArchitecture.allServices()" + " && @annotation(org.genesys2.server.aspect.AsAdmin)") @Around("org.genesys2.server.aspect.SystemArchitecture.allServices()" + " && @annotation(org.genesys2.server.aspect.AsAdmin)")
public Object authenticateAsAdmin(ProceedingJoinPoint pjp) throws Throwable { public Object authenticateAsAdmin(ProceedingJoinPoint pjp) throws Throwable {
loadSystemAdminAccount("SYSTEM"); getSystemAdminAccount();
// store previous version of auth (if any exists) // store previous version of auth (if any exists)
Authentication prevAuth = SecurityContextHolder.getContext().getAuthentication(); Authentication prevAuth = SecurityContextHolder.getContext().getAuthentication();
...@@ -75,7 +75,7 @@ public class AsAdminAspect { ...@@ -75,7 +75,7 @@ public class AsAdminAspect {
} }
} }
private synchronized void loadSystemAdminAccount(String string) { public synchronized Authentication getSystemAdminAccount() {
if (SYS_ADMIN == null) { if (SYS_ADMIN == null) {
LOG.warn("SYS_ADMIN not loaded. Loading now."); LOG.warn("SYS_ADMIN not loaded. Loading now.");
User sysUser = userService.getSystemUser("SYSTEM"); User sysUser = userService.getSystemUser("SYSTEM");
...@@ -94,6 +94,8 @@ public class AsAdminAspect { ...@@ -94,6 +94,8 @@ public class AsAdminAspect {
SYS_ADMIN = new PreAuthenticatedAuthenticationToken(userDetails, null, userDetails.getAuthorities()); SYS_ADMIN = new PreAuthenticatedAuthenticationToken(userDetails, null, userDetails.getAuthorities());
} }
} }
return SYS_ADMIN;
} }
} }
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
**/ **/
package org.genesys2.server.aspect; package org.genesys2.server.aspect;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
...@@ -23,45 +22,45 @@ import org.aspectj.lang.annotation.Pointcut; ...@@ -23,45 +22,45 @@ import org.aspectj.lang.annotation.Pointcut;
@Aspect @Aspect
public class SystemArchitecture { public class SystemArchitecture {
/** /**
* Securing services pointcuts * Securing services pointcuts
*/ */
@Pointcut("businessServices() || sampleServices() || securityServices() || controllers()") @Pointcut("businessServices() || sampleServices() || securityServices() || controllers()")
public void allServices(){ public void allServices() {
} }
@Pointcut("execution(* org.genesys2.server.service.*.*(..))") @Pointcut("execution(* org.genesys2.server.service.*.*(..))")
public void businessServices(){ public void businessServices() {