updated to auth2

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-mail-servlet@131298 82a268e6-3cf1-43bd-a215-b396298e98cf
Feature/21689
Massimiliano Assante 8 years ago
parent 8c82d67edd
commit 85d8ec87d2

@ -2,6 +2,7 @@
<Changeset component="org.gcube.portal.social-mail-servlet.2-1-0" <Changeset component="org.gcube.portal.social-mail-servlet.2-1-0"
date="2016-08-31"> date="2016-08-31">
<Change>Added possibility to change poller time at runtime as well as to quit it by editing a property file in the server</Change> <Change>Added possibility to change poller time at runtime as well as to quit it by editing a property file in the server</Change>
<Change>Added support for Auth2</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.portal.social-mail-servlet.1-4-0" <Changeset component="org.gcube.portal.social-mail-servlet.1-4-0"
date="2016-02-29"> date="2016-02-29">

@ -35,6 +35,7 @@ import org.gcube.applicationsupportlayer.social.mailing.AppType;
import org.gcube.applicationsupportlayer.social.mailing.SocialMailingUtil; import org.gcube.applicationsupportlayer.social.mailing.SocialMailingUtil;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.common.homelibrary.home.HomeLibrary; import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException; import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
@ -181,7 +182,7 @@ public class PeriodicTask implements Runnable {
} }
private final static String DEFAULT_ROLE = "OrganizationMember"; private final static String DEFAULT_ROLE = "OrganizationMember";
private static void setAuthorizationToken(ASLSession session) { private static void setAuthorizationToken(ASLSession session) throws Exception {
String username = session.getUsername(); String username = session.getUsername();
String scope = session.getScope(); String scope = session.getScope();
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
@ -189,10 +190,11 @@ public class PeriodicTask implements Runnable {
List<String> userRoles = new ArrayList<>(); List<String> userRoles = new ArrayList<>();
userRoles.add(DEFAULT_ROLE); userRoles.add(DEFAULT_ROLE);
session.setSecurityToken(null); session.setSecurityToken(null);
String token = authorizationService().build().generate(session.getUsername(), userRoles); String token = authorizationService().generateUserToken(new UserInfo(session.getUsername(), userRoles), scope);
_log.debug("received token: "+token); _log.debug("received token: "+token);
session.setSecurityToken(token); session.setSecurityToken(token);
_log.info("Security token set in session for: "+username + " on " + scope); _log.debug("PeriodicTask EmailParser: Security token set in session for: "+username + " on " + scope);
} }
public void check(String portalName, String host, String user, String password) { public void check(String portalName, String host, String user, String password) {

@ -2,6 +2,8 @@
<body> <body>
<h2>Hello From D4Science Email reader service!</h2> <h2>Hello From D4Science Email reader service!</h2>
<a href="./start-email-reader">RUN Email reader service (repeat: every minute [Default])</a> <a href="./start-email-reader">RUN Email reader service (repeat: every minutes [Default])</a>
You can change this value by editing the property file gcube-data.properties under $CATALINA_HOME/conf
</body> </body>
</html> </html>

Loading…
Cancel
Save