1 package fr.in2p3.jsaga.adaptor.security.usage;
2
3 import fr.in2p3.jsaga.adaptor.base.usage.UNoPrompt;
4 import fr.in2p3.jsaga.adaptor.security.impl.InMemoryProxySecurityCredential;
5 import org.ietf.jgss.GSSCredential;
6 import org.ogf.saga.error.IncorrectStateException;
7
8
9
10
11
12
13
14
15
16
17
18
19
20 public class UProxyObject extends UNoPrompt {
21 private int m_minLifeTime;
22
23 public UProxyObject(int id, String name, int minLifeTime) {
24 super(id, name);
25 m_minLifeTime = minLifeTime;
26 }
27
28 public String toString() {
29 return "_"+m_name+":"+m_minLifeTime+"_";
30 }
31
32 protected Object throwExceptionIfInvalid(Object value) throws Exception {
33 String v = (String) super.throwExceptionIfInvalid(value);
34 GSSCredential cred = InMemoryProxySecurityCredential.toGSSCredential(v);
35 if (cred.getRemainingLifetime() < m_minLifeTime) {
36 throw new IncorrectStateException("Proxy object remaining lifetime is not enougth: "+cred.getRemainingLifetime());
37 }
38 return cred;
39 }
40 }