-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 8875-update-the-email-verification-schedule-…
…to-send-emails-2-7-and-28-days-after-email-creation
- Loading branch information
Showing
101 changed files
with
1,198 additions
and
8,448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
orcid-core/src/main/java/org/orcid/core/common/manager/EventManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.orcid.core.common.manager; | ||
|
||
import org.orcid.core.utils.EventType; | ||
import org.orcid.pojo.ajaxForm.RequestInfoForm; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
/** | ||
* | ||
* @author Daniel Palafox | ||
* | ||
*/ | ||
public interface EventManager { | ||
|
||
boolean removeEvents(String orcid); | ||
|
||
void createEvent(String orcid, EventType eventType, HttpServletRequest request, RequestInfoForm requestInfoForm); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
orcid-core/src/main/java/org/orcid/core/common/manager/impl/EventManagerImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package org.orcid.core.common.manager.impl; | ||
|
||
import javax.annotation.Resource; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
import org.orcid.core.common.manager.EventManager; | ||
import org.orcid.core.constants.OrcidOauth2Constants; | ||
import org.orcid.core.manager.ClientDetailsEntityCacheManager; | ||
import org.orcid.core.utils.EventType; | ||
import org.orcid.persistence.dao.EventDao; | ||
import org.orcid.persistence.jpa.entities.ClientDetailsEntity; | ||
import org.orcid.persistence.jpa.entities.EventEntity; | ||
import org.orcid.pojo.ajaxForm.RequestInfoForm; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLDecoder; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
/** | ||
* | ||
* @author Daniel Palafox | ||
* | ||
*/ | ||
public class EventManagerImpl implements EventManager { | ||
|
||
@Resource | ||
private EventDao eventDao; | ||
|
||
@Resource | ||
private ClientDetailsEntityCacheManager clientDetailsEntityCacheManager; | ||
|
||
@Override | ||
public boolean removeEvents(String orcid) { | ||
return eventDao.removeEvents(orcid); | ||
} | ||
|
||
@Override | ||
public void createEvent(String orcid, EventType eventType, HttpServletRequest request, RequestInfoForm requestInfoForm) { | ||
String label = "Website"; | ||
String clientId = null; | ||
String redirectUrl = null; | ||
String publicPage = null; | ||
|
||
switch (eventType) { | ||
case PUBLIC_PAGE: | ||
publicPage = orcid; | ||
orcid = null; | ||
break; | ||
case REAUTHORIZE: | ||
clientId = requestInfoForm.getClientId(); | ||
redirectUrl = requestInfoForm.getRedirectUrl(); | ||
label = "OAuth " + requestInfoForm.getClientName(); | ||
break; | ||
default: | ||
if (request != null) { | ||
Boolean isOauth2ScreensRequest = (Boolean) request.getSession().getAttribute(OrcidOauth2Constants.OAUTH_2SCREENS); | ||
if (isOauth2ScreensRequest != null && isOauth2ScreensRequest) { | ||
String queryString = (String) request.getSession().getAttribute(OrcidOauth2Constants.OAUTH_QUERY_STRING); | ||
clientId = getParameterValue(queryString, "client_id"); | ||
redirectUrl = getParameterValue(queryString, "redirect_uri"); | ||
ClientDetailsEntity clientDetailsEntity = clientDetailsEntityCacheManager.retrieve(clientId); | ||
label = "OAuth " + clientDetailsEntity.getClientName(); | ||
} | ||
} | ||
} | ||
|
||
EventEntity eventEntity = new EventEntity(); | ||
|
||
eventEntity.setOrcid(orcid); | ||
eventEntity.setEventType(eventType.getValue()); | ||
eventEntity.setClientId(clientId); | ||
eventEntity.setRedirectUrl(redirectUrl); | ||
eventEntity.setLabel(label); | ||
eventEntity.setPublicPage(publicPage); | ||
|
||
eventDao.createEvent(eventEntity); | ||
} | ||
|
||
private String getParameterValue(String queryString, String parameter) { | ||
if (StringUtils.isNotEmpty(queryString)) { | ||
try { | ||
queryString = URLDecoder.decode(queryString, StandardCharsets.UTF_8.toString()); | ||
} catch (UnsupportedEncodingException u) { | ||
// l | ||
} | ||
String[] parameters = queryString.split("&"); | ||
for (String p : parameters) { | ||
String[] keyValuePair = p.split("="); | ||
if (parameter.equals(keyValuePair[0])) { | ||
return keyValuePair[1]; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.