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.setup.for3_5;
35
36 import info.magnolia.cms.beans.config.ContentRepository;
37 import info.magnolia.cms.core.ItemType;
38 import info.magnolia.cms.core.SystemProperty;
39 import info.magnolia.cms.security.IPSecurityManagerImpl;
40 import info.magnolia.cms.security.Realm;
41 import info.magnolia.module.delta.ArrayDelegateTask;
42 import info.magnolia.module.delta.BootstrapConditionally;
43 import info.magnolia.module.delta.BootstrapSingleResource;
44 import info.magnolia.module.delta.CheckOrCreatePropertyTask;
45 import info.magnolia.module.delta.CopyOrReplaceNodePropertiesTask;
46 import info.magnolia.module.delta.CreateNodeTask;
47 import info.magnolia.module.delta.IsAuthorInstanceDelegateTask;
48 import info.magnolia.module.delta.ModuleFilesExtraction;
49 import info.magnolia.module.delta.MoveAndRenamePropertyTask;
50 import info.magnolia.module.delta.MoveNodeTask;
51 import info.magnolia.module.delta.NewPropertyTask;
52 import info.magnolia.module.delta.NodeExistsDelegateTask;
53 import info.magnolia.module.delta.PropertyExistsDelegateTask;
54 import info.magnolia.module.delta.RegisterModuleServletsTask;
55 import info.magnolia.module.delta.RemoveNodeTask;
56 import info.magnolia.module.delta.RemovePropertyTask;
57 import info.magnolia.module.delta.Task;
58 import info.magnolia.module.delta.WarnTask;
59 import info.magnolia.setup.CoreModuleVersionHandler;
60 import org.apache.commons.codec.binary.Base64;
61 import org.apache.commons.lang.StringUtils;
62
63 import java.util.Arrays;
64 import java.util.List;
65
66
67
68
69
70
71
72
73
74
75 public class GenericTasks {
76 private static final String UNSECURE_URIS_BACKUP_PATH = "/server/install/backup/unsecureURIList";
77 private static final String SECURE_URIS_BACKUP_PATH = "/server/install/backup/secureURIList";
78
79
80
81
82 public static List<Task> genericTasksFor35() {
83 final String areWeBootstrappingAuthorInstance = StringUtils.defaultIfEmpty(SystemProperty.getProperty(CoreModuleVersionHandler.BOOTSTRAP_AUTHOR_INSTANCE_PROPERTY), "true");
84 return Arrays.asList(
85
86 new NodeExistsDelegateTask("Server node", "Creates the server node in the config repository if needed.", ContentRepository.CONFIG, "/server", null,
87 new CreateNodeTask(null, null, ContentRepository.CONFIG, "/", "server", ItemType.CONTENT.getSystemName())),
88
89
90 new NodeExistsDelegateTask("Modules node", "Creates the modules node in the config repository if needed.", ContentRepository.CONFIG, "/modules", null,
91 new CreateNodeTask(null, null, ContentRepository.CONFIG, "/", "modules", ItemType.CONTENT.getSystemName())),
92
93 new MigrateFilterConfiguration("/mgnl-bootstrap/core/config.server.filters.xml"),
94
95 new BootstrapConditionally("IPConfig rules changed",
96 "Updates the existing ip access rules to match the new configuration structure or bootstraps the new default configuration.",
97 "/mgnl-bootstrap/core/config.server.IPConfig.xml",
98 new ArrayDelegateTask(null,
99 new NewPropertyTask("IPSecurityManager class property", "IPSecurity is now a component which can be configured through the repository.", "config", "/server/IPConfig", "class", IPSecurityManagerImpl.class.getName()),
100 new IPConfigRulesUpdate()
101 )),
102
103 new UpdateI18nConfiguration(),
104
105 new BootstrapSingleResource("New security configuration", "Install new configuration for security managers.", "/mgnl-bootstrap/core/config.server.security.xml"),
106 new BootstrapSingleResource("New rendering strategy for links", "Install new configuration for link resolving.", "/mgnl-bootstrap/core/config.server.rendering.linkManagement.xml"),
107
108 new BootstrapConditionally("MIME mappings", "Adds MIMEMappings to server config, if not already present.", "/mgnl-bootstrap/core/config.server.MIMEMapping.xml"),
109 new BootstrapConditionally("URI2Repository mappings", "Installs new configuration of URI2Repository mappings.", "/mgnl-bootstrap/core/config.server.URI2RepositoryMapping.xml", new UpdateURI2RepositoryMappings()),
110
111
112 new PropertyExistsDelegateTask("Cleanup", "Config property /server/defaultMailServer was unused.", "config", "/server", "defaultMailServer",
113 new RemovePropertyTask("", "", "config", "/server", "defaultMailServer")),
114
115
116 new CheckOrCreatePropertyTask("defaultExtension property", "Checks that the defaultExtension property exists in config:/server", "config", "/server", "defaultExtension", "html"),
117
118 new CheckOrCreatePropertyTask("admin property", "Checks that the admin property exists in config:/server", "config", "/server", "admin", areWeBootstrappingAuthorInstance),
119 new MoveAndRenamePropertyTask("basicRealm property", "/server", "basicRealm", "magnolia 3.0", "/server/filters/uriSecurity/clientCallback", "realmName", "Magnolia"),
120 new ArrayDelegateTask("defaultBaseUrl property",
121 new NewPropertyTask("defaultBaseUrl property", "Adds the new defaultBaseUrl property with a default value.", "config", "/server", "defaultBaseUrl", "http://localhost:8080/magnolia/"),
122 new WarnTask("defaultBaseUrl property", "Please set the config:/server/defaultBaseUrl property to a full URL to be used when generating absolute URLs for external systems.")
123 ),
124
125
126 new NodeExistsDelegateTask("Login configuration", "The login configuration was moved to filters configuration.", "config", "/server/login",
127 new ArrayDelegateTask("",
128 new LoginAuthTypePropertyMovedToFilter(),
129 new LoginFormPropertyMovedToFilter(),
130 new MoveAndRenamePropertyTask("unsecuredPath is now handled by the bypass mechanism.", "/server/login", "UnsecuredPath", "/server/filters/uriSecurity/bypasses/login", "pattern"),
131 new RemoveNodeTask("Login configuration changed", "Removes /server/login as it is not used anymore.", "config", "/server/login")
132 )),
133
134 new CopyOrReplaceNodePropertiesTask("clientCallback configuration for content security", "The clientCallback configuration needs to be configuration for each security filter. This is copying the one from the URI security filter to the content security filter.",
135 "config", "/server/filters/uriSecurity/clientCallback", "/server/filters/cms/contentSecurity/clientCallback"),
136
137
138 new CreateNodeTask("Adds system folder node to users workspace", "Add system realm folder /system to users workspace.", ContentRepository.USERS, "/", Realm.REALM_SYSTEM, ItemType.NT_FOLDER),
139 new CreateNodeTask("Adds admin folder node to users workspace", "Add magnolia realm folder /admin to users workspace.", ContentRepository.USERS, "/", Realm.REALM_ADMIN, ItemType.NT_FOLDER),
140
141 new IsAuthorInstanceDelegateTask("URI permissions", "Introduction of URI-based security. All existing roles will have GET/POST permissions on /*.",
142 new AddURIPermissionsToAllRoles(true),
143 new AddURIPermissionsToAllRoles(false)),
144
145 new IsAuthorInstanceDelegateTask("Anonymous role", "Anonymous role must exist.",
146 new BootstrapConditionally("", "Author permissions", "/info/magnolia/setup/author/userroles.anonymous.xml"),
147 new BootstrapConditionally("", "Public permissions", "/info/magnolia/setup/public/userroles.anonymous.xml")),
148
149 new BootstrapConditionally("Superuser role", "Bootstraps the superuser role if needed.", "/mgnl-bootstrap/core/userroles.superuser.xml"),
150
151 new BootstrapConditionally("Anonymous user", "Anonymous user must exist in the system realm: will move the existing one or bootstrap it.",
152 ContentRepository.USERS, "/anonymous", "/mgnl-bootstrap/core/users.system.anonymous.xml",
153 new ArrayDelegateTask("",
154 new MoveNodeTask("", "", ContentRepository.USERS, "/anonymous", "/system/anonymous", false),
155 new NewPropertyTask("Anonymous user", "Anonymous user must have a password.", ContentRepository.USERS, "/system/anonymous", "pswd", new String(Base64.encodeBase64("anonymous".getBytes())))
156 )),
157
158 new BootstrapConditionally("Superuser user", "Superuser user must exist in the system realm: will move the existing one or bootstrap it.",
159 ContentRepository.USERS, "/superuser", "/mgnl-bootstrap/core/users.system.superuser.xml",
160 new MoveNodeTask("", "", ContentRepository.USERS, "/superuser", "/system/superuser", false)),
161
162
163 new MoveMagnoliaUsersToRealmFolder(),
164
165
166 new ModuleFilesExtraction(),
167 new RegisterModuleServletsTask(),
168
169
170 new NodeExistsDelegateTask("Security configuration", "The unsecureURIList configuration was removed from /servers and will be handled by the uriSecurityFilter in 3.5.", ContentRepository.CONFIG, "/server/unsecureURIList", new ArrayDelegateTask("UnsecureURIList update", new Task[]{
171 new MoveNodeTask("Unsecure URIs", "Moves the current configuration of unsecure URIs to a backup location", ContentRepository.CONFIG, "/server/unsecureURIList", UNSECURE_URIS_BACKUP_PATH, true),
172 new CheckAndUpdateUnsecureURIs(UNSECURE_URIS_BACKUP_PATH)
173 })),
174 new NodeExistsDelegateTask("Security configuration", "The secureURIList configuration was removed from /servers and will be handled by the URI-based security mechanism in 3.5.", ContentRepository.CONFIG, "/server/secureURIList", new ArrayDelegateTask("SecureURIList update", new Task[]{
175 new MoveNodeTask("Secure URIs", "Moves the current configuration of secure URIs to a backup location", ContentRepository.CONFIG, "/server/secureURIList", SECURE_URIS_BACKUP_PATH, true),
176 new CheckAndUpdateSecureURIs(SECURE_URIS_BACKUP_PATH)
177 })),
178
179
180 new WarnIgnoredModuleFilters(),
181 new RenamedRenderersToTemplateRenderers(),
182 new ReconfigureCommands(),
183 new UpdateURIMappings(),
184 new RemoveModuleDescriptorDetailsFromRepo()
185 );
186 }
187
188 }