1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.adminauthenticationoauth2.service;
35
36 import fr.paris.lutece.plugins.adminauthenticationoauth2.business.authentication.AdminOauth2Authentication;
37 import fr.paris.lutece.plugins.oauth2.business.AuthClientConf;
38 import fr.paris.lutece.plugins.oauth2.business.AuthServerConf;
39 import fr.paris.lutece.portal.service.spring.SpringContextService;
40 import fr.paris.lutece.portal.service.util.AppPropertiesService;
41
42
43
44
45 public final class Oauth2Utils
46 {
47
48 public static final String AUTHENTICATION_BEAN_NAME = "adminauthenticationoauth2.authentication";
49 private static final String BEAN_AUTH_SERVER_CONF = "oauth2.server";
50 private static final String BEAN_AUTH_CLIENT_CONF = "oauth2.client";
51
52
53
54 public static final String PROPERTY_USE_PROMPT_NONE = "adminauthenticationoauth2.usePromptNone";
55 public static final String PROPERTY_USE_PROMPT_NONE_WHITE_LISTING_URLS = "adminauthenticationoauth2.usePromptNoneWhiteListingUrls";
56 public static final String PROPERTY_USE_PROMPT_NONE_WHITE_LISTING_HEADERS = "adminauthenticationoauth2.usePromptNoneWhiteListingHeaders";
57 public static final String PROPERTY_VALIDATE_REFRESH_TOKEN = "adminauthenticationoauth2.validateRefreshToken";
58 public static final String PROPERTY_USER_KEY_NAME = "adminauthenticationoauth2.attributeKeyUsername";
59 public static final String PROPERTY_IDENTITY_ATTRIBUTE_KEY = "adminauthenticationoauth2.attributeIdentityKey";
60 public static final String PROPERTY_USER_MAPPING_ATTRIBUTES = "adminauthenticationoauth2.userMappingAttributes";
61 public static final String PROPERTY_EMAIL_ATTRIBUTE_KEY = "adminauthenticationoauth2.attribute.user.business-info.online.email";
62 public static final String PROPERTY_LASTNAME_ATTRIBUTE_KEY = "adminauthenticationoauth2.attribute.user.name.family";
63 public static final String PROPERTY_FIRSTNAME_ATTRIBUTE_KEY = "adminauthenticationoauth2.attribute.user.name.given";
64 public static final String CONSTANT_LUTECE_USER_PROPERTIES_PATH = "adminauthenticationoauth2.attribute";
65
66
67 public static final String OAUTH2_CHANGE_PASSWORD_URL = "adminauthenticationoauth2.url.changePassword";
68 public static final String OAUTH2_NEW_ACCOUNT_URL = "adminauthenticationoauth2.url.newAccount";
69 public static final String OAUTH2_VIEW_ACCOUNT_URL = "adminauthenticationoauth2.url.viewAccount";
70 public static final String OAUTH2_LOST_PASSWORD_URL = "adminauthenticationoauth2.url.lostPassword";
71 public static final String OAUTH2_LOST_LOGIN_URL = "adminauthenticationoauth2.url.lostLogin";
72
73
74 public static final String PROPERTY_AUTH_SERVICE_NAME = "adminauthenticationoauth2.service.name";
75
76
77 public static final String AUTH_DATA_CLIENT_NAME = "authData";
78 public static final String CONSTANT_ACTION_DOLOGOUT = "doLogout";
79 public static final String CONSTANT_BO = "BO";
80 public static final String URL_INTERROGATIVE = "?";
81 public static final String URL_AMPERSAND = "&";
82 public static final String URL_EQUAL = "=";
83 public static final String URL_STAR = "*";
84 public static final String SEPARATOR = ",";
85 public static final String ERROR_TYPE_LOGIN_REQUIRED = "login_required";
86 public static final String REINIT_ERROR_LOGIN = "reinit_error_login";
87 public static final String SESSION_ERROR_LOGIN = "session_error_login";
88 public static final String PARAM_ERROR_LOGIN = "error_login";
89 public static final String PARAMETER_UID = AppPropertiesService.getProperty(PROPERTY_USER_KEY_NAME,"uid");
90
91
92
93 private static AuthServerConf _authServerConf;
94 private static AuthClientConf _authClientConf;
95 private static AdminOauth2Authentication _authService;
96
97
98 private Oauth2Utils( )
99 {
100 }
101
102 public static AuthServerConf getAuthServerConf( )
103 {
104 if ( _authServerConf == null )
105 {
106 _authServerConf = SpringContextService.getBean( BEAN_AUTH_SERVER_CONF );
107 }
108 return _authServerConf;
109 }
110
111 public static AuthClientConf getAuthClientConf( )
112 {
113 if ( _authClientConf == null )
114 {
115 _authClientConf = SpringContextService.getBean( BEAN_AUTH_CLIENT_CONF );
116 }
117 return _authClientConf;
118 }
119
120 static AdminOauth2Authentication getAuthService()
121 {
122 if ( _authService == null )
123 {
124 _authService = SpringContextService.getBean( AUTHENTICATION_BEAN_NAME );
125 }
126 return _authService;
127 }
128 }