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
286 additions
and
51 deletions.
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
hawtio-web/src/main/java/io/hawt/web/AuthenticationConfiguration.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,63 @@ | ||
package io.hawt.web; | ||
|
||
import javax.security.auth.login.Configuration; | ||
|
||
public class AuthenticationConfiguration { | ||
|
||
private boolean enabled; | ||
private String realm; | ||
private String role; | ||
private String rolePrincipalClasses; | ||
private Configuration configuration; | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public String getRealm() { | ||
return realm; | ||
} | ||
|
||
public void setRealm(String realm) { | ||
this.realm = realm; | ||
} | ||
|
||
public String getRole() { | ||
return role; | ||
} | ||
|
||
public void setRole(String role) { | ||
this.role = role; | ||
} | ||
|
||
public String getRolePrincipalClasses() { | ||
return rolePrincipalClasses; | ||
} | ||
|
||
public void setRolePrincipalClasses(String rolePrincipalClasses) { | ||
this.rolePrincipalClasses = rolePrincipalClasses; | ||
} | ||
|
||
public Configuration getConfiguration() { | ||
return configuration; | ||
} | ||
|
||
public void setConfiguration(Configuration configuration) { | ||
this.configuration = configuration; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AuthenticationConfiguration[" + | ||
"enabled=" + enabled + | ||
", realm='" + realm + '\'' + | ||
", role='" + role + '\'' + | ||
", rolePrincipalClasses='" + rolePrincipalClasses + '\'' + | ||
", configuration=" + 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
26 changes: 26 additions & 0 deletions
26
hawtio-web/src/main/java/io/hawt/web/tomcat/TomcatLoginContextConfiguration.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,26 @@ | ||
package io.hawt.web.tomcat; | ||
|
||
import java.util.HashMap; | ||
import javax.security.auth.login.AppConfigurationEntry; | ||
import javax.security.auth.login.Configuration; | ||
|
||
/** | ||
* Configuration class to avoid having to deal with jaas.config files in the classpath | ||
*/ | ||
public class TomcatLoginContextConfiguration extends Configuration { | ||
|
||
private final AppConfigurationEntry entry = new TomcatAppConfigurationEntry(); | ||
|
||
@Override | ||
public AppConfigurationEntry[] getAppConfigurationEntry(String name) { | ||
return new AppConfigurationEntry[]{entry}; | ||
} | ||
|
||
private static final class TomcatAppConfigurationEntry extends AppConfigurationEntry { | ||
|
||
public TomcatAppConfigurationEntry() { | ||
super("io.hawt.web.tomcat.TomcatUserDatabaseLoginContext", LoginModuleControlFlag.REQUIRED, new HashMap<String, Object>()); | ||
} | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
hawtio-web/src/main/java/io/hawt/web/tomcat/TomcatPrincipal.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,20 @@ | ||
package io.hawt.web.tomcat; | ||
|
||
import java.io.Serializable; | ||
import java.security.Principal; | ||
|
||
public class TomcatPrincipal implements Principal, Serializable { | ||
|
||
// TODO: add role | ||
|
||
private final String name; | ||
|
||
public TomcatPrincipal(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
} |
Oops, something went wrong.