![JAR search and dependency download from the Maven repository](/logo.png)
it.eng.spago.security.xmlauthorizations.XMLUserProfile Maven / Gradle / Ivy
/**
Copyright 2004, 2007 Engineering Ingegneria Informatica S.p.A.
This file is part of Spago.
Spago is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
any later version.
Spago is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Spago; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**/
package it.eng.spago.security.xmlauthorizations;
import it.eng.spago.base.SourceBean;
import it.eng.spago.error.EMFInternalError;
import it.eng.spago.security.IExtendedEngUserProfile;
import java.util.ArrayList;
import java.util.Collection;
/**
* @author zoppello
*
* This class implement the IEngUserProfile interface basing on the engiweb
* profile manager system
*/
public class XMLUserProfile implements IExtendedEngUserProfile {
private static final long serialVersionUID = 1L;
private String _userID = null;
private SourceBean _user = null;
private String _applicationName = null;
private ArrayList _roles = null;
private ArrayList _functionalities = null;
private ArrayList _resources = null;
public XMLUserProfile(String userID) throws EMFInternalError {
_userID = userID;
_user = XMLAuthorizationsRepository.getInstance().getUser(userID);
} // public XMLUserProfile(String userID) throws EMFInternalError
/**
* @see it.eng.spago.security.IEngUserProfile#getUserAttribute(java.lang.String)
*/
public Object getUserAttribute(String attributeName) throws EMFInternalError {
return _user.getAttribute(attributeName);
} // public Object getUserAttribute(String attributeName) throws EMFInternalError
/* (non-Javadoc)
* @see it.eng.spago.security.IEngUserProfile#getUserAttributeNames()
*/
public Collection getUserAttributeNames() {
return null;
}
/**
* @see it.eng.spago.security.IEngUserProfile#hasRole(java.lang.String)
*/
public boolean hasRole(String roleName) throws EMFInternalError {
return getRoles().contains(roleName.toUpperCase());
} // public boolean hasRole(String roleName) throws EMFInternalError
/**
* @see it.eng.spago.security.IEngUserProfile#getRoles()
*/
public Collection getRoles() throws EMFInternalError {
if (_roles == null)
_roles = new ArrayList(XMLAuthorizationsRepository.getInstance().getUserRoles(_userID));
return _roles;
} // public Collection getRoles() throws EMFInternalError
/**
* @see it.eng.spago.security.IEngUserProfile#getFunctionalities()
*/
public Collection getFunctionalities() throws EMFInternalError {
if (_functionalities == null)
_functionalities = new ArrayList(XMLAuthorizationsRepository.getInstance().getUserFunctionalities(_userID));
return _functionalities;
} // public Collection getFunctionalities() throws EMFInternalError
/* (non-Javadoc)
* @see it.eng.spago.security.IEngUserProfile#getFunctionalitiesByRole(java.lang.String)
*/
public Collection getFunctionalitiesByRole(String roleName) throws EMFInternalError {
return XMLAuthorizationsRepository.getInstance().getRoleFunctionalities(roleName);
}
/**
* @see it.eng.spago.security.IEngUserProfile#isAbleToExecuteAction(java.lang.String, java.lang.String)
*/
public boolean isAbleToExecuteAction(String actionName) throws EMFInternalError {
String functionality = XMLAuthorizationsBusinessMapper.getInstance().mapActionToBusinessProcess(actionName);
if (functionality == null)
return XMLAuthorizationsRepository.getInstance().getDefaultAuthorization();
else
return getFunctionalities().contains(functionality.toUpperCase());
} // public boolean isAbleToExecuteAction(String actionName) throws EMFInternalError
/**
* @see it.eng.spago.security.IEngUserProfile#isAbleToExecuteModuleInPage(java.lang.String, java.lang.String)
*/
public boolean isAbleToExecuteModuleInPage(String pageName, String moduleName) throws EMFInternalError {
String functionality = XMLAuthorizationsBusinessMapper.getInstance()
.mapPageModuleToBusinessProcess(pageName, moduleName);
if (functionality == null)
return XMLAuthorizationsRepository.getInstance().getDefaultAuthorization();
else
return getFunctionalities().contains(functionality.toUpperCase());
} // public boolean isAbleToExecuteModuleInPage(String pageName, String moduleName) throws EMFInternalError
/**
* @see it.eng.spago.security.IEngUserProfile#setApplication(java.lang.String)
*/
public void setApplication(String applicationName) throws EMFInternalError {
_applicationName = applicationName;
} // public void setApplication(String applicationName) throws EMFInternalError
/**
* @see it.eng.spago.security.IEngUserProfile#getUserUniqueIdentifier()
*/
public Object getUserUniqueIdentifier() {
return _userID;
} // public Object getUserUniqueIdentifier()
public boolean canAccessResource(String resourceID) throws EMFInternalError{
return getAccessibleResources().contains(resourceID);
}
public boolean canExecuteFunctionality(String functionalityID) throws EMFInternalError{
return getFunctionalities().contains(functionalityID);
}
public Collection getAccessibleResources() throws EMFInternalError{
if (_resources == null)
_resources = new ArrayList(XMLAuthorizationsRepository.getInstance().getUserResources(_userID));
return _resources;
}
} // public class XMLUserProfile implements IEngUserProfile
© 2015 - 2025 Weber Informatics LLC | Privacy Policy