Skip to content

Commit fbea604

Browse files
author
Markus Binsteiner
committed
Changes in order for grid-session project to work.
1 parent 9ba9f67 commit fbea604

8 files changed

Lines changed: 49 additions & 17 deletions

File tree

pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@
187187
<version>0.8.1</version>
188188
<scope>test</scope>
189189
</dependency>
190+
191+
190192
</dependencies>
191193

192194
<name>SimpleProxyLib</name>
@@ -299,6 +301,6 @@
299301
<parent>
300302
<groupId>nz.org.nesi</groupId>
301303
<artifactId>nesi</artifactId>
302-
<version>0.10</version>
304+
<version>0.11-SNAPSHOT</version>
303305
</parent>
304306
</project>

simpleProxyLib.assembly.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<assembly>
2-
<id>knife</id>
2+
<id>bin</id>
33
<formats>
44
<!-- <format>dir</format>-->
55
<!-- <format>zip</format>-->

src/main/java/grith/jgrith/control/SlcsLoginWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class SlcsLoginWrapper {
2828

2929
private static List<String> cachedIdps = null;
3030

31-
public static List<String> getAllIdps() throws Throwable {
31+
public synchronized static List<String> getAllIdps() throws Throwable {
3232
if (cachedIdps == null) {
3333
final String id = UUID.randomUUID().toString();
3434
final IdpObject idpObj = new DummyIdpObject();
@@ -56,7 +56,7 @@ public static List<String> getAllIdps() throws Throwable {
5656

5757
public static GSSCredential slcsMyProxyInit(String username,
5858
char[] password, String idp, LoginParams params, String shibUrl)
59-
throws Exception {
59+
throws Exception {
6060

6161
myLogger.debug("SLCS login: starting slcs/myproxy login...");
6262
final String id = UUID.randomUUID().toString();

src/main/java/grith/jgrith/credential/Credential.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,13 @@ public static String getFqan(GSSCredential gss) throws CredentialException {
151151
}
152152

153153
public static Credential load() {
154-
return load(CoGProperties.getDefault().getProxyFile());
154+
return load(null);
155155
}
156156

157157
public static Credential load(String location) {
158+
if (StringUtils.isBlank(location)) {
159+
location = CoGProperties.getDefault().getProxyFile();
160+
}
158161
String mdFilePath = location + "." + METADATA_FILE_EXTENSION;
159162
File mdFile = new File(mdFilePath);
160163
if ( ! mdFile.exists() || ! mdFile.canRead() ) {
@@ -165,7 +168,8 @@ public static Credential load(String location) {
165168
return loadFromMetaDataFile(mdFilePath);
166169
}
167170

168-
public static Credential loadFromConfig(Map<PROPERTY, Object> config) {
171+
public static Credential loadFromConfig(Map<PROPERTY, Object> config,
172+
boolean neverLoadFromMyproxy) {
169173

170174
myLogger.debug("Loading credential from config map...");
171175

@@ -196,6 +200,11 @@ public static Credential loadFromConfig(Map<PROPERTY, Object> config) {
196200
+ " not supported.");
197201
}
198202

203+
if (neverLoadFromMyproxy) {
204+
c.getCredential();
205+
return c;
206+
}
207+
199208
if (StringUtils.isNotBlank(localPath)
200209
&& new File(localPath).exists()) {
201210
c.setSaved(true);
@@ -218,10 +227,12 @@ && new File(localPath).exists()) {
218227
}
219228
}
220229

230+
221231
return c;
222232
} catch (CredentialException ce) {
223233
throw ce;
224234
} catch (Exception e) {
235+
e.printStackTrace();
225236
throw new CredentialException("Can't create credential: "
226237
+ e.getLocalizedMessage(), e);
227238
}
@@ -320,19 +331,21 @@ public static Credential loadFromMetaDataFile(String metadataFile) {
320331

321332
}
322333

323-
Credential c = loadFromConfig(config);
334+
Credential c = loadFromConfig(config, false);
324335

325336
for (String fqan : childs.keySet()) {
326337
myLogger.debug("Adding existing and uploaded childs to credential...");
327338
Map<PROPERTY, Object> childConf = childs.get(fqan);
328339
childConf.put(PROPERTY.LoginType, LoginType.MYPROXY);
329-
Credential child = loadFromConfig(childConf);
340+
Credential child = loadFromConfig(childConf, false);
330341
c.addVomsCredential(child);
331342
}
332343

333344
return c;
334345
} catch (Exception e) {
335-
throw new CredentialException("Can't create credential from metadata file: "+metadataFile);
346+
throw new CredentialException(
347+
"Can't create credential from metadata file "
348+
+ metadataFile + ": " + e.getLocalizedMessage());
336349
}
337350

338351
}
@@ -1107,6 +1120,8 @@ private void saveCredentialMetadata() {
11071120
}
11081121
prop.put(p.toString(), new String((char[]) pw));
11091122
break;
1123+
case Password:
1124+
break;
11101125
default:
11111126
prop.put(p.toString(), properties.get(p).toString());
11121127
}

src/main/java/grith/jgrith/credential/MyProxyCredential.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ public Map<PROPERTY, Object> autorefreshConfig() {
8989
public GSSCredential createGssCredential(Map<PROPERTY, Object> config)
9090
throws CredentialException {
9191

92-
Object pw = config.get(PROPERTY.MyProxyPassword);
92+
char[] pw = (char[]) config.get(PROPERTY.MyProxyPassword);
9393

9494
String un = (String) config.get(PROPERTY.MyProxyUsername);
9595
String host = (String) config.get(PROPERTY.MyProxyHost);
9696

9797
Integer port = (Integer) config.get(PROPERTY.MyProxyPort);
9898

9999

100-
return createGssCredential(un, (char[]) pw, host, port);
100+
return createGssCredential(un, pw, host, port);
101101
}
102102

103103
public GSSCredential createGssCredential(String myproxyUsername,
104-
char[] myproxyPassword, String myproxyhost, int myproxyPort)
104+
char[] myproxyPassword, String myproxyhost, Integer myproxyPort)
105105
throws CredentialException {
106106

107107
try {
@@ -115,9 +115,15 @@ public GSSCredential createGssCredential(String myproxyUsername,
115115
if (StringUtils.isBlank(myproxyhost)) {
116116
myproxyhost = (String) getProperty(PROPERTY.MyProxyHost);
117117
}
118-
if (myproxyPort <= 0) {
118+
if (StringUtils.isBlank(myproxyhost)) {
119+
myproxyhost = GridEnvironment.getDefaultMyProxyServer();
120+
}
121+
if ((myproxyPort == null) || (myproxyPort <= 0)) {
119122
myproxyPort = (Integer) getProperty(PROPERTY.MyProxyPort);
120123
}
124+
if ((myproxyPort == null) || (myproxyPort <= 0)) {
125+
myproxyPort = GridEnvironment.getDefaultMyProxyPort();
126+
}
121127
return MyProxy_light.getDelegation(myproxyhost, myproxyPort,
122128
myproxyUsername, myproxyPassword, getInitialLifetime());
123129
} catch (Exception e) {

src/main/java/grith/jgrith/credential/X509Credential.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import java.util.HashMap;
99
import java.util.Map;
1010

11+
import org.apache.commons.lang.StringUtils;
1112
import org.globus.common.CoGProperties;
12-
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
1313
import org.ietf.jgss.GSSCredential;
1414
import org.ietf.jgss.GSSException;
1515

@@ -128,11 +128,18 @@ public GSSCredential createGssCredential(Map<PROPERTY, Object> temp)
128128
if ((store != null) && (Boolean) store) {
129129
this.passphrase = passphrase;
130130
}
131-
131+
132132

133133
String certFile = (String) temp.get(PROPERTY.CertFile);
134134
String keyFile = (String) temp.get(PROPERTY.KeyFile);
135135

136+
if (StringUtils.isBlank(certFile)) {
137+
certFile = CoGProperties.getDefault().getUserCertFile();
138+
}
139+
if (StringUtils.isBlank(keyFile)) {
140+
keyFile = CoGProperties.getDefault().getUserKeyFile();
141+
}
142+
136143
return PlainProxy.init(certFile, keyFile, passphrase,
137144
getInitialLifetime() / 3600);
138145
} catch (Exception e) {

src/main/java/grith/jgrith/vomsProxy/VomsProxyCredential.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ private boolean getAC() throws GSSException, IOException {
379379
ac = new org.bouncycastle.asn1.x509.AttributeCertificate(acseq);
380380

381381
} catch (Exception e) {
382-
myLogger.error("Could not get AttributeCertificate.", e);
382+
myLogger.info(
383+
"Could not get AttributeCertificate: {}. Probably means the user is not member of the VO.",
384+
e.getLocalizedMessage());
383385
throw new IOException(e);
384386
}
385387

src/main/resources/logback.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<configuration>
22

3-
<logger name="grisu" level="debug"/>
3+
<logger name="grith" level="debug"/>
44

55

66
<appender name="FILE" class="ch.qos.logback.core.FileAppender">

0 commit comments

Comments
 (0)