Skip to content

Commit

Permalink
Remove legacy logging in AbstractCell
Browse files Browse the repository at this point in the history
AbstractCell offered a logging system that predates per-cell log level
adjustments. There is no longer any need for that logging system and
this patch replaces all uses of it with a regular static per-class
Logger instance.

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: http://rb.dcache.org/r/6279/
  • Loading branch information
gbehrmann committed Nov 26, 2013
1 parent a6500bb commit 021b410
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 275 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
import org.ietf.jgss.GSSManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.security.auth.Subject;

Expand Down Expand Up @@ -45,6 +47,8 @@
*/
public class GsiFtpDoorV1 extends GssFtpDoorV1
{
private static final Logger LOGGER = LoggerFactory.getLogger(GsiFtpDoorV1.class);

@Option(
name="service-key",
required=true
Expand Down Expand Up @@ -101,8 +105,8 @@ public void startTlog(FTPTransactionLog tlog, String path, String action) {
_engine.getInetAddress());
}
catch (Exception e) {
error("GsiFtpDoor: couldn't start tLog. " +
"Ignoring exception: " + e.getMessage());
LOGGER.error("GsiFtpDoor: couldn't start tLog. " +
"Ignoring exception: {}", e.getMessage());
}
}
}
Expand All @@ -117,7 +121,7 @@ protected GSSContext getServiceContext() throws GSSException {
catch (CredentialException gce) {
String errmsg = "GsiFtpDoor: couldn't load " +
"host globus credentials: " + gce.toString();
error(errmsg);
LOGGER.error(errmsg);
throw new GSSException(GSSException.NO_CRED, 0, errmsg);
}
catch(IOException ioe) {
Expand Down Expand Up @@ -174,13 +178,13 @@ public void ac_user(String arg)

reply("200 User " + arg + " logged in");
} catch (GSSException | CertificateException e) {
error("Failed to extract X509 chain: " + e);
LOGGER.error("Failed to extract X509 chain: {}", e.toString());
println("530 Login failed: " + e.getMessage());
} catch (PermissionDeniedCacheException e) {
warn("Login denied for " + subject + ": " + e);
LOGGER.warn("Login denied for {}: {}", subject, e.getMessage());
println("530 Login incorrect");
} catch (CacheException e) {
error("Login failed for " + subject + ": " + e);
LOGGER.error("Login failed for {}: {}", subject, e.getMessage());
println("530 Login failed: " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.ietf.jgss.GSSException;
import org.ietf.jgss.GSSName;
import org.ietf.jgss.MessageProp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.InetAddress;
import java.net.UnknownHostException;
Expand All @@ -23,6 +25,8 @@

public abstract class GssFtpDoorV1 extends AbstractFtpDoorV1
{
private static final Logger LOGGER = LoggerFactory.getLogger(GssFtpDoorV1.class);

public static final String GLOBUS_URL_COPY_DEFAULT_USER =
":globus-mapping:";

Expand Down Expand Up @@ -65,7 +69,7 @@ protected void secure_reply(String answer, String code) {

@Override
public void ac_auth(String arg) {
info("GssFtpDoorV1::secure_reply: going to authorize using " + _gssFlavor);
LOGGER.info("GssFtpDoorV1::secure_reply: going to authorize using {}", _gssFlavor);
if ( !arg.equals("GSSAPI") ) {
reply("504 Authenticating method not supported");
return;
Expand All @@ -78,7 +82,7 @@ public void ac_auth(String arg) {
try {
_serviceContext = getServiceContext();
} catch( Exception e ) {
error(e.toString());
LOGGER.error(e.toString());
reply("500 Error: " + e.toString());
return;
}
Expand Down Expand Up @@ -119,13 +123,13 @@ public void ac_adat(String arg) {
} catch (GSSException e) {
CertPathValidatorException cpve =
getFirst(filter(Throwables.getCausalChain(e), CertPathValidatorException.class), null);
if (cpve != null && cpve.getCertPath() != null && _logger.isDebugEnabled()) {
_logger.error("Authentication failed: {} in #{} of {}",
if (cpve != null && cpve.getCertPath() != null && LOGGER.isDebugEnabled()) {
LOGGER.error("Authentication failed: {} in #{} of {}",
e.getMessage(), cpve.getIndex() + 1, cpve.getCertPath());
} else {
_logger.error("Authentication failed: {}", e.getMessage());
LOGGER.error("Authentication failed: {}", e.getMessage());
}
_logger.trace("Authentication failed", e);
LOGGER.trace("Authentication failed", e);
reply("535 Authentication failed: " + e.getMessage());
return;
} finally {
Expand All @@ -144,8 +148,8 @@ public void ac_adat(String arg) {
reply("335 ADAT=");
}
else {
info("GssFtpDoorV1::ac_adat: security context established " +
"with " + _gssIdentity);
LOGGER.info("GssFtpDoorV1::ac_adat: security context established " +
"with {}", _gssIdentity);
reply("235 OK");
}
}
Expand All @@ -171,8 +175,8 @@ public void secure_command(String answer, String sectype)
data = _serviceContext.unwrap(data, 0, data.length, prop);
} catch( GSSException e ) {
reply("500 Can not decrypt command: " + e);
error("GssFtpDoorV1::secure_command: got GSSException: " +
e.getMessage());
LOGGER.error("GssFtpDoorV1::secure_command: got GSSException: {}",
e.getMessage());
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.ietf.jgss.GSSManager;
import org.ietf.jgss.GSSName;
import org.ietf.jgss.Oid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.security.auth.Subject;
import javax.security.auth.kerberos.KerberosPrincipal;
Expand Down Expand Up @@ -43,6 +45,8 @@
*/
public class KerberosFtpDoorV1 extends GssFtpDoorV1 {

private static final Logger LOGGER = LoggerFactory.getLogger(KerberosFtpDoorV1.class);

private String _myPrincipalStr;
private String[] _kdcList;

Expand All @@ -63,8 +67,8 @@ protected void init()
String problem = "KerberosFTPDoorV1: -svc-principal not specified";
throw new IllegalArgumentException(problem);
}
info("KerberosFTPDoorV1: initializing kerberos ftp door service. " +
"Principal is '" + _myPrincipalStr + "'");
LOGGER.info("KerberosFTPDoorV1: initializing kerberos ftp door service. " +
"Principal is '{}'", _myPrincipalStr);
_gssFlavor = "k5";
String kdclist;
if( ( kdclist = args.getOpt("kdc-list") ) != null ) {
Expand All @@ -73,7 +77,7 @@ protected void init()
_kdcList = new String[n];
for( int i = 0; i < n; i++ ) {
_kdcList[i] = tokens.nextToken();
info("KerberosFTPDoorV1: kdc[" + i + "] = " + _kdcList[i]);
LOGGER.info("KerberosFTPDoorV1: kdc[{}] = {}", i, _kdcList[i]);
}
}
ftpDoorName="Kerberos FTP";
Expand All @@ -89,8 +93,8 @@ public void startTlog(FTPTransactionLog tlog, String path, String action) {
_engine.getInetAddress());
}
catch (Exception e) {
error("KerberosFTPDoorV1::startTlog: couldn't start tLog. " +
"Ignoring exception: " + e.getMessage());
LOGGER.error("KerberosFTPDoorV1::startTlog: couldn't start tLog. " +
"Ignoring exception: {}", e.getMessage());
}
}
}
Expand All @@ -102,23 +106,22 @@ protected GSSContext getServiceContext() throws GSSException {
int nretry = 10;
GSSException error = null;
Properties sysp = System.getProperties();
GSSCredential MyCredential = null;
GSSCredential myCredential = null;

GSSManager _GManager = GSSManager.getInstance();
debug("KerberosFTPDoorV1::getServiceContext: calling " +
"_GManager.createName(\"" + _myPrincipalStr + "\", null)");
GSSName MyPrincipal = _GManager.createName(_myPrincipalStr, null);
info("KerberosFTPDoorV1::getServiceContext: principal=\"" +
MyPrincipal + "\"");
GSSName myPrincipal = _GManager.createName(_myPrincipalStr, null);
LOGGER.info("KerberosFTPDoorV1::getServiceContext: principal=\"{}\"", myPrincipal);

while( MyCredential == null && nretry-- > 0 ) {
while( myCredential == null && nretry-- > 0 ) {
if( _kdcList != null && _kdcList.length > 0 ) {
String kdc = _kdcList[nretry % _kdcList.length];
sysp.put("java.security.krb5.kdc", kdc);
}

try {
MyCredential = _GManager.createCredential(MyPrincipal,
myCredential = _GManager.createCredential(myPrincipal,
GSSCredential.DEFAULT_LIFETIME,
krb5Mechanism,
GSSCredential.ACCEPT_ONLY);
Expand All @@ -129,12 +132,11 @@ protected GSSContext getServiceContext() throws GSSException {
error = e;
}
}
if( MyCredential == null ) {
if( myCredential == null ) {
throw error;
}
info("KerberosFTPDoorV1::getServiceContext: credential=\"" +
MyCredential + "\"");
GSSContext context = _GManager.createContext(MyCredential);
LOGGER.info("KerberosFTPDoorV1::getServiceContext: credential=\"{}\"", myCredential);
GSSContext context = _GManager.createContext(myCredential);

try {
ChannelBinding cb = new ChannelBinding(_engine.getInetAddress(),
Expand All @@ -145,7 +147,7 @@ protected GSSContext getServiceContext() throws GSSException {
catch( UnknownHostException e ) {
String errmsg = "KerberosFTPDoorV1::getServiceContext: can't " +
"bind channel to localhost:" + e.getMessage();
error(errmsg);
LOGGER.error(errmsg);
throw new GSSException(GSSException.NO_CRED, 0, errmsg);
}

Expand Down Expand Up @@ -174,10 +176,10 @@ public void ac_user(String arg)
login(subject);
reply("200 User " + arg + " logged in");
} catch (PermissionDeniedCacheException e) {
warn("Login denied for " + subject);
LOGGER.warn("Login denied for {}", subject);
println("530 Login incorrect");
} catch (CacheException e) {
error("Login failed for " + subject + ": " + e);
LOGGER.error("Login failed for {}: {}", subject, e.getMessage());
println("530 Login failed: " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

package diskCacheV111.doors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.security.auth.Subject;

import java.util.concurrent.ExecutionException;
Expand All @@ -58,6 +61,8 @@
*/
public class WeakFtpDoorV1 extends AbstractFtpDoorV1 {

private static final Logger LOGGER = LoggerFactory.getLogger(WeakFtpDoorV1.class);

/** Creates a new instance of WeakFtpDoorV1
* @throws ExecutionException
* @throws InterruptedException */
Expand Down Expand Up @@ -114,10 +119,10 @@ public void ac_pass(String arg)
try {
login(subject);
} catch (PermissionDeniedCacheException e) {
warn("Login denied for " + subject);
LOGGER.warn("Login denied for {}", subject);
println("530 Login incorrect");
} catch (CacheException e) {
error("Login failed for " + subject + ": " + e);
LOGGER.error("Login failed for {}: {}", subject, e);
println("530 Login failed: " + e.getMessage());
}

Expand All @@ -134,8 +139,8 @@ public void startTlog(FTPTransactionLog tlog, String path, String action) {
_engine.getInetAddress());
}
catch (Exception e) {
error("WeakFtpDoor: couldn't start tLog. " +
"Ignoring exception: " + e.getMessage());
LOGGER.error("WeakFtpDoor: couldn't start tLog. " +
"Ignoring exception: {}", e.getMessage());
}
}
}
Expand Down
Loading

0 comments on commit 021b410

Please sign in to comment.