org.apache.catalina.realm.MemoryRealm Java Examples

The following examples show how to use org.apache.catalina.realm.MemoryRealm. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MBeanFactory.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Create a new Memory Realm.
 *
 * @param parent MBean Name of the associated parent component
 * @return the object name of the created realm
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createMemoryRealm(String parent) throws Exception {

     // Create a new MemoryRealm instance
    MemoryRealm realm = new MemoryRealm();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    Container container = getParentContainerFromParent(pname);
    // Add the new instance to its parent component
    container.setRealm(realm);
    // Return the corresponding MBean name
    ObjectName oname = realm.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }
}
 
Example #2
Source File: MBeanFactory.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new Memory Realm.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createMemoryRealm(String parent)
    throws Exception {

     // Create a new MemoryRealm instance
    MemoryRealm realm = new MemoryRealm();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    // Add the new instance to its parent component
    containerBase.setRealm(realm);
    // Return the corresponding MBean name
    ObjectName oname = realm.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }   

}
 
Example #3
Source File: MBeanFactory.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new Memory Realm.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createMemoryRealm(String parent)
    throws Exception {

     // Create a new MemoryRealm instance
    MemoryRealm realm = new MemoryRealm();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    // Add the new instance to its parent component
    containerBase.setRealm(realm);
    // Return the corresponding MBean name
    ObjectName oname = realm.getObjectName();
    if (oname != null) {
        return (oname.toString());
    } else {
        return null;
    }   

}
 
Example #4
Source File: ManagedExecutorServiceGetPrincipalInTaskTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
@Deployment(testable = false)
public static Archive<?> app() {
    ClassLoader cl = ManagedExecutorServiceGetPrincipalInTaskTest.class.getClassLoader();
    URL tcUserFile = cl.getResource("managed/tomcat-users.xml");

    return ShrinkWrap.create(WebArchive.class, "mp.war")
        .addClasses(ConcurrencyServlet.class, User.class)
        .addAsManifestResource(new StringAsset(
            "<Context>" +
            "   <Realm className=\"" + MemoryRealm.class.getName() +
                "\" pathname=\""+ tcUserFile.getFile() + "\" />" +
            "</Context>"), "context.xml")
            .addAsWebInfResource(new UrlAsset(cl.getResource("managed/web.xml")), "web.xml");
}