Skip to content

Commit

Permalink
Merge pull request #41 from diging/develop
Browse files Browse the repository at this point in the history
Prepare Release
  • Loading branch information
jdamerow authored May 8, 2017
2 parents 8ca361e + 6240aee commit b7eaa04
Show file tree
Hide file tree
Showing 109 changed files with 1,172 additions and 329 deletions.
48 changes: 45 additions & 3 deletions giles-eco/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

<geco.requests.version>0.5</geco.requests.version>
<geco.util.version>0.4.2</geco.util.version>
<geco.september.util.version>0.1</geco.september.util.version>
<geco.september.util.version>0.2</geco.september.util.version>

<tomcat.deploy.path></tomcat.deploy.path>
<tomcat.app.name>geco-giles</tomcat.app.name>
<tomcat.server.id>TomcatServer</tomcat.server.id>
Expand Down Expand Up @@ -61,7 +61,7 @@
<buildNumber></buildNumber>
<log.level>debug</log.level>
<iframing.hostname></iframing.hostname>

<!-- DB config -->
<db.driver>com.mysql.jdbc.Driver</db.driver>
<db.database.url></db.database.url>
Expand All @@ -72,9 +72,22 @@

<!-- Kafka -->
<giles.kafka.hosts>localhost:9092</giles.kafka.hosts>

<!-- Zookeeper -->
<zookeeper.host>localhost</zookeeper.host>
<zookeeper.port>2181</zookeeper.port>

<!-- Solr -->
<giles.freddie.host></giles.freddie.host>

<!-- Notification -->
<email.host></email.host>
<email.port>8080</email.port>
<email.username></email.username>
<email.pw></email.pw>
<email.from></email.from>
<email.enabled>true</email.enabled>

</properties>

<dependencies>
Expand Down Expand Up @@ -465,6 +478,35 @@
<version>${org.springframework-version}</version>
</dependency>

<!-- Java mail -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.5.0-b01</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>2.0</version>
</dependency>

<!-- Curator to connect to Zookeeper -->
<!-- https://mvnrepository.com/artifact/org.apache.curator/curator-framework -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>2.12.0</version>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.node.ObjectNode;

import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.AppTokenCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.AppTokenOnlyCheck;
import edu.asu.diging.gilesecosystem.web.aspects.access.annotations.DocumentAccessCheck;
Expand Down Expand Up @@ -77,6 +79,9 @@ public class RestSecurityAspect {

@Autowired
private List<IChecker> checkers;

@Autowired
private ISystemMessageHandler messageHandler;

private Map<String, IChecker> tokenCheckers;

Expand Down Expand Up @@ -393,28 +398,28 @@ private ResponseEntity<String> checkAuthorization(String token, String provider,
tokenHolder.checkResult = validationResult;
tokenHolder.tokenContents = validationResult.getPayload();
} catch (GeneralSecurityException e) {
logger.error("Security issue with token.", e);
messageHandler.handleMessage("Security issue with token.", e, MessageType.ERROR);
Map<String, String> msgs = new HashMap<String, String>();
msgs.put("errorMsg", e.getLocalizedMessage());
msgs.put("provider", provider);

return generateResponse(msgs, HttpStatus.UNAUTHORIZED);
} catch (IOException e) {
logger.error("Network issue.", e);
messageHandler.handleMessage("Network issue.", e, MessageType.ERROR);
Map<String, String> msgs = new HashMap<String, String>();
msgs.put("errorMsg", e.getLocalizedMessage());
msgs.put("provider", provider);

return generateResponse(msgs, HttpStatus.INTERNAL_SERVER_ERROR);
} catch (InvalidTokenException e) {
logger.error("Token is invalid.", e);
messageHandler.handleMessage("Token is invalid.", e, MessageType.ERROR);
Map<String, String> msgs = new HashMap<String, String>();
msgs.put("errorMsg", e.getLocalizedMessage());
msgs.put("provider", provider);

return generateResponse(msgs, HttpStatus.UNAUTHORIZED);
} catch (ServerMisconfigurationException e) {
logger.error("Server or apps are misconfigured.", e);
messageHandler.handleMessage("Server or apps are misconfigured.", e, MessageType.ERROR);
Map<String, String> msgs = new HashMap<String, String>();
msgs.put("errorMsg", e.getLocalizedMessage());
msgs.put("provider", provider);
Expand Down Expand Up @@ -469,7 +474,7 @@ private ResponseEntity<String> extractUser(User user, IApiTokenContents tokenCon
}

private void fillUser(User filled, User toBeFilled) {
toBeFilled.setAdmin(filled.getIsAdmin());
toBeFilled.setIsAdmin(filled.getIsAdmin());
toBeFilled.setEmail(filled.getEmail());
toBeFilled.setFirstname(filled.getFirstname());
toBeFilled.setLastname(filled.getLastname());
Expand All @@ -491,7 +496,7 @@ private ResponseEntity<String> generateResponse(Map<String, String> msgs, HttpSt
try {
mapper.writeValue(sw, root);
} catch (IOException e) {
logger.error("Could not write json.", e);
messageHandler.handleMessage("Could not write json.", e, MessageType.ERROR);
return new ResponseEntity<String>(
"{\"errorMsg\": \"Could not write json result.\", \"errorCode\": \"errorCode\": \"500\" }",
HttpStatus.INTERNAL_SERVER_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -31,8 +29,6 @@
@Component
public class SecurityAspect {

private Logger logger = LoggerFactory.getLogger(SecurityAspect.class);

@Autowired
private ITransactionalUploadService uploadService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;

import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.web.aspects.access.github.GitHubTemplateFactory;
import edu.asu.diging.gilesecosystem.web.aspects.access.openid.google.CheckerResult;
import edu.asu.diging.gilesecosystem.web.aspects.access.openid.google.ValidationResult;
Expand All @@ -28,7 +30,10 @@ public class GitHubChecker implements IChecker {

@Autowired
private GitHubTemplateFactory templateFactory;


@Autowired
private ISystemMessageHandler messageHandler;

@Override
public String getId() {
return ID;
Expand All @@ -49,7 +54,7 @@ public CheckerResult validateToken(String token, String appId) throws GeneralSec
result.setPayload(contents);
result.setResult(ValidationResult.VALID);
} catch (RestClientException ex) {
logger.warn("Could not authenticate user with GitHub.", ex);
messageHandler.handleMessage("Could not authenticate user with GitHub", ex, MessageType.WARNING);
// validation result already set
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.apps.IRegisteredApp;
import edu.asu.diging.gilesecosystem.web.aspects.access.openid.google.Checker;
import edu.asu.diging.gilesecosystem.web.aspects.access.openid.google.CheckerResult;
Expand All @@ -19,9 +18,6 @@ public class GoogleChecker implements IChecker {

public final static String ID = "GOOGLE";

@Autowired
private IPropertiesManager propertiesManager;

@Autowired
private IRegisteredAppManager appsManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.nimbusds.jose.util.Base64;

import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.septemberutil.service.impl.SystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
import edu.asu.diging.gilesecosystem.web.service.properties.Properties;
Expand All @@ -28,7 +29,7 @@
*
*/
@Configuration
public class GilesTokenConfig {
public class GilesConfig {

@Autowired
private IPropertiesManager propertyManager;
Expand All @@ -55,7 +56,7 @@ protected ClientHttpRequest createRequest(URI url, HttpMethod method) throws IOE
}

@Bean
public SystemMessageHandler getMessageHandler() {
public ISystemMessageHandler getMessageHandler() {
return new SystemMessageHandler(propertyManager.getProperty(Properties.APPLICATION_ID));
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package edu.asu.diging.gilesecosystem.web.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionSignUp;

import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.users.IUserManager;
import edu.asu.diging.gilesecosystem.web.users.User;

public class GilesConnectionSignUp implements ConnectionSignUp {

private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private ISystemMessageHandler messageHandler;

private IUserManager userManager;
private IUserHelper userHelper;
Expand All @@ -28,7 +30,7 @@ public String execute(Connection<?> connection) {
try {
userManager.addUser(user);
} catch (UnstorableObjectException e) {
logger.error("Could not store user.", e);
messageHandler.handleMessage("Could not store user.", e, MessageType.ERROR);
return null;
}
return user.getUsername();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import edu.asu.diging.gilesecosystem.web.users.IAdminUserDetailsService;
import edu.asu.diging.gilesecosystem.web.users.LocalUserDetailsService;
import edu.asu.diging.gilesecosystem.web.users.SimpleSocialUserDetailsService;
import edu.asu.diging.gilesecosystem.web.users.impl.AdminUserDetailsService;

@Configuration
@EnableWebSecurity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
Expand All @@ -17,14 +16,17 @@
import org.springframework.social.connect.web.SignInAdapter;
import org.springframework.web.context.request.NativeWebRequest;

import edu.asu.diging.gilesecosystem.septemberutil.properties.MessageType;
import edu.asu.diging.gilesecosystem.septemberutil.service.ISystemMessageHandler;
import edu.asu.diging.gilesecosystem.util.exceptions.UnstorableObjectException;
import edu.asu.diging.gilesecosystem.web.users.GilesGrantedAuthority;
import edu.asu.diging.gilesecosystem.web.users.IUserManager;
import edu.asu.diging.gilesecosystem.web.users.User;

public final class SimpleSignInAdapter implements SignInAdapter {

private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private ISystemMessageHandler messageHandler;

private IUserManager userManager;
private IUserHelper userHelper;
Expand All @@ -48,7 +50,7 @@ public String signIn(String userId, Connection<?> connection,
try {
userManager.addUser(user);
} catch (UnstorableObjectException e) {
logger.error("Could not add user.", e);
messageHandler.handleMessage("Could not add user.", e, MessageType.ERROR);
user = null;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository;
import org.springframework.social.connect.web.ProviderSignInController;
import org.springframework.social.github.api.GitHub;
import org.springframework.social.github.connect.GitHubConnectionFactory;
import org.springframework.social.google.api.Google;
import org.springframework.social.google.connect.GoogleConnectionFactory;
import org.springframework.social.mitreidconnect.api.MitreidConnect;
import org.springframework.social.mitreidconnect.connect.MitreidConnectConnectionFactory;
import org.springframework.social.security.AuthenticationNameUserIdSource;

import edu.asu.diging.gilesecosystem.util.properties.IPropertiesManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package edu.asu.diging.gilesecosystem.web.config.social;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.social.ServiceProvider;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.Connection;
Expand All @@ -20,8 +18,6 @@

public class AdjustableGithubConnectionFactory extends OAuth2ConnectionFactory<GitHub> implements IAdjustableConnectionFactory<GitHub> {

private final Logger logger = LoggerFactory.getLogger(getClass());

private GitHubConnectionFactory delegate;

public AdjustableGithubConnectionFactory(String providerId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package edu.asu.diging.gilesecosystem.web.config.social;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.social.ServiceProvider;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionData;
import org.springframework.social.connect.support.OAuth2ConnectionFactory;
import org.springframework.social.github.api.GitHub;
import org.springframework.social.google.api.Google;
import org.springframework.social.google.connect.GoogleAdapter;
import org.springframework.social.google.connect.GoogleConnectionFactory;
Expand All @@ -21,8 +18,6 @@

public class AdjustableGoogleConnectionFactory extends OAuth2ConnectionFactory<Google> implements IAdjustableConnectionFactory<Google> {

private final Logger logger = LoggerFactory.getLogger(getClass());

private GoogleConnectionFactory delegate;

public AdjustableGoogleConnectionFactory(String providerId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package edu.asu.diging.gilesecosystem.web.config.social;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.social.ServiceProvider;
import org.springframework.social.connect.ApiAdapter;
import org.springframework.social.connect.Connection;
Expand All @@ -21,8 +19,6 @@

public class AdjustableMitreidConnectionFactory extends OAuth2ConnectionFactory<MitreidConnect> implements IAdjustableConnectionFactory<MitreidConnect> {

private final Logger logger = LoggerFactory.getLogger(getClass());

private MitreidConnectConnectionFactory delegate;
private String providerUrl;

Expand Down
Loading

0 comments on commit b7eaa04

Please sign in to comment.