use of org.apache.wiki.api.exceptions.NoRequiredPropertyException in project jspwiki by apache.
the class UserDatabaseLoginModuleTest method setUp.
/**
*/
@Before
public void setUp() throws Exception {
Properties props = TestEngine.getTestProperties();
props.put(XMLUserDatabase.PROP_USERDATABASE, "target/test-classes/userdatabase.xml");
m_engine = new TestEngine(props);
m_db = new XMLUserDatabase();
m_subject = new Subject();
try {
m_db.initialize(m_engine, props);
} catch (NoRequiredPropertyException e) {
System.err.println(e.getMessage());
Assert.assertTrue(false);
}
}
use of org.apache.wiki.api.exceptions.NoRequiredPropertyException in project jspwiki by apache.
the class WebContainerLoginModuleTest method setUp.
@Before
public void setUp() throws Exception {
Properties props = TestEngine.getTestProperties();
props.put(XMLUserDatabase.PROP_USERDATABASE, "target/test-classes/userdatabase.xml");
m_engine = new TestEngine(props);
m_db = new XMLUserDatabase();
m_subject = new Subject();
try {
m_db.initialize(m_engine, props);
} catch (NoRequiredPropertyException e) {
System.err.println(e.getMessage());
Assert.assertTrue(false);
}
}
use of org.apache.wiki.api.exceptions.NoRequiredPropertyException in project jspwiki by apache.
the class AuthorizationManager method locateImplementation.
private Object locateImplementation(String clazz) throws WikiException {
if (clazz != null) {
try {
Class<?> authClass = ClassUtil.findClass("org.apache.wiki.auth.authorize", clazz);
Object impl = authClass.newInstance();
return impl;
} catch (ClassNotFoundException e) {
log.fatal("Authorizer " + clazz + " cannot be found", e);
throw new WikiException("Authorizer " + clazz + " cannot be found", e);
} catch (InstantiationException e) {
log.fatal("Authorizer " + clazz + " cannot be created", e);
throw new WikiException("Authorizer " + clazz + " cannot be created", e);
} catch (IllegalAccessException e) {
log.fatal("You are not allowed to access this authorizer class", e);
throw new WikiException("You are not allowed to access this authorizer class", e);
}
}
throw new NoRequiredPropertyException("Unable to find a " + PROP_AUTHORIZER + " entry in the properties.", PROP_AUTHORIZER);
}
use of org.apache.wiki.api.exceptions.NoRequiredPropertyException in project jspwiki by apache.
the class GroupManager method getGroupDatabase.
/**
* Returns the current external {@link GroupDatabase} in use. This method
* is guaranteed to return a properly-initialized GroupDatabase, unless
* it could not be initialized. In that case, this method throws
* a {@link org.apache.wiki.api.exceptions.WikiException}. The GroupDatabase
* is lazily initialized.
* @throws org.apache.wiki.auth.WikiSecurityException if the GroupDatabase could
* not be initialized
* @return the current GroupDatabase
* @since 2.3
*/
public GroupDatabase getGroupDatabase() throws WikiSecurityException {
if (m_groupDatabase != null) {
return m_groupDatabase;
}
String dbClassName = "<unknown>";
String dbInstantiationError = null;
Throwable cause = null;
try {
Properties props = m_engine.getWikiProperties();
dbClassName = props.getProperty(PROP_GROUPDATABASE);
if (dbClassName == null) {
dbClassName = XMLGroupDatabase.class.getName();
}
log.info("Attempting to load group database class " + dbClassName);
Class<?> dbClass = ClassUtil.findClass("org.apache.wiki.auth.authorize", dbClassName);
m_groupDatabase = (GroupDatabase) dbClass.newInstance();
m_groupDatabase.initialize(m_engine, m_engine.getWikiProperties());
log.info("Group database initialized.");
} catch (ClassNotFoundException e) {
log.error("GroupDatabase class " + dbClassName + " cannot be found.", e);
dbInstantiationError = "Failed to locate GroupDatabase class " + dbClassName;
cause = e;
} catch (InstantiationException e) {
log.error("GroupDatabase class " + dbClassName + " cannot be created.", e);
dbInstantiationError = "Failed to create GroupDatabase class " + dbClassName;
cause = e;
} catch (IllegalAccessException e) {
log.error("You are not allowed to access group database class " + dbClassName + ".", e);
dbInstantiationError = "Access GroupDatabase class " + dbClassName + " denied";
cause = e;
} catch (NoRequiredPropertyException e) {
log.error("Missing property: " + e.getMessage() + ".");
dbInstantiationError = "Missing property: " + e.getMessage();
cause = e;
}
if (dbInstantiationError != null) {
throw new WikiSecurityException(dbInstantiationError + " Cause: " + (cause != null ? cause.getMessage() : ""), cause);
}
return m_groupDatabase;
}
Aggregations