Project

General

Profile

« Previous | Next » 

Revision 58363

[Uoa-admin-tool|Trunk]

Properties: use classpath instead of path of specific tomcats
Recaptcha: add logs and catch exceptions

View differences:

modules/uoa-admin-tools/trunk/src/test/java/eu/dnetlib/uoaadmintools/CommunityTests.java
1
package eu.dnetlib.uoaadmintools;
2

  
3
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
4
import eu.dnetlib.uoaadmintools.dao.NotificationsDAO;
5
import eu.dnetlib.uoaadmintools.entities.Community;
6
import eu.dnetlib.uoaadmintools.entities.Notifications;
7
import org.junit.Test;
8
import org.junit.runner.RunWith;
9
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.boot.test.context.SpringBootTest;
11
import org.springframework.test.context.junit4.SpringRunner;
12

  
13
import java.util.List;
14

  
15
@RunWith(SpringRunner.class)
16
@SpringBootTest
17
public class CommunityTests {
18

  
19
	@Autowired
20
	private CommunityDAO communityDAO;
21

  
22

  
23

  
24
	@Test
25
	public void test() {
26
		String id="egi";
27
		Community community = communityDAO.findByPid(id);
28
//		community.getPages()
29

  
30

  
31
	}
32

  
33
	@Test
34
	public void remove() {
35
		List <Community> communities = communityDAO.findAll();
36
		for(Community com : communities){
37

  
38
		}
39

  
40
	}
41

  
42
}
modules/uoa-admin-tools/trunk/src/main/java/eu/dnetlib/uoaadmintools/handlers/AuthorizationHandler.java
28 28
            HttpServletResponse response,
29 29
            Object handler) throws Exception {
30 30
//        log.debug("request method " + request.getRemoteHost());
31
        log.debug("properties: " + helper.getOriginServer() + " "+ helper.getUserInfoUrl());
32
        log.debug(allowedPostRequests);
33
        log.debug(allowedPostRequests.contains(request.getServletPath()));
34
        log.debug(request.getServletPath());
31
//        log.debug("properties: " + helper.getOriginServer() + " "+ helper.getUserInfoUrl());
32
//        log.debug(allowedPostRequests);
33
//        log.debug(allowedPostRequests.contains(request.getServletPath()));
34
//        log.debug(request.getServletPath());
35 35
        if((request.getMethod().equals("POST") || request.getMethod().equals("DELETE")) &&
36 36
        !allowedPostRequests.contains(request.getServletPath())) {
37 37
            //TODO check domain & check user info
......
68 68
//        log.info("I am here - afterCompletion ");
69 69
//    }
70 70

  
71
}
71
}
modules/uoa-admin-tools/trunk/src/main/java/eu/dnetlib/uoaadmintools/UoaAdminToolsApplication.java
13 13
@SpringBootApplication
14 14
@PropertySources({
15 15
        @PropertySource("classpath:admintools.properties"),
16
        @PropertySource(value = "file:/usr/share/tomcat7/lib/dnet-override.properties", ignoreResourceNotFound = true),
17
        @PropertySource(value = "file:/var/lib/tomcat_dnet/8380/lib/dnet-override.properties", ignoreResourceNotFound = true),
18
        @PropertySource(value = "file:/var/lib/tomcat8/lib/dnet-override.properties", ignoreResourceNotFound = true)
16
        @PropertySource("classpath:dnet-override.properties")
19 17
})
20 18
@EnableConfigurationProperties({SecurityConfig.class, MailConfig.class, GoogleConfig.class, MongoConfig.class})
21 19
public class UoaAdminToolsApplication {
modules/uoa-admin-tools/trunk/src/main/java/eu/dnetlib/uoaadmintools/entities/Community.java
56 56
        this.entities = entities;
57 57
    }
58 58

  
59
    @Override
60
    public String toString() {
61
        return "Community{" +
62
                "id='" + id + '\'' +
63
                ", pid='" + pid + '\'' +
64
                ", name='" + name + '\'' +
65
                ", pages=" + pages +
66
                ", entities=" + entities +
67
                '}';
68
    }
69

  
59 70
    public String getLayout() {
60 71
        return layout;
61 72
    }
modules/uoa-admin-tools/trunk/src/main/java/eu/dnetlib/uoaadmintools/recaptcha/VerifyRecaptcha.java
3 3
import eu.dnetlib.uoaadmintools.configuration.properties.GoogleConfig;
4 4
import eu.dnetlib.uoaadmintools.entities.GoogleResponse;
5 5
import eu.dnetlib.uoaadmintools.handlers.InvalidReCaptchaException;
6
import org.apache.log4j.Logger;
7
import org.apache.log4j.spi.ErrorCode;
6 8
import org.springframework.beans.factory.annotation.Autowired;
7 9
import org.springframework.beans.factory.annotation.Configurable;
8 10
import org.springframework.boot.web.client.RestTemplateBuilder;
......
17 19
@Service
18 20
@Configurable
19 21
public class VerifyRecaptcha {
20

  
22
    private final Logger log = Logger.getLogger(this.getClass());
21 23
    @Autowired
22 24
    private RestOperations restTemplate;
23 25

  
......
33 35

  
34 36
    public void processResponse(String response) throws InvalidReCaptchaException{
35 37
        if(!responseSanityCheck(response)) {
36
            throw new InvalidReCaptchaException("Response contains invalid characters");
38
            InvalidReCaptchaException e = new InvalidReCaptchaException("Response contains invalid characters");
39
            log.error("Response contains invalid characters", e);
40
            throw e;
37 41
        }
38 42

  
39 43
        URI verifyUri = URI.create(String.format(
......
43 47
        GoogleResponse googleResponse = restTemplate.getForObject(verifyUri, GoogleResponse.class);
44 48

  
45 49
        if(!googleResponse.isSuccess()) {
46
            throw new InvalidReCaptchaException("reCaptcha was not successfully validated");
50
            log.error("Has client error:"+googleResponse.hasClientError());
51
            InvalidReCaptchaException e = new InvalidReCaptchaException("reCaptcha was not successfully validated");
52
            log.error("reCaptcha was not successfully validated", e);
53
            throw e;
47 54
        }
48 55
    }
49 56

  
modules/uoa-admin-tools/trunk/src/main/resources/admintools.properties
1 1
#dev
2
admintool.security.user-info-url = http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=
3
admintool.security.origin-server = .di.uoa.gr
4
admintool.security.posts-allowed = /contact,/contact/
5
admintool.mail.host = smtp.gmail.com
6
admintool.mail.port = 587
7
admintool.mail.auth = true
8
admintool.mail.from = openaire.test@gmail.com
9
admintool.mail.username = openaire.test@gmail.com
10
admintool.mail.password = ...
11
admintool.google.secret = 6LcVtFIUAAAAAIlEaz6Am2PBC3j5lHG7vBo6uW4_
12
admintool.mongodb.host=localhost
13
admintool.mongodb.port=27017
14
admintool.mongodb.database=openaire_admin
2
#admintool.security.userInfoUrl = http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=
3
#admintool.security.originServer = .di.uoa.gr
4
#admintool.security.postsAllowed = /contact,/contact/
5
#admintool.mail.host = smtp.gmail.com
6
#admintool.mail.port = 587
7
#admintool.mail.auth = true
8
#admintool.mail.from = openaire.test@gmail.com
9
#admintool.mail.username = openaire.test@gmail.com
10
#admintool.mail.password =
11
#admintool.google.secret = 6LcVtFIUAAAAAIlEaz6Am2PBC3j5lHG7vBo6uW4_
12
#admintool.mongodb.host=localhost
13
#admintool.mongodb.port=27017
14
#admintool.mongodb.database=openaire_admin
15 15

  
16 16
#beta
17 17
#admintool.security.userInfoUrl =  https://beta.services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=
18 18
#admintool.security.originServer = .openaire.eu
19
#admintool.security.post-allowed = /contact,/contact/
19
#admintool.security.postsAllowed = /contact,/contact/
20 20
#admintool.mail.host = bwnmail.icm.edu.pl
21 21
#admintool.mail.port = 25
22 22
#admintool.mail.auth = false
23 23
#admintool.mail.username = no-reply@openaire.eu
24 24
#admintool.mail.from = no-reply@beta.openaire.eu
25
#admintool.mail.password = ...
25
#admintool.mail.password =
26 26
#admintool.google.secret = 6LezhVIUAAAAAP97HFoWsqU9R1zLKptnA4YBg8FX
27 27
#admintool.mongodb.host=beta.services.openaire.eu
28 28
#admintool.mongodb.port=27017
......
32 32
#production
33 33
#admintool.security.userInfoUrl =  https://services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=
34 34
#admintool.security.originServer = .openaire.eu
35
#admintool.security.post-allowed = /contact,/contact/
36
#admintool.google.secret = 6LcVtFIUAAAAAIlEaz6Am2PBC3j5lHG7vBo6uW4_
35
#admintool.security.postsAllowed = /contact,/contact/
36
#admintool.mail.host = bwnmail.icm.edu.pl
37
#admintool.mail.port = 25
38
#admintool.mail.auth = false
39
#admintool.mail.username = no-reply@openaire.eu
40
#admintool.mail.from = no-reply@www.openaire.eu
41
#admintool.mail.password =
42
#admintool.google.secret = 6LezhVIUAAAAAP97HFoWsqU9R1zLKptnA4YBg8FX
37 43
#admintool.mongodb.host=localhost
38 44
#admintool.mongodb.port=27017
39 45
#admintool.mongodb.database=openaireconnect
40 46
#admintool.mongodb.username=dnet8480
41
#admintool.mongodb.password=...
42

  
47
#admintool.mongodb.password=

Also available in: Unified diff