Merge remote-tracking branch 'origin/master' into jetty-9.1
This commit is contained in:
commit
e9925bcba2
|
@ -31,6 +31,7 @@ import javax.security.auth.callback.CallbackHandler;
|
||||||
import javax.security.auth.callback.NameCallback;
|
import javax.security.auth.callback.NameCallback;
|
||||||
import javax.security.auth.callback.PasswordCallback;
|
import javax.security.auth.callback.PasswordCallback;
|
||||||
import javax.security.auth.callback.UnsupportedCallbackException;
|
import javax.security.auth.callback.UnsupportedCallbackException;
|
||||||
|
import javax.security.auth.login.FailedLoginException;
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
import javax.security.auth.spi.LoginModule;
|
import javax.security.auth.spi.LoginModule;
|
||||||
|
|
||||||
|
@ -199,9 +200,14 @@ public abstract class AbstractLoginModule implements LoginModule
|
||||||
callbacks[2] = new PasswordCallback("Enter password", false); //only used if framework does not support the ObjectCallback
|
callbacks[2] = new PasswordCallback("Enter password", false); //only used if framework does not support the ObjectCallback
|
||||||
return callbacks;
|
return callbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isIgnored ()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract UserInfo getUserInfo (String username) throws Exception;
|
public abstract UserInfo getUserInfo (String username) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,7 +220,10 @@ public abstract class AbstractLoginModule implements LoginModule
|
||||||
public boolean login() throws LoginException
|
public boolean login() throws LoginException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (isIgnored())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (callbackHandler == null)
|
if (callbackHandler == null)
|
||||||
throw new LoginException ("No callback handler");
|
throw new LoginException ("No callback handler");
|
||||||
|
|
||||||
|
@ -231,7 +240,7 @@ public abstract class AbstractLoginModule implements LoginModule
|
||||||
if ((webUserName == null) || (webCredential == null))
|
if ((webUserName == null) || (webCredential == null))
|
||||||
{
|
{
|
||||||
setAuthenticated(false);
|
setAuthenticated(false);
|
||||||
return isAuthenticated();
|
throw new FailedLoginException();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInfo userInfo = getUserInfo(webUserName);
|
UserInfo userInfo = getUserInfo(webUserName);
|
||||||
|
@ -239,12 +248,16 @@ public abstract class AbstractLoginModule implements LoginModule
|
||||||
if (userInfo == null)
|
if (userInfo == null)
|
||||||
{
|
{
|
||||||
setAuthenticated(false);
|
setAuthenticated(false);
|
||||||
return isAuthenticated();
|
throw new FailedLoginException();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentUser = new JAASUserInfo(userInfo);
|
currentUser = new JAASUserInfo(userInfo);
|
||||||
setAuthenticated(currentUser.checkCredential(webCredential));
|
setAuthenticated(currentUser.checkCredential(webCredential));
|
||||||
return isAuthenticated();
|
|
||||||
|
if (isAuthenticated())
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
throw new FailedLoginException();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -256,7 +269,8 @@ public abstract class AbstractLoginModule implements LoginModule
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
if (e instanceof LoginException)
|
||||||
|
throw (LoginException)e;
|
||||||
throw new LoginException (e.toString());
|
throw new LoginException (e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,9 +112,10 @@ public class PropertyFileLoginModule extends AbstractLoginModule
|
||||||
PropertyUserStore propertyUserStore = _propertyUserStores.get(_filename);
|
PropertyUserStore propertyUserStore = _propertyUserStores.get(_filename);
|
||||||
if (propertyUserStore == null)
|
if (propertyUserStore == null)
|
||||||
throw new IllegalStateException("PropertyUserStore should never be null here!");
|
throw new IllegalStateException("PropertyUserStore should never be null here!");
|
||||||
|
|
||||||
|
LOG.debug("Checking PropertyUserStore "+_filename+" for "+userName);
|
||||||
UserIdentity userIdentity = propertyUserStore.getUserIdentity(userName);
|
UserIdentity userIdentity = propertyUserStore.getUserIdentity(userName);
|
||||||
if(userIdentity==null)
|
if (userIdentity==null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Set<Principal> principals = userIdentity.getSubject().getPrincipals();
|
Set<Principal> principals = userIdentity.getSubject().getPrincipals();
|
||||||
|
@ -127,7 +128,7 @@ public class PropertyFileLoginModule extends AbstractLoginModule
|
||||||
}
|
}
|
||||||
|
|
||||||
Credential credential = (Credential)userIdentity.getSubject().getPrivateCredentials().iterator().next();
|
Credential credential = (Credential)userIdentity.getSubject().getPrivateCredentials().iterator().next();
|
||||||
LOG.debug("Found: " + userName + " in PropertyUserStore");
|
LOG.debug("Found: " + userName + " in PropertyUserStore "+_filename);
|
||||||
return new UserInfo(userName, credential, roles);
|
return new UserInfo(userName, credential, roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue