1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.springframework.extensions.webscripts.connector;
20
21 import org.springframework.extensions.config.ConfigService;
22 import org.springframework.extensions.config.RemoteConfigElement;
23 import org.springframework.extensions.config.RemoteConfigElement.EndpointDescriptor;
24
25
26
27
28
29
30
31 public abstract class AbstractPersistentCredentialVault extends SimpleCredentialVault
32 {
33 protected ConfigService configService;
34
35
36
37
38
39
40 public AbstractPersistentCredentialVault(String id)
41 {
42 super(id);
43 }
44
45
46
47
48
49
50 public void setConfigService(ConfigService configService)
51 {
52 this.configService = configService;
53 }
54
55
56
57
58 public void store(Credentials credentials)
59 {
60
61
62 String endpointId = credentials.getEndpointId();
63 EndpointDescriptor descriptor = getRemoteConfig().getEndpointDescriptor(endpointId);
64 if(descriptor != null)
65 {
66
67 ((CredentialsImpl)credentials).persistent = descriptor.getPersistent();
68 }
69
70 super.store(credentials);
71 }
72
73
74
75
76 protected RemoteConfigElement getRemoteConfig()
77 {
78 RemoteConfigElement remoteConfig = (RemoteConfigElement)configService.getConfig(
79 "Remote").getConfigElement("remote");
80 return remoteConfig;
81 }
82
83
84
85
86 @Override
87 public String toString()
88 {
89 return "PersistentCredentialVault - " + this.id;
90 }
91 }