1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.admininterface.config;
35
36 import info.magnolia.cms.beans.config.ContentRepository;
37
38 import java.util.ArrayList;
39 import java.util.Collections;
40 import java.util.Iterator;
41 import java.util.LinkedHashMap;
42 import java.util.List;
43 import java.util.Map;
44
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
47
48
49
50
51
52
53 public class SecurityConfiguration {
54
55
56
57
58 private static Logger log = LoggerFactory.getLogger(SecurityConfiguration.class);
59
60 private Map repositories = new LinkedHashMap();
61
62 private RepositoryConfiguration defaultRepositoryConfiguration;
63
64 private Map systemRepositories = new LinkedHashMap();
65
66 public RepositoryConfiguration getDefaultRepositoryConfiguration() {
67 return this.defaultRepositoryConfiguration;
68 }
69
70 public void setDefaultRepositoryConfiguration(RepositoryConfiguration defaultRepositoryConfiguration) {
71 this.defaultRepositoryConfiguration = defaultRepositoryConfiguration;
72 }
73
74 public Map getRepositories() {
75 return this.repositories;
76 }
77
78 public void setRepositories(Map repositories) {
79 this.repositories = repositories;
80 }
81
82 public void addRepository(String name, RepositoryConfiguration repositoryConfiguration) {
83 this.repositories.put(name, repositoryConfiguration);
84 }
85
86 public Map getSystemRepositories() {
87 return this.systemRepositories;
88 }
89
90 public void setSystemRepositories(Map systemRepositories) {
91 this.systemRepositories = systemRepositories;
92 }
93
94 public void addSystemRepository(String name, RepositoryConfiguration repository){
95 this.systemRepositories.put(name, repository);
96 }
97
98 public List getVisibleRepositories(){
99 List visibleRepositories = new ArrayList();
100
101 visibleRepositories.addAll(this.getRepositories().values());
102
103 for (Iterator iter = ContentRepository.getAllRepositoryNames(); iter.hasNext();) {
104 String name = (String) iter.next();
105 if(!systemRepositories.containsKey(name)){
106 if(!this.getRepositories().containsKey(name)){
107 DefaultRepositoryConfigurationWrapper repositoryConfiguration = new DefaultRepositoryConfigurationWrapper(this.getDefaultRepositoryConfiguration());
108 repositoryConfiguration.setName(name);
109 visibleRepositories.add(repositoryConfiguration);
110 }
111 }
112 }
113 Collections.sort(visibleRepositories);
114 return visibleRepositories;
115 }
116
117
118
119
120
121 static class DefaultRepositoryConfigurationWrapper extends RepositoryConfiguration{
122 RepositoryConfiguration repositoryConfiguration;
123
124 public DefaultRepositoryConfigurationWrapper(RepositoryConfiguration repositoryConfiguration) {
125 this.repositoryConfiguration = repositoryConfiguration;
126 }
127
128 public void addAclType(AclTypeConfiguration type) {
129 this.repositoryConfiguration.addAclType(type);
130 }
131
132 public void addPermission(PermissionConfiguration permission) {
133 this.repositoryConfiguration.addPermission(permission);
134 }
135
136 public List getAclTypes() {
137 return this.repositoryConfiguration.getAclTypes();
138 }
139
140 public List getPermissions() {
141 return this.repositoryConfiguration.getPermissions();
142 }
143
144 public boolean isChooseButton() {
145 return this.repositoryConfiguration.isChooseButton();
146 }
147
148 public void setAclTypes(List patternTypes) {
149 this.repositoryConfiguration.setAclTypes(patternTypes);
150 }
151
152 public void setChooseButton(boolean chooseButton) {
153 this.repositoryConfiguration.setChooseButton(chooseButton);
154 }
155
156 public void setPermissions(List permissions) {
157 this.repositoryConfiguration.setPermissions(permissions);
158 }
159
160 public String toViewPattern(String path) {
161 return this.repositoryConfiguration.toViewPattern(path);
162 }
163 }
164
165 }