Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Heromyth committed Jul 7, 2019
1 parent d8601cb commit 05b3386
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 7 additions & 5 deletions source/hunt/shiro/authc/AbstractAuthenticator.d
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ abstract class AbstractAuthenticator : Authenticator, LogoutAware {
*/
//@SuppressWarnings({"UnusedDeclaration"})
void setAuthenticationListeners(Collection!(AuthenticationListener) listeners) {
if (listeners is null) {
if (listeners is null) {
this.listeners = new ArrayList!(AuthenticationListener)();
} else {
this.listeners = listeners;
Expand Down Expand Up @@ -192,7 +192,7 @@ abstract class AbstractAuthenticator : Authenticator, LogoutAware {
*/
final AuthenticationInfo authenticate(AuthenticationToken token){

if (token is null) {
if (token is null) {
throw new IllegalArgumentException("Method argument (authentication token) cannot be null.");
}

Expand All @@ -201,26 +201,28 @@ abstract class AbstractAuthenticator : Authenticator, LogoutAware {
AuthenticationInfo info;
try {
info = doAuthenticate(token);
if (info is null) {
if (info is null) {
string msg = "No account information found for authentication token [" ~
(cast(Object)token).toString() ~ "] by this " ~
"Authenticator instance. Please check that it is configured correctly.";
throw new AuthenticationException(msg);
}
} catch (Throwable t) {
warning(t);

AuthenticationException ae = null;
auto tCast = cast(AuthenticationException)t;
if (tCast !is null) {
ae = tCast;
}
if (ae is null) {
if (ae is null) {
//Exception thrown was not an expected AuthenticationException. Therefore it is probably a little more
//severe or unexpected. So, wrap in an AuthenticationException, log to warn, and propagate:
string msg = "Authentication failed for token submission [" ~
(cast(Object)token).toString() ~ "]. Possible unexpected " ~
"error? (Typical or expected login exceptions should extend from AuthenticationException).";
ae = new AuthenticationException(msg, t);
version(HUNT_DEBUG) warning(msg, t);
// version(HUNT_DEBUG) warning(msg, t);
}
try {
notifyFailure(token, ae);
Expand Down
5 changes: 4 additions & 1 deletion source/hunt/shiro/realm/AuthorizingRealm.d
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ abstract class AuthorizingRealm : AuthenticatingRealm,
* @return {@code true} if authorization caching should be utilized, {@code false} otherwise.
*/
bool isAuthorizationCachingEnabled() {
tracef("authorizationCachingEnabled=%s, isCachingEnabled=%s", authorizationCachingEnabled, isCachingEnabled());
version(HUNT_SHIRO_DEBUG) {
tracef("authorizationCachingEnabled=%s, isCachingEnabled=%s",
authorizationCachingEnabled, isCachingEnabled());
}
return isCachingEnabled() && authorizationCachingEnabled;
}

Expand Down

0 comments on commit 05b3386

Please sign in to comment.