@@ -83,17 +83,16 @@ public ProxyStatisticsFilter(PerunRequestFilterParams params) {
83
83
this .mitreIdStats = beanUtil .getBean ("mitreIdStats" , DataSource .class );
84
84
this .samlProperties = beanUtil .getBean (SamlProperties .class );
85
85
86
- Properties props = params .getProperties ();
87
- this .idpNameAttributeName = props .getProperty (IDP_NAME_ATTRIBUTE_NAME ,
86
+ this .idpNameAttributeName = params .getProperty (IDP_NAME_ATTRIBUTE_NAME ,
88
87
"urn:cesnet:proxyidp:attribute:sourceIdPName" );
89
- this .idpEntityIdAttributeName = props .getProperty (IDP_ENTITY_ID_ATTRIBUTE_NAME ,
88
+ this .idpEntityIdAttributeName = params .getProperty (IDP_ENTITY_ID_ATTRIBUTE_NAME ,
90
89
"urn:cesnet:proxyidp:attribute:sourceIdPEntityID" );
91
- this .statisticsTableName = props .getProperty (STATISTICS_TABLE_NAME , "statistics_per_user" );
92
- this .identityProvidersMapTableName = props .getProperty (IDENTITY_PROVIDERS_MAP_TABLE_NAME , "statistics_idp" );
93
- this .serviceProvidersMapTableName = props .getProperty (SERVICE_PROVIDERS_MAP_TABLE_NAME , "statistics_sp" );
94
- this .idpIdColumnName = props .getProperty (IDP_ID_COLUMN_NAME , "idpId" );
95
- this .spIdColumnName = props .getProperty (SP_ID_COLUMN_NAME , "spId" );
96
- this .usernameColumnName = props .getProperty (USERNAME_COLUMN_NAME , "user" );
90
+ this .statisticsTableName = params .getProperty (STATISTICS_TABLE_NAME , "statistics_per_user" );
91
+ this .identityProvidersMapTableName = params .getProperty (IDENTITY_PROVIDERS_MAP_TABLE_NAME , "statistics_idp" );
92
+ this .serviceProvidersMapTableName = params .getProperty (SERVICE_PROVIDERS_MAP_TABLE_NAME , "statistics_sp" );
93
+ this .idpIdColumnName = params .getProperty (IDP_ID_COLUMN_NAME , "idpId" );
94
+ this .spIdColumnName = params .getProperty (SP_ID_COLUMN_NAME , "spId" );
95
+ this .usernameColumnName = params .getProperty (USERNAME_COLUMN_NAME , "user" );
97
96
this .filterName = params .getFilterName ();
98
97
}
99
98
@@ -156,7 +155,8 @@ private void insertOrUpdateLogin(String idpEntityId, String idpName, String spId
156
155
if (spId == null ) {
157
156
return ;
158
157
}
159
- log .trace ("{} - Extracted IDs for SP and IdP: spId={}, idpId ={}" , filterName , spId , idpId );
158
+ log .trace ("{} - Extracted IDs for SP and IdP: spId={}({}), idpId={}({})" ,
159
+ filterName , spId , spIdentifier , idpId , idpEntityId );
160
160
insertOrUpdateLogin (c , idpId , spId , userId );
161
161
} catch (SQLException ex ) {
162
162
log .warn ("{} - caught SQLException" , filterName );
@@ -177,12 +177,14 @@ private boolean fetchLogin(Connection c, Long idpId, Long spId, String userId) {
177
177
String query = "SELECT COUNT(*) AS res FROM " + statisticsTableName +
178
178
" WHERE " + idpIdColumnName + " = ?" +
179
179
" AND " + spIdColumnName + " = ?" +
180
- " AND " + usernameColumnName + " = ?" ;
180
+ " AND " + usernameColumnName + " = ?" +
181
+ " AND day = ?" ;
181
182
182
183
try (PreparedStatement ps = c .prepareStatement (query )) {
183
184
ps .setLong (1 , idpId );
184
185
ps .setLong (2 , spId );
185
186
ps .setString (3 , userId );
187
+ ps .setDate (4 , Date .valueOf (LocalDate .now ()));
186
188
ResultSet rs = ps .executeQuery ();
187
189
if (rs .next ()) {
188
190
return rs .getInt ("res" ) > 0 ;
@@ -301,7 +303,8 @@ private void insertLogin(Connection c, Long idpId, Long spId, String userId) {
301
303
ps .setLong (3 , spId );
302
304
ps .setString (4 , userId );
303
305
ps .execute ();
304
- log .debug ("{} - login inserted" , filterName );
306
+ log .debug ("{} - Inserted first login for combination: idpId={}, spId={}, userId={}" ,
307
+ filterName , idpId , spId , userId );
305
308
} catch (SQLException ex ) {
306
309
log .warn ("{} - caught SQLException when inserting login entry" , filterName );
307
310
log .debug ("{} - details:" , filterName , ex );
@@ -321,8 +324,8 @@ private void updateLogin(Connection c, Long idpId, Long spId, String userId) {
321
324
ps .setLong (2 , idpId );
322
325
ps .setLong (3 , spId );
323
326
ps .setString (4 , userId );
324
- ps . execute ();
325
- log . debug ( "{} - login updated" , filterName );
327
+ log . debug ( "{} - Updated login count by 1 for combination: idpId={}, spId={}, userId={}" ,
328
+ filterName , idpId , spId , userId );
326
329
} catch (SQLException ex ) {
327
330
log .warn ("{} - caught SQLException when updating login entry" , filterName );
328
331
log .debug ("{} - details:" , filterName , ex );
0 commit comments