Search in sources :

Example 31 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class AuthenticationManagerTest method testCustomJAASLoginModuleOptions.

@Test
public void testCustomJAASLoginModuleOptions() throws Exception {
    Properties props = TestEngine.getTestProperties();
    // Supply a custom LoginModule options
    props.put("jspwiki.loginModule.options.key1", "value1");
    props.put("jspwiki.loginModule.options.key2", "value2");
    props.put("jspwiki.loginModule.options.key3", "value3");
    // Init the engine and verify that we initialized with the correct
    // options
    WikiEngine engine = new TestEngine(props);
    AuthenticationManager authMgr = engine.getAuthenticationManager();
    Map<String, String> options = authMgr.m_loginModuleOptions;
    Assert.assertEquals(3, options.size());
    Assert.assertTrue(options.containsKey("key1"));
    Assert.assertTrue(options.containsKey("key2"));
    Assert.assertTrue(options.containsKey("key3"));
    Assert.assertEquals("value1", options.get("key1"));
    Assert.assertEquals("value2", options.get("key2"));
    Assert.assertEquals("value3", options.get("key3"));
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) WikiSessionTest(org.apache.wiki.WikiSessionTest) Test(org.junit.Test)

Example 32 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class AuthenticationManagerTest method testCustomJAASLoginModule.

@Test
public void testCustomJAASLoginModule() throws Exception {
    Properties props = TestEngine.getTestProperties();
    // Supply a custom LoginModule class
    props.put("jspwiki.loginModule.class", "org.apache.wiki.auth.login.CookieAssertionLoginModule");
    // Init the engine and verify that we initialized with a custom auth
    // login module
    WikiEngine engine = new TestEngine(props);
    AuthenticationManager authMgr = engine.getAuthenticationManager();
    Assert.assertEquals(CookieAssertionLoginModule.class, authMgr.m_loginModuleClass);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) WikiSessionTest(org.apache.wiki.WikiSessionTest) Test(org.junit.Test)

Example 33 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class GroupTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    WikiEngine engine = new TestEngine(props);
    m_wiki = engine.getApplicationName();
    m_group = new Group("TestGroup", m_wiki);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) Before(org.junit.Before)

Example 34 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class MetaWeblogHandler method newPost.

/**
 *  Adds a new post to the blog.
 *
 *  @param blogid The id of the blog.
 *  @param username The username to use
 *  @param password The password
 *  @param content As per Metaweblogapi contract
 *  @param publish This parameter is ignored for JSPWiki.
 *  @return Returns an empty string
 *  @throws XmlRpcException If something goes wrong
 */
public String newPost(String blogid, String username, String password, Hashtable content, boolean publish) throws XmlRpcException {
    log.info("metaWeblog.newPost() called");
    WikiEngine engine = m_context.getEngine();
    WikiPage page = engine.getPage(blogid);
    checkPermissions(page, username, password, "createPages");
    try {
        WeblogEntryPlugin plugin = new WeblogEntryPlugin();
        String pageName = plugin.getNewEntryPage(engine, blogid);
        WikiPage entryPage = new WikiPage(engine, pageName);
        entryPage.setAuthor(username);
        WikiContext context = new WikiContext(engine, entryPage);
        StringBuilder text = new StringBuilder();
        text.append("!" + content.get("title"));
        text.append("\n\n");
        text.append(content.get("description"));
        log.debug("Writing entry: " + text);
        engine.saveText(context, text.toString());
    } catch (Exception e) {
        log.error("Failed to create weblog entry", e);
        throw new XmlRpcException(0, "Failed to create weblog entry: " + e.getMessage());
    }
    // FIXME:
    return "";
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) WeblogEntryPlugin(org.apache.wiki.plugin.WeblogEntryPlugin) WikiEngine(org.apache.wiki.WikiEngine) XmlRpcException(org.apache.xmlrpc.XmlRpcException) WikiSecurityException(org.apache.wiki.auth.WikiSecurityException) ProviderException(org.apache.wiki.api.exceptions.ProviderException) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 35 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class UserProfileTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    PropertyConfigurator.configure(props);
    WikiEngine engine = new TestEngine(props);
    m_db = engine.getUserManager().getUserDatabase();
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) Before(org.junit.Before)

Aggregations

WikiEngine (org.apache.wiki.WikiEngine)67 WikiPage (org.apache.wiki.WikiPage)29 ProviderException (org.apache.wiki.api.exceptions.ProviderException)15 Attachment (org.apache.wiki.attachment.Attachment)10 WikiContext (org.apache.wiki.WikiContext)9 Properties (java.util.Properties)8 JspWriter (javax.servlet.jsp.JspWriter)8 TestEngine (org.apache.wiki.TestEngine)8 Element (org.jdom2.Element)7 IOException (java.io.IOException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Calendar (java.util.Calendar)5 Date (java.util.Date)5 ResourceBundle (java.util.ResourceBundle)5 PluginException (org.apache.wiki.api.exceptions.PluginException)5 Before (org.junit.Before)5 Principal (java.security.Principal)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 InternalWikiException (org.apache.wiki.InternalWikiException)4 ArrayList (java.util.ArrayList)3