Skip to content

Commit c094679

Browse files
author
Markus Binsteiner
committed
Refactoring: VOManagement -> VOManager
1 parent 073cff8 commit c094679

20 files changed

+142
-460
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@
199199
<artifactId>jsch</artifactId>
200200
<version>0.1.48</version>
201201
</dependency>
202+
<dependency>
203+
<groupId>com.jgoodies</groupId>
204+
<artifactId>jgoodies-common</artifactId>
205+
<version>1.6.0</version>
206+
<scope>provided</scope>
207+
</dependency>
202208
</dependencies>
203209

204210
<name>JGrith</name>

src/main/groovy/grith/SwissProxyKnife.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package grithimport grisu.jcommons.constants.GridEnvironmentimport grisu.jcommons.dependencies.Dependencyimport grisu.jcommons.dependencies.DependencyManagerimport grisu.jcommons.utils.DefaultGridSecurityProviderimport grisu.jcommons.utils.JythonHelpersimport grisu.model.info.dto.VOimport grith.gsindl.SLCSimport grith.jgrith.certificate.CertificateHelperimport grith.jgrith.myProxy.MyProxy_lightimport grith.jgrith.plainProxy.LocalProxyimport grith.jgrith.plainProxy.PlainProxyimport grith.jgrith.utils.CertificateFilesimport grith.jgrith.utils.CredentialHelpersimport grith.jgrith.utils.HelperMethodsimport grith.jgrith.voms.VOManagement.VOManagementimport grith.jgrith.vomsProxy.VomsProxyimport grith.jgrith.vomsProxy.VomsProxyCredentialimport grith.sibboleth.CredentialManagerimport grith.sibboleth.DummyCredentialManagerimport grith.sibboleth.DummyIdpObjectimport grith.sibboleth.IdpObjectimport grith.sibboleth.Shibbolethimport grith.sibboleth.StaticCredentialManagerimport grith.sibboleth.StaticIdpObjectimport groovy.util.OptionAccessorimport java.io.Fileimport jline.ConsoleReaderimport org.globus.common.CoGPropertiesimport org.globus.gsi.GlobusCredentialimport org.globus.myproxy.InitParamsimport org.globus.myproxy.MyProxyimport org.ietf.jgss.GSSCredential
1+
package grithimport grisu.jcommons.constants.GridEnvironmentimport grisu.jcommons.dependencies.Dependencyimport grisu.jcommons.dependencies.DependencyManagerimport grisu.jcommons.utils.DefaultGridSecurityProviderimport grisu.jcommons.utils.JythonHelpersimport grisu.model.info.dto.VOimport grith.gsindl.SLCSimport grith.jgrith.certificate.CertificateHelperimport grith.jgrith.myProxy.MyProxy_lightimport grith.jgrith.plainProxy.LocalProxyimport grith.jgrith.plainProxy.PlainProxyimport grith.jgrith.utils.CertificateFilesimport grith.jgrith.utils.CredentialHelpersimport grith.jgrith.utils.HelperMethodsimport grith.jgrith.vomsProxy.VomsProxyimport grith.jgrith.vomsProxy.VomsProxyCredentialimport grith.sibboleth.CredentialManagerimport grith.sibboleth.DummyCredentialManagerimport grith.sibboleth.DummyIdpObjectimport grith.sibboleth.IdpObjectimport grith.sibboleth.Shibbolethimport grith.sibboleth.StaticCredentialManagerimport grith.sibboleth.StaticIdpObjectimport groovy.util.OptionAccessorimport java.io.Fileimport jline.ConsoleReaderimport org.globus.common.CoGPropertiesimport org.globus.gsi.GlobusCredentialimport org.globus.myproxy.InitParamsimport org.globus.myproxy.MyProxyimport org.ietf.jgss.GSSCredential
22
/** * A script that allows you to create a proxy in 3 different ways: normal grid proxy init, myproxy-login, shibboleth. * It also allows you to convert the proxy into a voms proxy if you want to do that and then stores it either on disk or * uploads it to myproxy. * * @author Markus Binsteiner * */
33
public class SwissProxyKnife { public static final String WAYF_URL = "https://slcs1.arcs.org.au/SLCS/login"
44
public static final String PROXY_CREATION_MODE_OPTION = "mode" public static final String SHIBBOLETH_MODE_PARAMETER = "shib-proxy-init" public static final String CERTIFICATE_MODE_PARAMETER = "grid-proxy-init" public static final String MYPROXY_MODE_PARAMETER = "myproxy-login" public static final String SHIBBOLETH_LIST_MODE_PARAMETER = "shib-list" public static final String USE_LOCAL_MODE_PARAMETER = "load-local-proxy" public static final String PROXY_OUTPUT_MODE_OPTION = "action" public static final String LOCAL_OUTPUT_MODE_PARAMETER = "store-local" public static final String MYPROXY_OUTPUT_MODE_PARAMETER = "myproxy-upload" public static final String VOMS_LIST_GROUPS = "list-groups" public static final String INFO_ACTION_PARAMETER = "info" public static final String VOMS_PROXY_OPTION = "voms" public static final String SHIBBOLETH_IDP_PARAMETER = "idp" public static final String USERNAME_PARAMETER = "username" public static final String MYPROXY_USERNAME_PARAMETER = "myproxy_username" public static final String MYPROXY_PROXYNAME_PARAMETER = "myproxy_proxyname" public static final String MYPROXY_SERVER_PARAMETER = "server" public static final String MYPROXY_PORT_PARAMETER = "port" public static final String LIFETIME_PARAMETER = "lifetime" public static final VOMS_GROUP_PARAMETER = "voms_group" public final static String VERBOSE_OPTION = "verbose" public final static String DEBUG_OPTION = "debug"

src/main/java/grith/jgrith/cred/AbstractCred.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import grith.jgrith.myProxy.MyProxy_light;
1414
import grith.jgrith.utils.CertHelpers;
1515
import grith.jgrith.utils.CredentialHelpers;
16-
import grith.jgrith.voms.VOManagement.VOManagement;
16+
import grith.jgrith.voms.VOManagement.VOManager;
1717

1818
import java.beans.PropertyChangeListener;
1919
import java.beans.PropertyChangeSupport;
@@ -92,6 +92,8 @@ public Class getValueClass() {
9292

9393
static final Logger myLogger = LoggerFactory.getLogger(AbstractCred.class
9494
.getName());
95+
96+
public static VOManager DEFAULT_VO_MANAGER = new VOManager();
9597

9698
public static AbstractCred create(AbstractCallback callback) {
9799
return loadFromConfig(null, callback);
@@ -242,6 +244,8 @@ public static void main(String[] args) throws Exception {
242244
private boolean saveProxyOnCreation = true;
243245

244246
private volatile Date lastCredentialAutoRefresh = new Date();
247+
248+
private VOManager vom = null;
245249

246250
public AbstractCred() {
247251
super();
@@ -470,7 +474,7 @@ public void run() {
470474
public synchronized Map<String, VO> getAvailableFqans() {
471475

472476
if (fqans == null) {
473-
fqans = VOManagement.getAllFqans(getGSSCredential());
477+
fqans = getVOManager().getAllFqans(getGSSCredential());
474478
}
475479
return fqans;
476480

@@ -664,7 +668,22 @@ && new File(this.localPath).exists()) {
664668
return null;
665669

666670
}
671+
672+
public synchronized VOManager getVOManager() {
673+
if ( vom == null ) {
674+
if ( DEFAULT_VO_MANAGER != null ) {
675+
vom = DEFAULT_VO_MANAGER;
676+
} else {
677+
vom = new VOManager();
678+
}
679+
}
680+
return vom;
681+
}
667682

683+
public void setVOManager(VOManager vom) {
684+
this.vom = vom;
685+
}
686+
668687
/*
669688
* (non-Javadoc)
670689
*

src/main/java/grith/jgrith/cred/Cred.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import grisu.model.info.dto.VO;
44
import grith.jgrith.cred.AbstractCred.PROPERTY;
5+
import grith.jgrith.voms.VOManagement.VOManager;
56

67
import java.util.Map;
78

@@ -57,4 +58,6 @@ public interface Cred {
5758

5859
public abstract boolean getSaveProxyOnCreation();
5960

61+
public abstract VOManager getVOManager();
62+
6063
}

src/main/java/grith/jgrith/view/swing/VomsInfoPanel.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import grisu.model.info.dto.VO;
44
import grith.jgrith.utils.CredentialHelpers;
5+
import grith.jgrith.voms.VOManagement.VOManager;
56
import grith.jgrith.vomsProxy.VomsException;
67
import grith.jgrith.vomsProxy.VomsHelpers;
78
import grith.jgrith.vomsProxy.VomsProxy;
@@ -46,6 +47,8 @@ public class VomsInfoPanel extends JPanel {
4647
// -------------------------------------------------------------------
4748
// EventStuff
4849
private Vector<ProxyInitListener> vomsPanelListeners;
50+
51+
private final VOManager vom;
4952

5053
/**
5154
* Creates the VomsInfoPanel. You have to register a listener to get the
@@ -58,8 +61,9 @@ public class VomsInfoPanel extends JPanel {
5861
* whether to stop querying for voms information if an error with
5962
* one of the servers occurs or not.
6063
*/
61-
public VomsInfoPanel() {
64+
public VomsInfoPanel(VOManager vom) {
6265
super();
66+
this.vom = vom;
6367
final GridBagLayout gridBagLayout = new GridBagLayout();
6468
gridBagLayout.columnWidths = new int[] { 0 };
6569
gridBagLayout.rowHeights = new int[] { 0, 7, 7, 7, 7, 7 };
@@ -218,7 +222,7 @@ public void loadCredential(GSSCredential credential) throws VomsException {
218222
voModel.removeAllElements();
219223
groupModel.removeAllElements();
220224

221-
info = VomsHelpers.getAllVosAndVoGroups(credential, ignoreErrors);
225+
info = VomsHelpers.getAllVosAndVoGroups(vom, credential, ignoreErrors);
222226

223227
for (VO vo : info.keySet()) {
224228
voModel.addElement(vo);

src/main/java/grith/jgrith/view/swing/VomsProxyInfoAndInitPanel.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import grith.jgrith.plainProxy.LocalProxy;
44
import grith.jgrith.utils.CredentialHelpers;
5+
import grith.jgrith.voms.VOManagement.VOManager;
56

67
import java.io.File;
78
import java.io.IOException;
@@ -36,12 +37,15 @@ public class VomsProxyInfoAndInitPanel extends JPanel implements
3637
// -------------------------------------------------------------------
3738
// EventStuff
3839
private Vector<ProxyInitListener> proxyListeners;
40+
41+
private final VOManager vom;
3942

4043
/**
4144
* Create the panel
4245
*/
43-
public VomsProxyInfoAndInitPanel() {
46+
public VomsProxyInfoAndInitPanel(VOManager vom) {
4447
super();
48+
this.vom = vom;
4549
setLayout(new FormLayout(
4650
new ColumnSpec[] { ColumnSpec.decode(
4751
"default:grow(1.0)") }, new RowSpec[] {
@@ -121,7 +125,7 @@ protected VomsProxyInfoPanel getVomsProxyInfoPanel() {
121125
*/
122126
protected VomsProxyInitPanel getVomsProxyInitPanel() {
123127
if (vomsProxyInitPanel == null) {
124-
vomsProxyInitPanel = new VomsProxyInitPanel();
128+
vomsProxyInitPanel = new VomsProxyInitPanel(vom);
125129
}
126130
return vomsProxyInitPanel;
127131
}

src/main/java/grith/jgrith/view/swing/VomsProxyInitApplet.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
package grith.jgrith.view.swing;
22

3+
import grith.jgrith.voms.VOManagement.VOManager;
4+
35
import java.awt.BorderLayout;
46

57
import javax.swing.JApplet;
68

79
public class VomsProxyInitApplet extends JApplet {
810

911
private VomsProxyInfoAndInitPanel vomsProxyInfoAndInitPanel;
12+
private final VOManager vom;
1013

1114
/**
1215
* Create the applet
1316
*/
14-
public VomsProxyInitApplet() {
17+
public VomsProxyInitApplet(VOManager vom) {
1518
super();
19+
this.vom = vom;
1620
getContentPane().add(getVomsProxyInfoAndInitPanel(),
1721
BorderLayout.CENTER);
1822
//
@@ -23,7 +27,7 @@ public VomsProxyInitApplet() {
2327
*/
2428
protected VomsProxyInfoAndInitPanel getVomsProxyInfoAndInitPanel() {
2529
if (vomsProxyInfoAndInitPanel == null) {
26-
vomsProxyInfoAndInitPanel = new VomsProxyInfoAndInitPanel();
30+
vomsProxyInfoAndInitPanel = new VomsProxyInfoAndInitPanel(vom);
2731
}
2832
return vomsProxyInfoAndInitPanel;
2933
}

src/main/java/grith/jgrith/view/swing/VomsProxyInitDialog.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package grith.jgrith.view.swing;
22

3+
import grith.jgrith.voms.VOManagement.VOManager;
4+
35
import java.awt.BorderLayout;
46
import java.awt.event.ActionEvent;
57
import java.awt.event.ActionListener;
@@ -25,7 +27,7 @@ public class VomsProxyInitDialog extends JDialog {
2527
*/
2628
public static void main(String args[]) {
2729
try {
28-
VomsProxyInitDialog dialog = new VomsProxyInitDialog();
30+
VomsProxyInitDialog dialog = new VomsProxyInitDialog(new VOManager());
2931
dialog.setModal(true);
3032
dialog.setLifetimeDefaults(new Integer[] { 1, 2, 7 });
3133
dialog.enableWriteToDisk(true);
@@ -46,12 +48,14 @@ public void windowClosing(WindowEvent e) {
4648
private JPanel panel;
4749

4850
private VomsProxyInfoAndInitPanel vomsProxyInfoAndInitPanel;
51+
private final VOManager vom;
4952

5053
/**
5154
* Create the dialog
5255
*/
53-
public VomsProxyInitDialog() {
56+
public VomsProxyInitDialog(VOManager vom) {
5457
super();
58+
this.vom = vom;
5559
setBounds(100, 100, 470, 335);
5660
getContentPane().add(getPanel(), BorderLayout.CENTER);
5761
//
@@ -128,7 +132,7 @@ protected JPanel getPanel() {
128132
*/
129133
protected VomsProxyInfoAndInitPanel getVomsProxyInfoAndInitPanel() {
130134
if (vomsProxyInfoAndInitPanel == null) {
131-
vomsProxyInfoAndInitPanel = new VomsProxyInfoAndInitPanel();
135+
vomsProxyInfoAndInitPanel = new VomsProxyInfoAndInitPanel(vom);
132136
}
133137
return vomsProxyInfoAndInitPanel;
134138
}

src/main/java/grith/jgrith/view/swing/VomsProxyInitDialogOld.java

Lines changed: 0 additions & 114 deletions
This file was deleted.

src/main/java/grith/jgrith/view/swing/VomsProxyInitPanel.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import grisu.model.info.dto.VO;
44
import grith.jgrith.plainProxy.PlainProxy;
55
import grith.jgrith.utils.CredentialHelpers;
6-
import grith.jgrith.voms.VOManagement.VOManagement;
6+
import grith.jgrith.voms.VOManagement.VOManager;
77
import grith.jgrith.vomsProxy.VomsException;
88
import grith.jgrith.vomsProxy.VomsProxy;
99

@@ -68,12 +68,14 @@ public class VomsProxyInitPanel extends JPanel implements ProxyInitListener {
6868
// -------------------------------------------------------------------
6969
// EventStuff
7070
private Vector<ProxyInitListener> proxyListeners;
71+
private final VOManager vom;
7172

7273
/**
7374
* Create the panel
7475
*/
75-
public VomsProxyInitPanel() {
76+
public VomsProxyInitPanel(VOManager vom) {
7677
super();
78+
this.vom = vom;
7779
setBorder(DEFAULT_TITLE);
7880
setLayout(new FormLayout(new ColumnSpec[] {
7981
FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("65dlu"),
@@ -113,7 +115,7 @@ private void fillVOs() throws VomsException {
113115
//
114116
// voModel.addElement(NON_VOMS_PROXY_NAME);
115117

116-
allFqans = VOManagement.getAllFqans(CredentialHelpers
118+
allFqans = vom.getAllFqans(CredentialHelpers
117119
.wrapGlobusCredential(credential));
118120

119121
for (String fqan : allFqans.keySet()) {

0 commit comments

Comments
 (0)