Updated to Auth 2.0

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@131467 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-09-19 08:37:56 +00:00
parent c6f2e5c490
commit 85fe7bdcd9
2 changed files with 13 additions and 31 deletions

View File

@ -3,17 +3,13 @@
*/
package org.gcube.portlets.user.statisticalalgorithmsimporter.server;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.authorization.library.provider.UserInfo;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient;
@ -74,24 +70,7 @@ public class SessionUtil {
throws StatAlgoImporterServiceException {
String token = null;
if (Constants.DEBUG_MODE) {
List<String> userRoles = new ArrayList<>();
userRoles.add(Constants.DEFAULT_ROLE);
/*
* if (aslSession.getUsername().compareTo("lucio.lelii") == 0)
* userRoles.add("VRE-Manager");
*/
try {
token = authorizationService().generateUserToken(
new UserInfo(aslSession.getUsername(), userRoles),
aslSession.getScope());
} catch (Exception e) {
logger.error("Error generating the token for test: "
+ e.getLocalizedMessage());
e.printStackTrace();
throw new StatAlgoImporterServiceException("Error generating the token for test: "
+ e.getLocalizedMessage());
}
token = Constants.DEFAULT_TOKEN;
} else {
token = aslSession.getSecurityToken();
}
@ -100,6 +79,9 @@ public class SessionUtil {
}
//
public static ArrayList<Recipient> getRecipients(
ServletContext servletContest) {

View File

@ -2,8 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class Constants {
@ -15,14 +15,14 @@ public class Constants {
public static final String STATISTICAL_ALGORITHMS_IMPORTER_ID = "SAIId";
public static final String STATISTICAL_ALGORITHMS_IMPORTER_COOKIE = "SAILangCookie";
public static final String STATISTICAL_ALGORITHMS_IMPORTER_LANG = "SAILang";
public final static String DEFAULT_USER = "giancarlo.panichi";
public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
public static final String DEFAULT_ROLE = "OrganizationMember";
public static final String DEFAULT_USER = "giancarlo.panichi";
public final static String DEFAULT_SCOPE = "/gcube/devNext";
public final static String DEFAULT_TOKEN = "16e65d4f-11e0-4e4a-84b9-351688fccc12-98187548";
public static final String DEFAULT_ROLE = "OrganizationMember";
public static final String FILE_UPLOADED_FIELD = "FileUploadedField";
public static final String STATISTICAL_ALGORITHMS_IMPORTER_JAR_PUBLIC_LINK = "JarPublicLink";
public static final String RECIPIENTS = "Recipients";
}