You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lh...@apache.org on 2010/01/14 21:12:06 UTC
svn commit: r899386 -
/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/realm/ldap/AbstractLdapRealm.java
Author: lhazlewood
Date: Thu Jan 14 20:12:02 2010
New Revision: 899386
URL: http://svn.apache.org/viewvc?rev=899386&view=rev
Log:
SHIRO-120 - propagated exceptions as shiro-specific exceptions instead of logging them.
Modified:
incubator/shiro/trunk/core/src/main/java/org/apache/shiro/realm/ldap/AbstractLdapRealm.java
Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/realm/ldap/AbstractLdapRealm.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/realm/ldap/AbstractLdapRealm.java?rev=899386&r1=899385&r2=899386&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/realm/ldap/AbstractLdapRealm.java (original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/realm/ldap/AbstractLdapRealm.java Thu Jan 14 20:12:02 2010
@@ -18,17 +18,17 @@
*/
package org.apache.shiro.realm.ldap;
-import javax.naming.NamingException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
+import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.naming.NamingException;
/**
* <p>A {@link org.apache.shiro.realm.Realm} that authenticates with an LDAP
@@ -183,17 +183,14 @@
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
- AuthenticationInfo info = null;
+ AuthenticationInfo info;
try {
info = queryForAuthenticationInfo(token, this.ldapContextFactory);
} catch (javax.naming.AuthenticationException e) {
throw new AuthenticationException( "LDAP authentication failed.", e );
-
} catch (NamingException e) {
- if (log.isErrorEnabled()) {
- final String message = "LDAP naming error while attempting to authenticate user.";
- log.error(message, e);
- }
+ String msg = "LDAP naming error while attempting to authenticate user.";
+ throw new AuthenticationException(msg, e);
}
return info;
@@ -201,14 +198,12 @@
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
- AuthorizationInfo info = null;
+ AuthorizationInfo info;
try {
info = queryForAuthorizationInfo(principals, this.ldapContextFactory);
} catch (NamingException e) {
- if (log.isErrorEnabled()) {
- final String message = "LDAP naming error while attempting to retrieve authorization for user [" + principals + "].";
- log.error(message, e);
- }
+ String msg = "LDAP naming error while attempting to retrieve authorization for user [" + principals + "].";
+ throw new AuthorizationException(msg, e);
}
return info;