From b5bda0c2a9eccaec4efb608d994a5ab6d12b50f5 Mon Sep 17 00:00:00 2001 From: Rena Tsantouli Date: Mon, 7 May 2012 16:22:24 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerCore@54410 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../factories/ApplicationCredentials.java | 135 +++++++++--------- 1 file changed, 68 insertions(+), 67 deletions(-) diff --git a/src/org/gcube/application/framework/core/cache/factories/ApplicationCredentials.java b/src/org/gcube/application/framework/core/cache/factories/ApplicationCredentials.java index e29ae5c..edfe15f 100644 --- a/src/org/gcube/application/framework/core/cache/factories/ApplicationCredentials.java +++ b/src/org/gcube/application/framework/core/cache/factories/ApplicationCredentials.java @@ -2,15 +2,15 @@ package org.gcube.application.framework.core.cache.factories; import java.util.HashMap; -import org.gcube.application.framework.core.security.PortalSecurityManager; -import org.gcube.application.framework.core.security.VOMSAdminManager; -import org.gcube.application.framework.core.util.UserCredential; -import org.gcube.common.core.scope.GCUBEScope; -import org.gcube.common.core.security.utils.VOMSAttributesReader; +//import org.gcube.application.framework.core.security.PortalSecurityManager; +//import org.gcube.application.framework.core.security.VOMSAdminManager; +//import org.gcube.application.framework.core.util.UserCredential; +//import org.gcube.common.core.scope.GCUBEScope; +//import org.gcube.common.core.security.utils.VOMSAttributesReader; import org.gcube.common.core.utils.logging.GCUBELog; -import org.gcube.vomanagement.vomsapi.VOMSAdmin; -import org.gcube.vomanagement.vomsapi.impl.VOMSAPIFactory; -import org.glite.wsdl.services.org_glite_security_voms.User; +//import org.gcube.vomanagement.vomsapi.VOMSAdmin; +//import org.gcube.vomanagement.vomsapi.impl.VOMSAPIFactory; +//import org.glite.wsdl.services.org_glite_security_voms.User; import org.gridforum.jgss.ExtendedGSSCredential; /** @@ -50,64 +50,65 @@ public class ApplicationCredentials { */ public ExtendedGSSCredential getCredential(String VREname) { - PortalSecurityManager secMan = new PortalSecurityManager(GCUBEScope.getScope(VREname)); - if(!secMan.isSecurityEnabled()) - return null; - ExtendedGSSCredential cred = creds.get(VREname); - if(cred == null) - { - // If the credential is not available, it retrieves it from myProxy - cred = UserCredential.getCredential("application", VREname); - if(cred == null) - { - //user "application" does not exist on this VRE, so we add him and try to get credential again - VOMSAdmin vomsA; - VOMSAPIFactory factory; - try { - factory = VOMSAdminManager.getVOMSFactory(); - vomsA = factory.getVOMSAdmin(); - // String[] roles = vomsA.listRoles(); - // vomsA.createUser("application", userDN+"application", userCA, "application@gcube.org"); - // vomsA.addMember(VREname, userDN+"application", userCA); - // vomsA.assignRole(VREname, roles[0], userDN+"application", userCA); - // vomsA = new VOMSAdminImpl(); - String[] roles = vomsA.listRoles(); - User myUser = new User(); - myUser.setCN("application"); - myUser.setDN(userDN+"application"); - myUser.setCA(userCA); - myUser.setMail("application@gcube.org"); - //vomsA.getExtendedPortType().createUser("application", userDN+"application", userCA, "application@gcube.org"); - vomsA.createUser(myUser); - //vomsA.getExtendedPortType().addOnlineCAMember(VREname, userDN+"application"); - //vomsA.getExtendedPortType().assignOnlineCARole(VREname, roles[0], userDN+"application"); - vomsA.addMember(VREname, userDN + "application", userCA); - vomsA.assignRole(VREname, roles[0], userDN + "application", userCA); - } - catch (Exception e) { - vomsA = null; - logger.error("", e); - } - cred = UserCredential.getCredential("application", VREname); - } - creds.put(VREname, cred); - } - else - { - // credential already available - VOMSAttributesReader vomsReader = null; - try { - vomsReader = new VOMSAttributesReader(cred); - //Check if it's gonna expire in the next minute, and refresh it - if(vomsReader.getRefreshPeriod() < 60000) - { - cred = UserCredential.getCredential("application", VREname); - creds.put(VREname, cred); - } - } catch (Exception e1) { - logger.error("", e1); - } - } - return cred; +// PortalSecurityManager secMan = new PortalSecurityManager(GCUBEScope.getScope(VREname)); +// if(!secMan.isSecurityEnabled()) +// return null; +// ExtendedGSSCredential cred = creds.get(VREname); +// if(cred == null) +// { +// // If the credential is not available, it retrieves it from myProxy +// cred = UserCredential.getCredential("application", VREname); +// if(cred == null) +// { +// //user "application" does not exist on this VRE, so we add him and try to get credential again +// VOMSAdmin vomsA; +// VOMSAPIFactory factory; +// try { +// factory = VOMSAdminManager.getVOMSFactory(); +// vomsA = factory.getVOMSAdmin(); +// // String[] roles = vomsA.listRoles(); +// // vomsA.createUser("application", userDN+"application", userCA, "application@gcube.org"); +// // vomsA.addMember(VREname, userDN+"application", userCA); +// // vomsA.assignRole(VREname, roles[0], userDN+"application", userCA); +// // vomsA = new VOMSAdminImpl(); +// String[] roles = vomsA.listRoles(); +// User myUser = new User(); +// myUser.setCN("application"); +// myUser.setDN(userDN+"application"); +// myUser.setCA(userCA); +// myUser.setMail("application@gcube.org"); +// //vomsA.getExtendedPortType().createUser("application", userDN+"application", userCA, "application@gcube.org"); +// vomsA.createUser(myUser); +// //vomsA.getExtendedPortType().addOnlineCAMember(VREname, userDN+"application"); +// //vomsA.getExtendedPortType().assignOnlineCARole(VREname, roles[0], userDN+"application"); +// vomsA.addMember(VREname, userDN + "application", userCA); +// vomsA.assignRole(VREname, roles[0], userDN + "application", userCA); +// } +// catch (Exception e) { +// vomsA = null; +// logger.error("", e); +// } +// cred = UserCredential.getCredential("application", VREname); +// } +// creds.put(VREname, cred); +// } +// else +// { +// // credential already available +// VOMSAttributesReader vomsReader = null; +// try { +// vomsReader = new VOMSAttributesReader(cred); +// //Check if it's gonna expire in the next minute, and refresh it +// if(vomsReader.getRefreshPeriod() < 60000) +// { +// cred = UserCredential.getCredential("application", VREname); +// creds.put(VREname, cred); +// } +// } catch (Exception e1) { +// logger.error("", e1); +// } +// } +// return cred; + return null; } }