use of org.jaffa.security.businessfunctionsdomain.BusinessFunctions in project jaffa-framework by jaffa-projects.
the class BusinessFunctionManager method registerResource.
/**
* registerResource - Registers the roles into the business function repository from a business-functions.xml file.
* @param resource the object that contains the xml config file.
* @param context key with which config file to be registered.
* @throws JAXBException
* @throws SAXException
* @throws IOException
*/
@Override
public void registerResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
BusinessFunctions businessFunctions = JAXBHelper.unmarshalConfigFile(BusinessFunctions.class, resource, CONFIGURATION_SCHEMA_FILE);
if (businessFunctions.getBusinessFunction() != null) {
for (final BusinessFunction businessFunction : businessFunctions.getBusinessFunction()) {
ContextKey contextKey = new ContextKey(businessFunction.getName(), resource.getURI().toString(), variation, context);
registerBusinessFunction(contextKey, businessFunction);
}
}
}
use of org.jaffa.security.businessfunctionsdomain.BusinessFunctions in project jaffa-framework by jaffa-projects.
the class BusinessFunctionManager method unregisterResource.
/**
* unregisterResource - Unregisters the roles from the business function repository using a business-functions.xml file.
* @param resource the object that contains the xml config file.
* @param context key with which config file to be registered.
* @throws JAXBException
* @throws SAXException
* @throws IOException
*/
@Override
public void unregisterResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
BusinessFunctions businessFunctions = JAXBHelper.unmarshalConfigFile(BusinessFunctions.class, resource, CONFIGURATION_SCHEMA_FILE);
if (businessFunctions.getBusinessFunction() != null) {
for (final BusinessFunction businessFunction : businessFunctions.getBusinessFunction()) {
ContextKey contextKey = new ContextKey(businessFunction.getName(), resource.getURI().toString(), variation, context);
unregisterBusinessFunction(contextKey);
}
}
}
use of org.jaffa.security.businessfunctionsdomain.BusinessFunctions in project jaffa-framework by jaffa-projects.
the class CheckPolicyComponent method readFunctions.
/**
* This reads the bussiness-functions from the bussiness-functions.xml file
* @throws ApplicationExceptions if any error occurs.
*/
private List readFunctions() throws ApplicationExceptions {
ApplicationExceptions appExps = new ApplicationExceptions();
ArrayList bflist = new ArrayList();
InputStream stream = null;
try {
stream = URLHelper.newExtendedURL("resources/business-functions.xml").openStream();
// create a JAXBContext capable of handling classes generated into the package
JAXBContext jc = JAXBContext.newInstance("org.jaffa.security.businessfunctionsdomain");
// create an Unmarshaller
Unmarshaller u = jc.createUnmarshaller();
// enable validation
u.setSchema(JAXBHelper.createSchema(SCHEMA));
// unmarshal a document into a tree of Java content objects composed of classes from the package.
BusinessFunctions businessFunctions = (BusinessFunctions) u.unmarshal(XmlHelper.stripDoctypeDeclaration(stream));
for (Iterator i = businessFunctions.getBusinessFunction().iterator(); i.hasNext(); ) {
bflist.add(((BusinessFunction) i.next()).getName());
}
} catch (Exception e) {
appExps.add(new CheckPolicyException(CheckPolicyException.PROP_FILEREAD_ERROR, StringHelper.convertToHTML(e.getMessage())));
throw appExps;
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (IOException e) {
// do nothing
}
}
return bflist;
}
Aggregations