net.n2oapp.framework.access.metadata.compile.SecurityExtensionAttributeMapper Maven / Gradle / Ivy
The newest version!
package net.n2oapp.framework.access.metadata.compile;
import net.n2oapp.framework.access.metadata.Security;
import net.n2oapp.framework.access.metadata.SecurityObject;
import net.n2oapp.framework.api.metadata.compile.CompileProcessor;
import net.n2oapp.framework.api.metadata.compile.ExtensionAttributeMapper;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* Сборка атрибутов прав доступа
*/
@Component
public class SecurityExtensionAttributeMapper implements ExtensionAttributeMapper {
@Override
public String getNamespaceUri() {
return "http://n2oapp.net/framework/config/schema/security-1.0";
}
@Override
public Map mapAttributes(Map attributes, CompileProcessor p) {
Map result = new HashMap<>();
SecurityObject securityObject = new SecurityObject();
securityObject.setDenied(attributes.containsKey("denied") ? Boolean.valueOf(attributes.get("denied")) : null);
securityObject.setPermitAll(attributes.containsKey("permit-all") ? Boolean.valueOf(attributes.get("permit-all")) : null);
securityObject.setRoles(parseAttributes(attributes.get("roles")));
securityObject.setPermissions(parseAttributes(attributes.get("permissions")));
securityObject.setUsernames(parseAttributes(attributes.get("usernames")));
securityObject.setAuthenticated(attributes.containsKey("authenticated") ? Boolean.valueOf(attributes.get("authenticated")) : null);
securityObject.setAnonymous(attributes.containsKey("anonymous") ? Boolean.valueOf(attributes.get("anonymous")) : null);
List