Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#857: Tomcat security support for its conf/tomcat-users.xml. Work in …
…progress.
- Loading branch information
Showing
6 changed files
with
130 additions
and
68 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
hawtio-web/src/main/java/io/hawt/web/AuthenticationContainerDiscovery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.hawt.web; | ||
|
||
/** | ||
* SPI to allow various containers to discover and hook up needed configuration | ||
* changes to {@link AuthenticationConfiguration} so hawtio {@link AuthenticationFilter} | ||
* can integrate with the container easily. | ||
*/ | ||
public interface AuthenticationContainerDiscovery { | ||
|
||
/** | ||
* Gets the container name such as Apache Tomcat, used for logging purpose | ||
*/ | ||
String getContainerName(); | ||
|
||
/** | ||
* Whether the container can/should be used for authentication | ||
* | ||
* @param configuration the configuration option (muteable) | ||
* @return <tt>true</tt> if the container is being used for authentication. | ||
*/ | ||
boolean canAuthenticate(AuthenticationConfiguration configuration); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
hawtio-web/src/main/java/io/hawt/web/tomcat/TomcatAuthenticationContainerDiscovery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.hawt.web.tomcat; | ||
|
||
import io.hawt.web.AuthenticationConfiguration; | ||
import io.hawt.web.AuthenticationContainerDiscovery; | ||
|
||
/** | ||
* To use Apache Tomcat using its conf/tomcat-users.xml for authentication. | ||
*/ | ||
public class TomcatAuthenticationContainerDiscovery implements AuthenticationContainerDiscovery { | ||
|
||
@Override | ||
public String getContainerName() { | ||
return "Apache Tomcat"; | ||
} | ||
|
||
@Override | ||
public boolean canAuthenticate(AuthenticationConfiguration configuration) { | ||
// TODO: are we running in Tomcat | ||
// lookup in JMX or env check? | ||
|
||
boolean isTomcat = true; | ||
if (isTomcat) { | ||
configuration.setConfiguration(new TomcatLoginContextConfiguration()); | ||
configuration.setRolePrincipalClasses(TomcatPrincipal.class.getName()); | ||
} | ||
|
||
return isTomcat; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters