mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 10:23:51 +00:00
added documentation for settings in UserStore; renamed changepassword package to editprofile; setSettings now returns boolean
This commit is contained in:
1 parent
080972402d
commit
b8562a93d3
8 files changed
+62
-24
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.sap.sse.security.ui.changepassword;
|
||||
package com.sap.sse.security.ui.editprofile;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
+3
-7
@@ -55,13 +55,13 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
private static final Logger logger = Logger.getLogger(UserManagementServiceImpl.class.getName());
|
||||
|
||||
private final BundleContext context;
|
||||
private FutureTask<SecurityService> securityService;
|
||||
private final FutureTask<SecurityService> securityService;
|
||||
|
||||
public UserManagementServiceImpl() {
|
||||
context = Activator.getContext();
|
||||
final ServiceTracker<SecurityService, SecurityService> tracker = new ServiceTracker<>(context, SecurityService.class, /* customizer */ null);
|
||||
tracker.open();
|
||||
setSecurityService(new FutureTask<SecurityService>(new Callable<SecurityService>() {
|
||||
securityService = new FutureTask<SecurityService>(new Callable<SecurityService>() {
|
||||
@Override
|
||||
public SecurityService call() {
|
||||
SecurityService result = null;
|
||||
@@ -75,7 +75,7 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}));
|
||||
});
|
||||
new Thread("ServiceTracker in bundle com.sap.sse.security.ui waiting for SecurityService") {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -383,8 +383,4 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void setSecurityService(FutureTask<SecurityService> securityService) {
|
||||
this.securityService = securityService;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -29,7 +29,7 @@
|
||||
<super-source path="jre" />
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<entry-point class='com.sap.sse.security.ui.changepassword.EditProfileEntryPoint'/>
|
||||
<entry-point class='com.sap.sse.security.ui.editprofile.EditProfileEntryPoint'/>
|
||||
|
||||
<set-property name="gwt.logging.enabled" value="TRUE"/>
|
||||
<set-property name="gwt.logging.logLevel" value="FINE"/>
|
||||
@@ -44,7 +44,7 @@
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<extend-property name="locale" values="de"/>
|
||||
<source path='client'/>
|
||||
<source path='changepassword'/>
|
||||
<source path='editprofile'/>
|
||||
<source path='oauth'/>
|
||||
<source path='shared'/>
|
||||
<source path='loginpanel'/>
|
||||
|
||||
+8
-4
@@ -152,13 +152,17 @@ public class UserStoreImpl implements UserStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSetting(String key, Object setting) {
|
||||
public boolean setSetting(String key, Object setting) {
|
||||
final boolean result;
|
||||
Class<?> clazz = settingTypes.get(key);
|
||||
if (clazz == null || !clazz.isInstance(setting)) {
|
||||
return;
|
||||
result = false;
|
||||
} else {
|
||||
settings.put(key, setting);
|
||||
mongoObjectFactory.storeSettings(settings);
|
||||
result = true;
|
||||
}
|
||||
settings.put(key, setting);
|
||||
mongoObjectFactory.storeSettings(settings);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,9 +51,7 @@ public class OAuthRealm extends AbstractUserStoreBasedRealm {
|
||||
|
||||
@Override
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection token) {
|
||||
System.out.println("authorization");
|
||||
AuthorizationInfo info = new AuthorizationInfo() {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.sap.sse.security;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
@@ -53,9 +54,30 @@ public interface SecurityService {
|
||||
|
||||
void removeRoleFromUser(String username, String role) throws UserManagementException;
|
||||
|
||||
/**
|
||||
* Registers a settings key together with its type. Calling this method is necessary for {@link #setSetting(String, Object)}
|
||||
* to have an effect for <code>key</code>. Calls to {@link #setSetting(String, Object)} will only accept values whose type
|
||||
* is compatible with <code>type</code>. Note that the store implementation may impose constraints on the types supported.
|
||||
* All store implementations are required to support at least {@link String} and {@link UUID} as types.
|
||||
*/
|
||||
void addSetting(String key, Class<?> clazz) throws UserManagementException;
|
||||
|
||||
void setSetting(String key, Object setting);
|
||||
/**
|
||||
* Sets a value for a key if that key was previously added to this store using {@link #addSetting(String, Class)}.
|
||||
* For user store implementations that maintain their data persistently and make it available after a server
|
||||
* restart, it is sufficient to register the settings key once because these registrations will be stored
|
||||
* persistently, too.
|
||||
* <p>
|
||||
*
|
||||
* If the <code>key</code> was not registered before by a call to {@link #addSetting(String, Class)}, or if the
|
||||
* <code>setting</code> object does not conform with the type passed to {@link #addSetting(String, Class)}, a call
|
||||
* to this method will have no effect and return <code>false</code>.
|
||||
*
|
||||
* @Return whether applying the setting was successful; <code>false</code> means that no update was performed to the
|
||||
* setting because either the key was not registered before by {@link #addSetting(String, Class)} or the type of the
|
||||
* <code>setting</code> object does not conform to the type used in {@link #addSetting(String, Class)}
|
||||
*/
|
||||
boolean setSetting(String key, Object setting);
|
||||
|
||||
<T> T getSetting(String key, Class<T> clazz);
|
||||
|
||||
|
||||
@@ -389,12 +389,8 @@ public class SecurityServiceImpl extends RemoteServiceServlet implements Securit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSetting(String key, Object setting) {
|
||||
String[] split = key.split("_");
|
||||
// TODO why this precondition that all keys have to start with "URLS_" to have their settings stored?
|
||||
if (split[0].equals("URLS")) {
|
||||
store.setSetting(key, setting);
|
||||
}
|
||||
public boolean setSetting(String key, Object setting) {
|
||||
return store.setSetting(key, setting);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.sap.sse.security;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sse.security.shared.Account;
|
||||
import com.sap.sse.security.shared.UserManagementException;
|
||||
@@ -27,9 +28,30 @@ public interface UserStore {
|
||||
|
||||
void deleteUser(String name) throws UserManagementException;
|
||||
|
||||
/**
|
||||
* Registers a settings key together with its type. Calling this method is necessary for {@link #setSetting(String, Object)}
|
||||
* to have an effect for <code>key</code>. Calls to {@link #setSetting(String, Object)} will only accept values whose type
|
||||
* is compatible with <code>type</code>. Note that the store implementation may impose constraints on the types supported.
|
||||
* All store implementations are required to support at least {@link String} and {@link UUID} as types.
|
||||
*/
|
||||
public void addSetting(String key, Class<?> type);
|
||||
|
||||
public void setSetting(String key, Object setting);
|
||||
/**
|
||||
* Sets a value for a key if that key was previously added to this store using {@link #addSetting(String, Class)}.
|
||||
* For user store implementations that maintain their data persistently and make it available after a server
|
||||
* restart, it is sufficient to register the settings key once because these registrations will be stored
|
||||
* persistently, too.
|
||||
* <p>
|
||||
*
|
||||
* If the <code>key</code> was not registered before by a call to {@link #addSetting(String, Class)}, or if the
|
||||
* <code>setting</code> object does not conform with the type passed to {@link #addSetting(String, Class)}, a call
|
||||
* to this method will have no effect and return <code>false</code>.
|
||||
*
|
||||
* @Return whether applying the setting was successful; <code>false</code> means that no update was performed to the
|
||||
* setting because either the key was not registered before by {@link #addSetting(String, Class)} or the type of the
|
||||
* <code>setting</code> object does not conform to the type used in {@link #addSetting(String, Class)}
|
||||
*/
|
||||
public boolean setSetting(String key, Object setting);
|
||||
|
||||
public <T> T getSetting(String key, Class<T> clazz);
|
||||
|
||||
|
||||
Reference in new issue
Block a user