1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.springframework.extensions.webscripts;
20
21 import java.io.Serializable;
22
23 import org.springframework.extensions.webscripts.connector.CredentialVault;
24 import org.springframework.extensions.webscripts.connector.Credentials;
25
26
27
28
29 public final class ScriptCredentials implements Serializable
30 {
31 final private CredentialVault vault;
32 final private Credentials credentials;
33 final private boolean hideNonPersistent;
34
35 protected ScriptableMap<String, Serializable> properties;
36
37 public ScriptCredentials(CredentialVault vault, Credentials credentials)
38 {
39 this(vault, credentials, false);
40 }
41
42 public ScriptCredentials(CredentialVault vault, Credentials credentials, boolean hideNonPersistent)
43 {
44 this.vault = vault;
45 this.credentials = credentials;
46 this.hideNonPersistent = hideNonPersistent;
47 }
48
49
50
51
52 public ScriptableMap<String, Serializable> getProperties()
53 {
54 if (this.properties == null)
55 {
56 this.properties = new ScriptableLinkedHashMap<String, Serializable>();
57
58
59
60 if (!isHidden())
61 {
62
63 String[] keys = this.credentials.getPropertyKeys();
64 for(int i = 0; i < keys.length; i++)
65 {
66 Object propertyValue = this.credentials.getProperty(keys[i]);
67 this.properties.put(keys[i], (Serializable)propertyValue);
68 }
69 }
70 }
71
72 return this.properties;
73 }
74
75
76
77
78
79 public boolean isHidden()
80 {
81 return !isPersistent() && hideNonPersistent;
82 }
83
84 public boolean isPersistent()
85 {
86 return credentials.isPersistent();
87 }
88 }