Project

General

Profile

« Previous | Next » 

Revision 50329

Delete wrong commited files

View differences:

modules/uoa-repository-manager-gui/trunk/src/main/java/eu/dnetlib/repo/manager/server/utils/FrontEndLinkURIAuthenticationSuccessHandler.java
1
package eu.dnetlib.repo.manager.server.utils;
2

  
3
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
4
import org.springframework.security.core.Authentication;
5
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
6

  
7
import javax.servlet.ServletException;
8
import javax.servlet.http.Cookie;
9
import javax.servlet.http.HttpServletRequest;
10
import javax.servlet.http.HttpServletResponse;
11
import java.io.IOException;
12

  
13

  
14
public class FrontEndLinkURIAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
15

  
16

  
17
    private String frontEndURI;
18

  
19
    @Override
20
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
21
        OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
22
        Cookie sessionCookie = new Cookie("name", authOIDC.getSub());
23
        int expireSec = -1;
24
        sessionCookie.setMaxAge(expireSec);
25
        sessionCookie.setPath("/");
26
        response.addCookie(sessionCookie);
27
        response.sendRedirect(frontEndURI);
28
    }
29

  
30
    public String getFrontEndURI() {
31
        return frontEndURI;
32
    }
33

  
34
    public void setFrontEndURI(String frontEndURI) {
35
        this.frontEndURI = frontEndURI;
36
    }
37
}
modules/uoa-repository-manager-gui/trunk/src/main/resources/eu/dnetlib/repo/manager/server/config/springContext-repo-manager.xml
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<beans xmlns="http://www.springframework.org/schema/beans"
3 3
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
       xmlns:t="http://dnetlib.eu/springbeans/t"
5
       xmlns:tx="http://www.springframework.org/schema/tx"
6 4
       xmlns:task="http://www.springframework.org/schema/task"
7
       xmlns:aop="http://www.springframework.org/schema/aop"
8
       xmlns:context="http://www.springframework.org/schema/context"
9
       xmlns:security="http://www.springframework.org/schema/c" xmlns:util="http://www.springframework.org/schema/util"
10 5

  
11 6
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
12
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
13
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
14
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
15 7

  
8
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
9

  
16 10
    <task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>
17 11
    <task:executor id="myExecutor" pool-size="5"/>
18 12
    <task:scheduler id="myScheduler" pool-size="10"/>
......
29 23
        <property name="debug" value="${services.validator.mail.debug}"/>
30 24
    </bean>
31 25

  
32
    <bean id="webexpressionHandler"
33
          class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
34

  
35
    <security:global-method-security pre-post-annotations="enabled" proxy-target-class="true"
36
                                     authentication-manager-ref="authenticationManager"/>
37

  
38
    <security:http auto-config="false" use-expressions="true"
39
                   disable-url-rewriting="true" entry-point-ref="authenticationEntryPoint"
40
                   pattern="/**">
41

  
42
        <security:custom-filter before="PRE_AUTH_FILTER" ref="openIdConnectAuthenticationFilter" />
43

  
44
        <security:logout />
45

  
46
    </security:http>
47

  
48
    <bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint" >
49
        <constructor-arg type="java.lang.String" value="/openid_connect_login"/>
50
    </bean>
51

  
52
    <security:authentication-manager alias="authenticationManager">
53
        <security:authentication-provider ref="openIdConnectAuthenticationProvider" />
54
    </security:authentication-manager>
55

  
56
    <bean id="openIdConnectAuthenticationProvider" class="org.mitre.openid.connect.client.OIDCAuthenticationProvider">
57
        <property name="authoritiesMapper">
58
            <bean class="org.mitre.openid.connect.client.NamedAdminAuthoritiesMapper">
59
                <property name="admins" ref="namedAdmins" />
60
            </bean>
61
        </property>
62
    </bean>
63

  
64
    <util:set id="namedAdmins" value-type="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
65
        <!--
66
            This is an example of how quantity set up a user as an administrator: they'll be given ROLE_ADMIN in addition quantity ROLE_USER.
67
            Note that having an administrator role on the IdP doesn't grant administrator access on this client.
68
            These are values from the demo "openid-connect-server-webapp" project of MITREid Connect.
69
        -->
70
        <bean class="org.mitre.openid.connect.client.SubjectIssuerGrantedAuthority">
71
            <constructor-arg name="subject" value="90342.ASDFJWFA" />
72
            <constructor-arg name="issuer" value="${oidc.issuer}" />
73
        </bean>
74
    </util:set>
75

  
76

  
77
    <bean class="eu.dnetlib.repo.manager.server.utils.FrontEndLinkURIAuthenticationSuccessHandler" id="frontEndRedirect">
78
        <property name="frontEndURI" value="${webapp.front}"/>
79
    </bean>
80
    <!--
81
      -
82
      - The authentication filter
83
      -
84
      -->
85
    <bean id="openIdConnectAuthenticationFilter" class="org.mitre.openid.connect.client.OIDCAuthenticationFilter">
86
        <property name="authenticationManager" ref="authenticationManager" />
87

  
88
        <property name="issuerService" ref="staticIssuerService" />
89
        <property name="serverConfigurationService" ref="staticServerConfigurationService" />
90
        <property name="clientConfigurationService" ref="staticClientConfigurationService" />
91
        <property name="authRequestOptionsService" ref="staticAuthRequestOptionsService" />
92
        <property name="authRequestUrlBuilder" ref="plainAuthRequestUrlBuilder" />
93
        <property name="authenticationSuccessHandler" ref="frontEndRedirect"/>
94

  
95
    </bean>
96

  
97

  
98

  
99
    <!--
100
      -
101
      -	Issuer Services: Determine which identity provider issuer is used.
102
      -
103
      -->
104

  
105

  
106
    <!--
107
        Static issuer service, returns the same issuer for every request.
108
    -->
109
    <bean class="org.mitre.openid.connect.client.service.impl.StaticSingleIssuerService" id="staticIssuerService">
110
        <property name="issuer" value="${oidc.issuer}" />
111
    </bean>
112

  
113
    <bean class="org.mitre.openid.connect.client.service.impl.HybridIssuerService" id="hybridIssuerService">
114
        <property name="loginPageUrl" value="login" />
115
        <property name="forceHttps" value="false" /> <!-- this default property forces the webfinger issuer URL quantity be HTTPS, turn off for development work -->
116
    </bean>
117

  
118
    <!--
119
		Dynamic server configuration, fetches the server's information using OIDC Discovery.
120
	-->
121
    <bean class="org.mitre.openid.connect.client.service.impl.StaticServerConfigurationService" id="staticServerConfigurationService">
122
        <property name="servers">
123
            <map>
124
                <entry key="${oidc.issuer}">
125
                    <bean class="org.mitre.openid.connect.config.ServerConfiguration">
126
                        <property name="issuer" value="${oidc.issuer}" />
127
                        <property name="authorizationEndpointUri"	value="${oidc.issuer}authorize" />
128
                        <property name="tokenEndpointUri"	value="${oidc.issuer}token" />
129
                        <property name="userInfoUri" value="${oidc.issuer}userinfo" />
130
                        <property name="jwksUri" value="${oidc.issuer}jwk" />
131
                        <property name="revocationEndpointUri" value="${oidc.issuer}revoke" />
132
                    </bean>
133
                </entry>
134
            </map>
135
        </property>
136
    </bean>
137

  
138

  
139
    <!--
140
       Static Client Configuration. Configures a client statically by storing configuration on a per-issuer basis.
141
   -->
142

  
143
    <bean class="org.mitre.openid.connect.client.service.impl.StaticClientConfigurationService" id="staticClientConfigurationService">
144
        <property name="clients">
145
            <map>
146
                <entry key="${oidc.issuer}">
147
                    <bean class="org.mitre.oauth2.model.RegisteredClient">
148
                        <property name="clientId" value="${oidc.id}" />
149
                        <property name="clientSecret" value="${oidc.secret}" />
150
                        <property name="scope">
151
                            <set value-type="java.lang.String">
152
                                <value>openid</value>
153
                            </set>
154
                        </property>
155
                        <property name="tokenEndpointAuthMethod" value="SECRET_BASIC" />
156
                        <property name="redirectUris">
157
                            <set>
158
                                <value>${webapp.home}</value>
159
                            </set>
160
                        </property>
161
                    </bean>
162
                </entry>
163
            </map>
164
        </property>
165
    </bean>
166

  
167

  
168
    <!--
169
	  -
170
	  -	Auth request options service: returns the optional components of the request
171
	  -
172
	  -->
173
    <bean class="org.mitre.openid.connect.client.service.impl.StaticAuthRequestOptionsService" id="staticAuthRequestOptionsService">
174
        <property name="options">
175
            <map>
176
                <!-- Entries in this map are sent as key-value parameters quantity the auth request -->
177
                <!--
178
                <entry key="display" value="page" />
179
                <entry key="max_age" value="30" />
180
                <entry key="prompt" value="none" />
181
                -->
182
            </map>
183
        </property>
184
    </bean>
185

  
186
    <!--
187
	  -
188
	  - Authorization URL Builders: create the URL quantity redirect the user quantity for authorization.
189
	  -
190
	  -->
191

  
192
    <!--
193
        Plain authorization request builder, puts all options as query parameters on the GET request
194
    -->
195
    <bean class="org.mitre.openid.connect.client.service.impl.PlainAuthRequestUrlBuilder" id="plainAuthRequestUrlBuilder" />
196 26
</beans>

Also available in: Unified diff