20
20
import org .orcid .persistence .jpa .entities .EventEntity ;
21
21
import org .orcid .persistence .jpa .entities .EventType ;
22
22
import org .orcid .pojo .ajaxForm .PojoUtil ;
23
- import org .orcid .pojo .ajaxForm .RequestInfoForm ;
24
23
25
24
/**
26
25
*
@@ -45,42 +44,51 @@ public void createEvent(EventType eventType, HttpServletRequest request) {
45
44
46
45
if (request != null ) {
47
46
Boolean isOauth2ScreensRequest = (Boolean ) request .getSession ().getAttribute (OrcidOauth2Constants .OAUTH_2SCREENS );
48
- RequestInfoForm requestInfoForm = (RequestInfoForm ) request .getSession ().getAttribute ("requestInfoForm" );
49
- if (requestInfoForm != null ) {
50
- clientId = requestInfoForm .getClientId ();
51
- label = "OAuth " + requestInfoForm .getMemberName () + " " + requestInfoForm .getClientName ();
52
- } else if (isOauth2ScreensRequest != null && isOauth2ScreensRequest ) {
47
+ if (isOauth2ScreensRequest != null && isOauth2ScreensRequest ) {
53
48
String queryString = (String ) request .getSession ().getAttribute (OrcidOauth2Constants .OAUTH_QUERY_STRING );
54
49
clientId = getParameterValue (queryString , "client_id" );
55
- ClientDetailsEntity clientDetailsEntity = clientDetailsEntityCacheManager .retrieve (clientId );
56
- String memberName = "" ;
57
- String clientName = clientDetailsEntity .getClientName ();
58
-
59
- if (ClientType .PUBLIC_CLIENT .equals (clientDetailsEntity .getClientType ())) {
60
- memberName = "PubApp" ;
61
- } else if (!PojoUtil .isEmpty (clientDetailsEntity .getGroupProfileId ())) {
62
- Name name = recordNameManagerReadOnly .getRecordName (clientDetailsEntity .getGroupProfileId ());
63
- if (name != null ) {
64
- memberName = name .getCreditName () != null ? name .getCreditName ().getContent () : "" ;
65
- }
66
- }
67
-
68
- if (StringUtils .isBlank (memberName )) {
69
- memberName = clientName ;
70
- }
71
- label = "OAuth " + memberName + " " + clientName ;
50
+ label = generateLabel (clientId );
72
51
}
73
52
}
74
53
75
54
EventEntity eventEntity = new EventEntity ();
76
-
77
55
eventEntity .setEventType (eventType .getValue ());
78
56
eventEntity .setClientId (clientId );
79
57
eventEntity .setLabel (label );
80
58
eventEntity .setDateCreated (new Date ());
81
59
eventDao .createEvent (eventEntity );
82
60
}
83
61
62
+ @ Override
63
+ public void createReauthorizeEvent (String clientId ) {
64
+ EventEntity eventEntity = new EventEntity ();
65
+ eventEntity .setEventType (EventType .REAUTHORIZE .getValue ());
66
+ eventEntity .setClientId (clientId );
67
+ eventEntity .setLabel (generateLabel (clientId ));
68
+ eventEntity .setDateCreated (new Date ());
69
+ eventDao .createEvent (eventEntity );
70
+ }
71
+
72
+ private String generateLabel (String clientId ) {
73
+ ClientDetailsEntity clientDetailsEntity = clientDetailsEntityCacheManager .retrieve (clientId );
74
+ String memberName = "" ;
75
+ String clientName = clientDetailsEntity .getClientName ();
76
+
77
+ if (ClientType .PUBLIC_CLIENT .equals (clientDetailsEntity .getClientType ())) {
78
+ memberName = "PubApp" ;
79
+ } else if (!PojoUtil .isEmpty (clientDetailsEntity .getGroupProfileId ())) {
80
+ Name name = recordNameManagerReadOnly .getRecordName (clientDetailsEntity .getGroupProfileId ());
81
+ if (name != null ) {
82
+ memberName = name .getCreditName () != null ? name .getCreditName ().getContent () : "" ;
83
+ }
84
+ }
85
+
86
+ if (StringUtils .isBlank (memberName )) {
87
+ memberName = clientName ;
88
+ }
89
+ return "OAuth " + memberName + " " + clientName ;
90
+ }
91
+
84
92
private String getParameterValue (String queryString , String parameter ) {
85
93
if (StringUtils .isNotEmpty (queryString )) {
86
94
try {
0 commit comments