Uživatelé rozšíření o ukládání uživatelského nastavení. Přidáno
oprávnění pro editaci vlastního záznamu uživatele. refs #132multitenant
parent
b7967e66c0
commit
5fd9f1844b
@ -0,0 +1,15 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
public class UserSettingsData {
|
||||
|
||||
private String signatureFile;
|
||||
|
||||
public String getSignatureFile() {
|
||||
return signatureFile;
|
||||
}
|
||||
|
||||
public void setSignatureFile(String signaturePath) {
|
||||
this.signatureFile = signaturePath;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package info.bukova.isspst.security;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
import info.bukova.isspst.data.User;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
public class UserEvaluator implements Evaluator {
|
||||
|
||||
@Override
|
||||
public boolean evaluate(Authentication authentication,
|
||||
Object targetDomainObject, String permission) {
|
||||
if (!(targetDomainObject instanceof User)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
User object = (User)targetDomainObject;
|
||||
|
||||
return permission.equals(Constants.PERM_EDIT_OWN) && object.equals(authentication.getPrincipal());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package info.bukova.isspst.services;
|
||||
|
||||
import info.bukova.isspst.services.settings.GlobalSettingsService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.exolab.castor.xml.MarshalException;
|
||||
import org.exolab.castor.xml.Marshaller;
|
||||
import org.exolab.castor.xml.Unmarshaller;
|
||||
import org.exolab.castor.xml.ValidationException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
|
||||
public class StringXmlMarshaller<T> {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(GlobalSettingsService.class);
|
||||
private final static String MARSHAL_ERROR = "Cannot marshal settings data: ";
|
||||
private final static String UNMARSHAL_ERROR = "Cannot unmarshal settings data: ";
|
||||
|
||||
private Marshaller marshaller;
|
||||
private Unmarshaller unmarshaller;
|
||||
|
||||
public StringXmlMarshaller(Marshaller marshaller, Unmarshaller unmarshaller) {
|
||||
this.marshaller = marshaller;
|
||||
this.unmarshaller = unmarshaller;
|
||||
}
|
||||
|
||||
public String marshalData(T data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringWriter wr = new StringWriter();
|
||||
try {
|
||||
marshaller.setWriter(wr);
|
||||
marshaller. marshal(data);
|
||||
} catch (MarshalException e) {
|
||||
log.error(MARSHAL_ERROR + e.getMessage());
|
||||
} catch (ValidationException e) {
|
||||
log.error(MARSHAL_ERROR + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
log.error(MARSHAL_ERROR + e.getMessage());
|
||||
}
|
||||
|
||||
return wr.toString();
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T unmarshalData(String data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringReader sr = new StringReader(data);
|
||||
try {
|
||||
unmarshaller.setClass(GenericTypeResolver.resolveTypeArgument(getClass(), StringXmlMarshaller.class));
|
||||
return (T) unmarshaller.unmarshal(sr);
|
||||
} catch (MarshalException e) {
|
||||
log.error(UNMARSHAL_ERROR + e.getMessage());
|
||||
} catch (ValidationException e) {
|
||||
log.error(UNMARSHAL_ERROR + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue