[Minor] added ComponentContainer.getRealm(Certificate)
- instead of throwing an exception if the realm property is missing on the certificate, we first see if the default realm is available
This commit is contained in:
parent
318b186641
commit
c307102e33
|
@ -65,8 +65,8 @@ public interface ComponentContainer {
|
||||||
* @return the {@link StrolchRealm}
|
* @return the {@link StrolchRealm}
|
||||||
*
|
*
|
||||||
* @throws StrolchException
|
* @throws StrolchException
|
||||||
* if the user does not have a {@link StrolchConstants#PROP_REALM} property configured, or if the realm
|
* if the user does not have a {@link StrolchConstants#PROP_REALM} property configured, and the default
|
||||||
* does not exist with the found value
|
* realm is not configured, or if the realm does not exist with the found value
|
||||||
*/
|
*/
|
||||||
public abstract StrolchRealm getRealm(Certificate certificate) throws StrolchException;
|
public abstract StrolchRealm getRealm(Certificate certificate) throws StrolchException;
|
||||||
|
|
||||||
|
|
|
@ -114,9 +114,13 @@ public class ComponentContainerImpl implements ComponentContainer {
|
||||||
|
|
||||||
String realmName = certificate.getProperty(StrolchConstants.PROP_REALM);
|
String realmName = certificate.getProperty(StrolchConstants.PROP_REALM);
|
||||||
if (StringHelper.isEmpty(realmName)) {
|
if (StringHelper.isEmpty(realmName)) {
|
||||||
String msg = "The User {0} is missing the property {1}";
|
if (getRealmNames().contains(StrolchConstants.DEFAULT_REALM)) {
|
||||||
throw new StrolchException(
|
realmName = StrolchConstants.DEFAULT_REALM;
|
||||||
MessageFormat.format(msg, certificate.getUsername(), StrolchConstants.PROP_REALM));
|
} else {
|
||||||
|
String msg = "The User {0} is missing the property {1} and the Realm {2} can not be used as it does not exist!";
|
||||||
|
throw new StrolchException(MessageFormat.format(msg, certificate.getUsername(),
|
||||||
|
StrolchConstants.PROP_REALM, StrolchConstants.DEFAULT_REALM));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue