Part of changes to switch from using System.err.println to using log4j.

This commit is contained in:
Juan Carlos Luciani 2007-02-15 18:16:52 +00:00
parent 76e1078be0
commit e1e74055b5
23 changed files with 344 additions and 273 deletions

View File

@ -31,6 +31,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.apache.log4j.Logger;
/**
* AuthMechConfig Class.
@ -40,6 +41,8 @@ import org.xml.sax.helpers.XMLReaderFactory;
*/
public final class AuthMechConfig
{
private static final Logger m_log = Logger.getLogger(AuthMechConfig.class);
// Well known authentication token configuration settings
public final static String ClassName = "ClassName";
public final static String RelativeClassPath = "RelativeClassPath";
@ -56,7 +59,7 @@ public final class AuthMechConfig
*/
public AuthMechConfig()
{
System.err.println("AuthMechConfig()- Default");
m_log.debug("AuthMechConfig()- Default");
// Create a map to keep track of the token settings
m_mechSettingsMap = new HashMap<String, String>();
@ -70,7 +73,7 @@ public final class AuthMechConfig
*/
public AuthMechConfig(String mechSettingsFileName) throws Exception
{
System.err.println("AuthMechConfig()-");
m_log.debug("AuthMechConfig()-");
// Create a map to keep track of the token settings
m_mechSettingsMap = new HashMap<String, String>();
@ -87,28 +90,28 @@ public final class AuthMechConfig
SettingsFileSAXHandler handler = new SettingsFileSAXHandler(m_mechSettingsMap);
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
InputSource source = new InputSource(inStream);
xr.parse(source);
}
catch (SAXException e)
{
System.err.println("AuthMechConfig()- " + mechSettingsFileName + " format error, exception: " + e.toString());
m_log.warn("AuthMechConfig()- " + mechSettingsFileName + " format error, exception: " + e.toString());
throw new Exception("AuthMechConfig()- authtoken.settings format error", e);
}
catch (SecurityException e)
{
System.err.println("AuthMechConfig()- SecurityException accessing " + mechSettingsFileName + " Exception=" + e.toString());
m_log.warn("AuthMechConfig()- SecurityException accessing " + mechSettingsFileName + " Exception=" + e.toString());
throw new Exception("AuthMechConfig()- Not able to access file", e);
}
catch (FileNotFoundException e)
{
System.err.println("AuthMechConfig()- File " + mechSettingsFileName + " not found");
m_log.warn("AuthMechConfig()- File " + mechSettingsFileName + " not found");
throw new Exception("AuthMechConfig()- File not found", e);
}
catch (IOException e)
{
System.err.println("AuthMechConfig()- IOException accessing " + mechSettingsFileName + " Exception=" + e.toString());
m_log.warn("AuthMechConfig()- IOException accessing " + mechSettingsFileName + " Exception=" + e.toString());
throw new Exception("AuthMechConfig()- Read error", e);
}
finally
@ -140,14 +143,14 @@ public final class AuthMechConfig
if (value == null)
{
System.err.println("AuthMechConfig.getSetting()- Did not find setting " + settingName);
m_log.info("AuthMechConfig.getSetting()- Did not find setting " + settingName);
// The setting is not in our map, check if it is one to
// which we have defaults.
if (settingName.equals(Krb5ServicePrincipalName))
{
value = m_defaultKrb5ServicePrincipalNameValue;
System.err.println("AuthMechConfig.getSetting()- Assigning default value " + value);
m_log.info("AuthMechConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_mechSettingsMap.put(Krb5ServicePrincipalName, m_defaultKrb5ServicePrincipalNameValue);
@ -155,8 +158,8 @@ public final class AuthMechConfig
}
else
{
System.err.println("AuthMechConfig.getSetting()- Found setting " + settingName);
System.err.println("AuthMechConfig.getSetting()- Setting value = " + value);
m_log.info("AuthMechConfig.getSetting()- Found setting " + settingName);
m_log.info("AuthMechConfig.getSetting()- Setting value = " + value);
}
return value;

View File

@ -31,6 +31,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.apache.log4j.Logger;
/**
@ -50,6 +51,7 @@ import org.xml.sax.helpers.XMLReaderFactory;
*/
public final class AuthReqMsg
{
private static final Logger m_log = Logger.getLogger(AuthReqMsg.class);
protected String m_realm = null;
protected char[] m_authMechToken = null;
@ -100,7 +102,7 @@ public final class AuthReqMsg
// Verify that we obtained all of the required elements
if (m_state != DONE_PARSING)
{
System.err.println("AuthReqMsg SAXHandler.endDocument()- Missing element");
m_log.error("AuthReqMsg SAXHandler.endDocument()- Missing element");
throw new SAXException("Missing element");
}
}
@ -128,7 +130,7 @@ public final class AuthReqMsg
}
else
{
System.err.println("AuthReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("AuthReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -142,7 +144,7 @@ public final class AuthReqMsg
}
else
{
System.err.println("AuthReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("AuthReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -156,7 +158,7 @@ public final class AuthReqMsg
}
else
{
System.err.println("AuthReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("AuthReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -170,13 +172,13 @@ public final class AuthReqMsg
}
else
{
System.err.println("AuthReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("AuthReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
default:
System.err.println("AuthReqMsg SAXHandler.startElement()- State error");
m_log.error("AuthReqMsg SAXHandler.startElement()- State error");
throw new SAXException("State error");
}
}
@ -203,7 +205,7 @@ public final class AuthReqMsg
}
else
{
System.err.println("AuthReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("AuthReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -217,7 +219,7 @@ public final class AuthReqMsg
}
else
{
System.err.println("AuthReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("AuthReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -231,7 +233,7 @@ public final class AuthReqMsg
}
else
{
System.err.println("AuthReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("AuthReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -245,13 +247,13 @@ public final class AuthReqMsg
}
else
{
System.err.println("AuthReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("AuthReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
default:
System.err.println("AuthReqMsg SAXHandler.endElement()- State error");
m_log.error("AuthReqMsg SAXHandler.endElement()- State error");
throw new SAXException("State error");
}
}
@ -361,7 +363,7 @@ public final class AuthReqMsg
}
catch (SAXException e)
{
System.err.println("AuthReqMsg()- Parse exception: " + e.toString());
m_log.error("AuthReqMsg()- Parse exception: " + e.toString());
throw new Exception("Protocol error", e);
}
}

View File

@ -24,6 +24,8 @@
package com.novell.casa.authtoksvc;
import org.apache.log4j.Logger;
/**
* AuthRespMsg Class.
*
@ -51,6 +53,7 @@ package com.novell.casa.authtoksvc;
*/
public final class AuthRespMsg
{
private static final Logger m_log = Logger.getLogger(AuthRespMsg.class);
final String m_msg;

View File

@ -33,6 +33,7 @@ import org.apache.axis.configuration.NullProvider;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPBody;
import org.apache.axis.message.MessageElement;
import org.apache.log4j.Logger;
import javax.xml.namespace.QName;
import java.io.*;
@ -56,6 +57,8 @@ import java.io.*;
*/
public final class AuthToken
{
private static final Logger m_log = Logger.getLogger(AuthToken.class);
private String m_token;
private String m_lifetime = "";
private String m_lifetimeShorter = "";
@ -138,8 +141,8 @@ public final class AuthToken
}
catch (Exception e)
{
// tbd
System.err.println("AuthToken()- Exception: " + e.toString());
m_log.error("AuthToken()- Exception: " + e.toString());
throw e;
}
finally
{
@ -158,6 +161,7 @@ public final class AuthToken
}
else
{
m_log.error("AuthToken()- Error: Missing authentication token config for " + targetService);
throw new Exception("Error: Missing authentication token config for " + targetService);
}
}
@ -189,7 +193,7 @@ public final class AuthToken
}
catch (Exception e)
{
System.err.println("AuthToken()- Exception caught creating message, msg: " + e.getMessage());
m_log.warn("AuthToken()- Exception caught creating message, msg: " + e.getMessage());
throw new Exception("Invalid Authentication Token", e);
}
finally
@ -233,14 +237,14 @@ public final class AuthToken
if (m_identityToken == null || m_identityTokenType == null)
{
System.out.println("AuthToken()- Required data missing from authentication token");
m_log.warn("AuthToken()- Required data missing from authentication token");
throw new Exception("Error: Required data missing from Authentication Token");
}
}
else
{
// Message verification failed
System.err.println("AuthToken()- Invalid Authentication Token");
m_log.warn("AuthToken()- Invalid Authentication Token");
throw new Exception("Invalid Authentication Token");
}
}
@ -298,7 +302,7 @@ public final class AuthToken
}
catch (Exception e)
{
System.out.println("AuthToken.getMessage() - Exception caught building message, error: " + e.getMessage());
m_log.error("AuthToken.getMessage() - Exception caught building message, error: " + e.getMessage());
secureMessage = null;
}
if (inStream != null)
@ -340,7 +344,7 @@ public final class AuthToken
// Throw exeption if the lifetime parameter is not set
if (m_lifetime.length() == 0)
{
System.out.println("AuthToken.getLifetime() - Called when lifetime is not set");
m_log.error("AuthToken.getLifetime() - Called when lifetime is not set");
throw new Exception("Error: Called getLifetime while not set");
}
@ -379,7 +383,8 @@ public final class AuthToken
*/
public static String validate(String authTokenString)
{
System.err.println("AuthToken.validate()- Start");
m_log.debug("AuthToken.validate()- Start");
// Instantiate the AuthToken, this validates the token itself.
try
{
@ -387,15 +392,14 @@ public final class AuthToken
// If we are here is because the token validation succeeded,
// return the identity token string.
System.err.println("AuthToken.validate()- Returning identity token");
m_log.debug("AuthToken.validate()- Returning identity token");
return authToken.getIdentityToken();
}
catch (Exception e)
{
// The validation of one of the tokens failed
// tbd - Log
System.err.println("AuthToken.validate()- Exception caught during token processing, msg: " + e.getMessage());
m_log.warn("AuthToken.validate()- Exception caught during token validation, msg: " + e.getMessage());
return null;
}

View File

@ -31,6 +31,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.apache.log4j.Logger;
/**
* AuthTokenConfig Class.
@ -40,6 +41,8 @@ import org.xml.sax.helpers.XMLReaderFactory;
*/
public final class AuthTokenConfig
{
private static final Logger m_log = Logger.getLogger(AuthTokenConfig.class);
// Well known authentication token configuration settings
public final static String TokenLifetime = "TokenLifetime";
public final static String LifetimeShorter = "LifetimeShorter";
@ -62,7 +65,7 @@ public final class AuthTokenConfig
*/
public AuthTokenConfig()
{
System.err.println("AuthTokenConfig()- Default");
m_log.debug("AuthTokenConfig()- Default");
// Create a map to keep track of the token settings
m_tokenSettingsMap = new HashMap<String, String>();
@ -81,7 +84,7 @@ public final class AuthTokenConfig
*/
public AuthTokenConfig(String authTokenSettingsFileName) throws Exception
{
System.err.println("AuthTokenConfig()-");
m_log.debug("AuthTokenConfig()-");
// Create a map to keep track of the token settings
m_tokenSettingsMap = new HashMap<String, String>();
@ -98,7 +101,7 @@ public final class AuthTokenConfig
SettingsFileSAXHandler handler = new SettingsFileSAXHandler(m_tokenSettingsMap);
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
InputSource source = new InputSource(inStream);
xr.parse(source);
@ -109,8 +112,8 @@ public final class AuthTokenConfig
tokenLifetime = Integer.valueOf(getSetting(TokenLifetime)).intValue();
if (tokenLifetime < m_minimumTokenLifetimeValue)
{
System.err.println("AuthTokenConfig()- Configured token lifetime too small, defaulting to "
+ Integer.toString(m_minimumTokenLifetimeValue) + " seconds");
m_log.info("AuthTokenConfig()- Configured token lifetime too small, defaulting to "
+ Integer.toString(m_minimumTokenLifetimeValue) + " seconds");
tokenLifetime = m_minimumTokenLifetimeValue;
// Update the map with the new value for the setting
@ -119,8 +122,8 @@ public final class AuthTokenConfig
}
catch (NumberFormatException e)
{
System.err.println("AuthTokenConfig()- Invalid configured token lifetime value, defaulting to "
+ Integer.toString(m_minimumTokenLifetimeValue) + " seconds");
m_log.info("AuthTokenConfig()- Invalid configured token lifetime value, defaulting to "
+ Integer.toString(m_minimumTokenLifetimeValue) + " seconds");
tokenLifetime = m_minimumTokenLifetimeValue;
// Update the map with the new value for the setting
@ -133,8 +136,8 @@ public final class AuthTokenConfig
lifetimeShorter = Integer.valueOf(getSetting(LifetimeShorter)).intValue();
if (lifetimeShorter < m_minimumLifetimeShorterValue)
{
System.err.println("AuthTokenConfig()- Configured lifetime shorter too small, defaulting to "
+ Integer.toString(m_minimumLifetimeShorterValue) + " seconds");
m_log.info("AuthTokenConfig()- Configured lifetime shorter too small, defaulting to "
+ Integer.toString(m_minimumLifetimeShorterValue) + " seconds");
lifetimeShorter = m_minimumLifetimeShorterValue;
// Update the map with the new value for the setting
@ -143,8 +146,8 @@ public final class AuthTokenConfig
}
catch (NumberFormatException e)
{
System.err.println("AuthTokenConfig()- Invalid configured lifetime shorter value, defaulting to "
+ Integer.toString(m_minimumLifetimeShorterValue) + " seconds");
m_log.info("AuthTokenConfig()- Invalid configured lifetime shorter value, defaulting to "
+ Integer.toString(m_minimumLifetimeShorterValue) + " seconds");
lifetimeShorter = m_minimumLifetimeShorterValue;
// Update the map with the new value for the setting
@ -154,8 +157,8 @@ public final class AuthTokenConfig
if (lifetimeShorter > tokenLifetime
|| (tokenLifetime - lifetimeShorter) < m_minimumLifetimeShorterDifferential)
{
System.err.println("AuthTokenConfig()- Invalid lifetime shorter value, defaulting to "
+ Integer.toString(m_minimumLifetimeShorterValue) + " seconds");
m_log.info("AuthTokenConfig()- Invalid lifetime shorter value, defaulting to "
+ Integer.toString(m_minimumLifetimeShorterValue) + " seconds");
// Update the map with the new value for the setting
m_tokenSettingsMap.put(LifetimeShorter, Integer.toString(m_minimumLifetimeShorterValue));
@ -163,22 +166,22 @@ public final class AuthTokenConfig
}
catch (SAXException e)
{
System.err.println("AuthTokenConfig()- " + authTokenSettingsFileName + " format error, exception: " + e.toString());
m_log.warn("AuthTokenConfig()- " + authTokenSettingsFileName + " format error, exception: " + e.toString());
throw new Exception("AuthTokenConfig()- authtoken.settings format error", e);
}
catch (SecurityException e)
{
System.err.println("AuthTokenConfig()- SecurityException accessing " + authTokenSettingsFileName + " Exception=" + e.toString());
m_log.warn("AuthTokenConfig()- SecurityException accessing " + authTokenSettingsFileName + " Exception=" + e.toString());
throw new Exception("AuthTokenConfig()- Not able to access file", e);
}
catch (FileNotFoundException e)
{
System.err.println("AuthTokenConfig()- File " + authTokenSettingsFileName + " not found");
m_log.warn("AuthTokenConfig()- File " + authTokenSettingsFileName + " not found");
throw new Exception("AuthTokenConfig()- File not found", e);
}
catch (IOException e)
{
System.err.println("AuthTokenConfig()- IOException accessing " + authTokenSettingsFileName + " Exception=" + e.toString());
m_log.warn("AuthTokenConfig()- IOException accessing " + authTokenSettingsFileName + " Exception=" + e.toString());
throw new Exception("AuthTokenConfig()- Read error", e);
}
finally
@ -209,14 +212,14 @@ public final class AuthTokenConfig
String value = m_tokenSettingsMap.get(settingName);
if (value == null)
{
System.err.println("AuthTokenConfig.getSetting()- Did not find setting " + settingName);
m_log.info("AuthTokenConfig.getSetting()- Did not find setting " + settingName);
// The setting is not in our map, check if it is one to
// which we have defaults.
if (settingName.equalsIgnoreCase(TokenLifetime))
{
value = m_defaultTokenLifetimeValue;
System.err.println("AuthTokenConfig.getSetting()- Assigning default value " + value);
m_log.info("AuthTokenConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_tokenSettingsMap.put(TokenLifetime, m_defaultTokenLifetimeValue);
@ -224,7 +227,7 @@ public final class AuthTokenConfig
else if (settingName.equalsIgnoreCase(LifetimeShorter))
{
value = m_defaultLifetimeShorterValue;
System.err.println("AuthTokenConfig.getSetting()- Assigning default value " + value);
m_log.info("AuthTokenConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_tokenSettingsMap.put(LifetimeShorter, m_defaultLifetimeShorterValue);
@ -232,7 +235,7 @@ public final class AuthTokenConfig
else if (settingName.equalsIgnoreCase(IdentityTokenType))
{
value = m_defaultLifetimeShorterValue;
System.err.println("AuthTokenConfig.getSetting()- Assigning default value " + value);
m_log.info("AuthTokenConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_tokenSettingsMap.put(IdentityTokenType, m_defaultIdentityTokenTypeValue);
@ -240,8 +243,8 @@ public final class AuthTokenConfig
}
else
{
System.err.println("AuthTokenConfig.getSetting()- Found setting " + settingName);
System.err.println("AuthTokenConfig.getSetting()- Setting value = " + value);
m_log.info("AuthTokenConfig.getSetting()- Found setting " + settingName);
m_log.info("AuthTokenConfig.getSetting()- Setting value = " + value);
}
return value;

View File

@ -24,6 +24,8 @@
package com.novell.casa.authtoksvc;
import org.apache.log4j.Logger;
import java.util.*;
import java.io.*;
@ -45,6 +47,8 @@ import java.net.URLClassLoader;
*/
public final class Authenticate implements RpcMethod
{
private static final Logger m_log = Logger.getLogger(Authenticate.class);
private static final String m_mechanismSettingsFileName = "mechanism.settings";
private final Map<String,AuthMechanism> m_authMechanismMap;
@ -97,7 +101,7 @@ public final class Authenticate implements RpcMethod
{
if (mechanismFolder.isDirectory())
{
System.err.println("Authenticate.init()- Mechanism folder " + mechanismFolder + " is directory");
m_log.debug("Authenticate.init()- Mechanism folder " + mechanismFolder + " is directory");
// Try to obtain the mechanism settings
try
@ -119,7 +123,7 @@ public final class Authenticate implements RpcMethod
// ultimately instantiate objects from a class loaded by the same class loader that
// loads the AuthMechanism class to avoid ClassCastExceptions.
File mechClassPathFile = new File(svcConfig.getSetting(SvcConfig.AppRootPath) + relativePath);
System.err.println("Authenticate.init()- Mechanism path = " + mechClassPathFile);
m_log.debug("Authenticate.init()- Mechanism path = " + mechClassPathFile);
try
{
URL methClassPathUrl = mechClassPathFile.toURL();
@ -144,19 +148,19 @@ public final class Authenticate implements RpcMethod
}
catch (MalformedURLException e)
{
System.err.println("Authenticate.init()- MalformedURLException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- MalformedURLException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
catch (ClassNotFoundException e)
{
System.err.println("Authenticate.init()- ClassNotFoundException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- ClassNotFoundException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
catch (InstantiationException e)
{
System.err.println("Authenticate.init()- InstantiationException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- InstantiationException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
catch (IllegalAccessException e)
{
System.err.println("Authenticate.init()- IllegalAccessException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- IllegalAccessException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
}
else
@ -169,7 +173,7 @@ public final class Authenticate implements RpcMethod
// ultimately instantiate objects from a class loaded by the same class loader that
// loads the AuthMechanism class to avoid ClassCastExceptions.
File mechClassPathFile = new File(classPath);
System.err.println("Authenticate.init()- Mechanism path = " + mechClassPathFile);
m_log.debug("Authenticate.init()- Mechanism path = " + mechClassPathFile);
try
{
URL methClassPathUrl = mechClassPathFile.toURL();
@ -194,53 +198,53 @@ public final class Authenticate implements RpcMethod
}
catch (MalformedURLException e)
{
System.err.println("Authenticate.init()- MalformedURLException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- MalformedURLException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
catch (ClassNotFoundException e)
{
System.err.println("Authenticate.init()- ClassNotFoundException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- ClassNotFoundException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
catch (InstantiationException e)
{
System.err.println("Authenticate.init()- InstantiationException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- InstantiationException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
catch (IllegalAccessException e)
{
System.err.println("Authenticate.init()- IllegalAccessException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- IllegalAccessException for " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
}
else
{
System.err.println("Authenticate.init()- No configuration to find class path to load " + mechanismFolder + File.separator + m_mechanismSettingsFileName);
m_log.warn("Authenticate.init()- No configuration to find class path to load " + mechanismFolder + File.separator + m_mechanismSettingsFileName);
}
}
}
else
{
System.err.println("Authenticate.init()- No configured mechanism class name for " + mechanismFolder + File.separator + m_mechanismSettingsFileName);
m_log.warn("Authenticate.init()- No configured mechanism class name for " + mechanismFolder + File.separator + m_mechanismSettingsFileName);
}
}
catch (SecurityException e)
{
System.err.println("Authenticate.init()- SecurityException accessing " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- SecurityException accessing " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
catch (FileNotFoundException e)
{
System.err.println("Authenticate.init()- No authentication policy file for " + mechanismFolder);
m_log.warn("Authenticate.init()- No authentication policy file for " + mechanismFolder);
}
catch (IOException e)
{
System.err.println("Authenticate.init()- IOException reading " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- IOException reading " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
catch (Exception e)
{
System.err.println("Authenticate.init()- Exception instantiating mechConfig or mechanism " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- Exception instantiating mechConfig or mechanism " + mechanismFolder + File.separator + m_mechanismSettingsFileName + " Exception=" + e.toString());
}
}
}
catch (SecurityException e)
{
System.err.println("Authenticate.init()- SecurityException accessing " + mechanismFolder + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- SecurityException accessing " + mechanismFolder + " Exception=" + e.toString());
}
finally
{
@ -295,12 +299,12 @@ public final class Authenticate implements RpcMethod
}
else
{
System.err.println("Authenticate.init()- Unable to obtain mechanisms folder " + mechanismsConfigFolder + " objects");
m_log.warn("Authenticate.init()- Unable to obtain mechanisms folder " + mechanismsConfigFolder + " objects");
}
}
catch (SecurityException e)
{
System.err.println("Authenticate.init()- SecurityException accessing " + mechanismsConfigFolder + " Exception=" + e.toString());
m_log.warn("Authenticate.init()- SecurityException accessing " + mechanismsConfigFolder + " Exception=" + e.toString());
}
}
@ -316,7 +320,7 @@ public final class Authenticate implements RpcMethod
try
{
System.err.println("Authenticate.invoke()");
m_log.debug("Authenticate.invoke()");
// Parse the AuthReqMsg sent from the client
authReqMsg = new AuthReqMsg(inStream);
@ -331,7 +335,7 @@ public final class Authenticate implements RpcMethod
// Create response based on the identity resolution results
if (identId != null && identId.length() != 0)
{
System.err.println("Authenticate.invoke()- identId resolved, " + identId);
m_log.info("Authenticate.invoke()- identId resolved, " + identId);
// An identity was resolved, get a SessionToken for it.
SessionToken sessionToken = new SessionToken(identId,
@ -350,7 +354,7 @@ public final class Authenticate implements RpcMethod
}
else
{
System.err.println("Authenticate.invoke()- identId not resolved");
m_log.info("Authenticate.invoke()- identId not resolved");
// Write out the response
AuthRespMsg authRespMsg = new AuthRespMsg(ProtoDefs.httpUnauthorizedStatusMsg,
@ -360,7 +364,7 @@ public final class Authenticate implements RpcMethod
}
else
{
System.err.println("Authenticate.invoke()- Unsupported mechanism " + authReqMsg.getMechanismId());
m_log.warn("Authenticate.invoke()- Unsupported mechanism " + authReqMsg.getMechanismId());
// Write out the response
AuthRespMsg authRespMsg = new AuthRespMsg(ProtoDefs.httpNotFoundStatusMsg,
@ -370,7 +374,7 @@ public final class Authenticate implements RpcMethod
}
catch (Exception e)
{
System.err.println("Authenticate.invoke()- Exception: " + e.toString());
m_log.error("Authenticate.invoke()- Exception: " + e.toString());
// Write out the response
try
@ -381,7 +385,7 @@ public final class Authenticate implements RpcMethod
}
catch (Exception e2)
{
System.err.println("Authenticate.invoke()- Exception trying to construct response msg: " + e2.toString());
m_log.error("Authenticate.invoke()- Exception trying to construct response msg: " + e2.toString());
}
}
finally

View File

@ -43,6 +43,7 @@ import org.xml.sax.helpers.XMLReaderFactory;
import org.bandit.ia.IAContext;
import org.bandit.util.config.Realm;
import org.apache.log4j.Logger;
/**
* CasaIdentityToken Class.
@ -73,10 +74,12 @@ import org.bandit.util.config.Realm;
*/
public final class CasaIdentityToken implements IdentityToken
{
private static final Logger m_log = Logger.getLogger(CasaIdentityToken.class);
/*
* XML Element Name Constants for the documents exchanged between the
* Casa Client and the Casa Server.
*/
* XML Element Name Constants for the documents exchanged between the
* Casa Client and the Casa Server.
*/
private final static String casaIdentTokElementName = "casa_ident_tok";
private final static String idElementName = "id";
private final static String sourceNameElementName = "source_name";
@ -154,7 +157,7 @@ public final class CasaIdentityToken implements IdentityToken
// Verify that we obtained all of the required elements
if (m_state != DONE_PARSING)
{
System.err.println("CasaIdentityToken SAXHandler.endDocument()- Missing element");
m_log.error("CasaIdentityToken SAXHandler.endDocument()- Missing element");
throw new SAXException("Missing element");
}
}
@ -173,7 +176,7 @@ public final class CasaIdentityToken implements IdentityToken
// Proceed based on our state
switch (m_state)
{
case AWAITING_ROOT_ELEMENT_START:
// Verify that we are processing the expected tag
if (casaIdentTokElementName.equalsIgnoreCase(qName))
@ -183,7 +186,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -197,7 +200,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -211,7 +214,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
@ -226,7 +229,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -240,7 +243,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -254,7 +257,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -268,7 +271,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -293,7 +296,7 @@ public final class CasaIdentityToken implements IdentityToken
break;
default:
System.err.println("CasaIdentityToken SAXHandler.startElement()- State error");
m_log.error("CasaIdentityToken SAXHandler.startElement()- State error");
throw new SAXException("State error");
}
}
@ -311,7 +314,7 @@ public final class CasaIdentityToken implements IdentityToken
// Proceed based on our state
switch (m_state)
{
case AWAITING_ROOT_ELEMENT_END:
// Verify that we are processing the expected tag
if (casaIdentTokElementName.equalsIgnoreCase(qName))
@ -321,7 +324,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -335,7 +338,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -349,7 +352,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -363,7 +366,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -377,7 +380,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -391,7 +394,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -415,19 +418,19 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Attribute data not found");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Attribute data not found");
throw new SAXException("Attribute data not found");
}
}
catch (NamingException e)
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Attribute data not found");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Attribute data not found");
throw new SAXException("Attribute data not found", e);
}
}
else
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Attribute not found");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Attribute not found");
throw new SAXException("Attribute not found");
}
@ -444,13 +447,13 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
m_log.error("CasaIdentityToken SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
default:
System.err.println("CasaIdentityToken SAXHandler.endElement()- State error");
m_log.error("CasaIdentityToken SAXHandler.endElement()- State error");
throw new SAXException("State error");
}
}
@ -468,7 +471,7 @@ public final class CasaIdentityToken implements IdentityToken
// Proceed based on our state
switch (m_state)
{
case AWAITING_ID_DATA:
// Consume the data
m_casaIdentToken.m_identityId = new String(ch, start, length);
@ -560,19 +563,19 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.characters()- Attribute data not found");
m_log.error("CasaIdentityToken SAXHandler.characters()- Attribute data not found");
throw new SAXException("Attribute data not found");
}
}
catch (NamingException e)
{
System.err.println("CasaIdentityToken SAXHandler.characters()- Attribute data not found");
m_log.error("CasaIdentityToken SAXHandler.characters()- Attribute data not found");
throw new SAXException("Attribute data not found", e);
}
}
else
{
System.err.println("CasaIdentityToken SAXHandler.characters()- Attribute not found");
m_log.error("CasaIdentityToken SAXHandler.characters()- Attribute not found");
throw new SAXException("Attribute not found");
}
}
@ -627,19 +630,19 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken SAXHandler.characters()- Attribute data not found");
m_log.error("CasaIdentityToken SAXHandler.characters()- Attribute data not found");
throw new SAXException("Attribute data not found");
}
}
catch (NamingException e)
{
System.err.println("CasaIdentityToken SAXHandler.characters()- Attribute data not found");
m_log.error("CasaIdentityToken SAXHandler.characters()- Attribute data not found");
throw new SAXException("Attribute data not found", e);
}
}
else
{
System.err.println("CasaIdentityToken SAXHandler.characters()- Attribute not found");
m_log.error("CasaIdentityToken SAXHandler.characters()- Attribute not found");
throw new SAXException("Attribute not found");
}
}
@ -741,7 +744,7 @@ public final class CasaIdentityToken implements IdentityToken
{
Object attrValue = enumeration.next();
m_attributes.put(attr.getID(), attrValue);
System.err.println("CasaIdentityToken.initialize()- Including attribute " + attr.getID());
m_log.debug("CasaIdentityToken.initialize()- Including attribute " + attr.getID());
// Encrypt the attribute if necessary
if (encryptAttributes)
@ -757,7 +760,7 @@ public final class CasaIdentityToken implements IdentityToken
{
// The attribute value is of type byte[], we need to encode it.
sb.append("<"); sb.append(attr.getID()); sb.append(" type=\"binary\" encoding=\"base64\">"); sb.append(new String(Base64Coder.encode((byte[]) attrValue))); sb.append("</"); sb.append(attr.getID()); sb.append(">\r\n");
System.err.println("Attribute " + attr.getID() + "included as " + new String(Base64Coder.encode((byte[]) attrValue)));
m_log.debug("Attribute " + attr.getID() + "included as " + new String(Base64Coder.encode((byte[]) attrValue)));
}
else
{
@ -774,12 +777,12 @@ public final class CasaIdentityToken implements IdentityToken
}
catch (NamingException e)
{
System.err.println("CasaIdentityToken.initialize()- Exception: " + e.getExplanation());
m_log.error("CasaIdentityToken.initialize()- Exception: " + e.getExplanation());
throw new Exception("Error obtaining identity data for token", e);
}
catch (Exception e)
{
System.err.println("CasaIdentityToken.initialize()- Exception: " + e.toString());
m_log.error("CasaIdentityToken.initialize()- Exception: " + e.toString());
throw new Exception("Error obtaining identity data for token", e);
}
}
@ -811,8 +814,7 @@ public final class CasaIdentityToken implements IdentityToken
}
catch (SAXException e)
{
// tbd - Log this.
System.err.println("CasaIdentityToken()- Parse exception: " + e.toString());
m_log.error("CasaIdentityToken()- Parse exception: " + e.toString());
throw new Exception("Token error", e);
}
finally
@ -848,7 +850,7 @@ public final class CasaIdentityToken implements IdentityToken
}
else
{
System.err.println("CasaIdentityToken.toString()- Not initialized");
m_log.error("CasaIdentityToken.toString()- Not initialized");
throw new Exception("Not initialized");
}
}
@ -876,7 +878,7 @@ public final class CasaIdentityToken implements IdentityToken
return m_identityId;
else
{
System.err.println("CasaIdentityToken.getIdentityId()- Not initialized");
m_log.error("CasaIdentityToken.getIdentityId()- Not initialized");
throw new Exception("Not initialized");
}
}
@ -894,7 +896,7 @@ public final class CasaIdentityToken implements IdentityToken
return m_sourceName;
else
{
System.err.println("CasaIdentityToken.getSourceName()- Not initialized");
m_log.error("CasaIdentityToken.getSourceName()- Not initialized");
throw new Exception("Not initialized");
}
}
@ -912,7 +914,7 @@ public final class CasaIdentityToken implements IdentityToken
return m_sourceUrl;
else
{
System.err.println("CasaIdentityToken.getSourceUrl()- Not initialized");
m_log.error("CasaIdentityToken.getSourceUrl()- Not initialized");
throw new Exception("Not initialized");
}
}
@ -929,7 +931,7 @@ public final class CasaIdentityToken implements IdentityToken
return m_service;
else
{
System.err.println("CasaIdentityToken.getTargetService()- Not initialized");
m_log.error("CasaIdentityToken.getTargetService()- Not initialized");
throw new Exception("Not initialized");
}
}
@ -947,7 +949,7 @@ public final class CasaIdentityToken implements IdentityToken
return m_host;
else
{
System.err.println("CasaIdentityToken.getTargetHost()- Not initialized");
m_log.error("CasaIdentityToken.getTargetHost()- Not initialized");
throw new Exception("Not initialized");
}
}
@ -964,7 +966,7 @@ public final class CasaIdentityToken implements IdentityToken
return m_attributes;
else
{
System.err.println("CasaIdentityToken.getIdentityAttributes()- Not initialized");
m_log.error("CasaIdentityToken.getIdentityAttributes()- Not initialized");
throw new Exception("Not initialized");
}
}

View File

@ -24,6 +24,8 @@
package com.novell.casa.authtoksvc;
import org.apache.log4j.Logger;
import java.io.*;
import java.util.*;
@ -36,6 +38,8 @@ import java.util.*;
*/
public final class EnabledSvcsConfig
{
private static final Logger m_log = Logger.getLogger(EnabledSvcsConfig.class);
private static final String m_authPolicyFileName = "auth.policy";
private static final String m_authTokenSettingsFileName = "authtoken.settings";
private static final String m_idenTokenSettingsFileName = "identoken.settings";
@ -91,8 +95,8 @@ public final class EnabledSvcsConfig
public EnabledSvcsConfig(String svcConfigPath,
boolean enabledSvcsOnly) throws Exception
{
System.err.println("EnabledSvcsConfig()-");
System.err.println("EnabledSvcsConfig()- SvcConfigPath = " + svcConfigPath);
m_log.debug("EnabledSvcsConfig()-");
m_log.info("EnabledSvcsConfig()- SvcConfigPath = " + svcConfigPath);
// Remember the enabledSvcsOnly setting
m_enabledSvcsOnly = enabledSvcsOnly;
@ -115,20 +119,20 @@ public final class EnabledSvcsConfig
int bytesRead = inStream.read(m_defaultAuthPolicyData);
if (bytesRead != m_defaultAuthPolicyData.length)
{
System.err.println("EnabledSvcsConfig()- Error reading default policy file");
m_log.warn("EnabledSvcsConfig()- Error reading default policy file");
}
}
catch (SecurityException e)
{
System.err.println("EnabledSvcsConfig()- SecurityException accessing " + configFolder + File.separator + m_authPolicyFileName + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- SecurityException accessing " + configFolder + File.separator + m_authPolicyFileName + " Exception=" + e.toString());
}
catch (FileNotFoundException e)
{
System.err.println("EnabledSvcsConfig()- File " + configFolder + File.separator + m_authPolicyFileName + " not found");
m_log.warn("EnabledSvcsConfig()- File " + configFolder + File.separator + m_authPolicyFileName + " not found");
}
catch (IOException e)
{
System.err.println("EnabledSvcsConfig()- IOException reading " + configFolder + File.separator + m_authPolicyFileName + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- IOException reading " + configFolder + File.separator + m_authPolicyFileName + " Exception=" + e.toString());
}
finally
{
@ -187,7 +191,7 @@ public final class EnabledSvcsConfig
{
if (hostFolder.isDirectory())
{
System.err.println("EnabledSvcsConfig()- Host folder " + hostFolder + " is directory");
m_log.debug("EnabledSvcsConfig()- Host folder " + hostFolder + " is directory");
// Now go through the services configured for this host
String[] hostFolderObjs = hostFolder.list();
@ -200,12 +204,12 @@ public final class EnabledSvcsConfig
{
// Check if we are dealing with a file or a folder
File serviceFolder = new File(hostFolder, hostFolderObjs[ii]);
System.err.println("EnabledSvcsConfig()- Service folder " + serviceFolder);
m_log.info("EnabledSvcsConfig()- Service folder " + serviceFolder);
try
{
if (serviceFolder.isDirectory())
{
System.err.println("EnabledSvcsConfig()- Service folder " + serviceFolder + " is directory");
m_log.debug("EnabledSvcsConfig()- Service folder " + serviceFolder + " is directory");
// We are dealing with a folder, remember that the folder name matches the name
// of the enabled service. Check and see if there are authentication policy and
@ -223,20 +227,20 @@ public final class EnabledSvcsConfig
int bytesRead = inStream.read(authPolicyData);
if (bytesRead != authPolicyData.length)
{
System.err.println("EnabledSvcsConfig()- Error reading policy file for " + servicesConfigFolderObjs[i] + " " + hostFolderObjs[ii]);
m_log.warn("EnabledSvcsConfig()- Error reading policy file for " + servicesConfigFolderObjs[i] + " " + hostFolderObjs[ii]);
}
}
catch (SecurityException e)
{
System.err.println("EnabledSvcsConfig()- SecurityException accessing " + serviceFolder + File.separator + m_authPolicyFileName + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- SecurityException accessing " + serviceFolder + File.separator + m_authPolicyFileName + " Exception=" + e.toString());
}
catch (FileNotFoundException e)
{
System.err.println("EnabledSvcsConfig()- No authentication policy file for " + serviceFolder);
m_log.warn("EnabledSvcsConfig()- No authentication policy file for " + serviceFolder);
}
catch (IOException e)
{
System.err.println("EnabledSvcsConfig()- IOException reading " + serviceFolder + File.separator + m_authPolicyFileName + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- IOException reading " + serviceFolder + File.separator + m_authPolicyFileName + " Exception=" + e.toString());
}
finally
{
@ -259,7 +263,7 @@ public final class EnabledSvcsConfig
}
catch (Exception e)
{
System.err.println("EnabledSvcsConfig()- Exception accessing " + serviceFolder + File.separator + m_authTokenSettingsFileName + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- Exception accessing " + serviceFolder + File.separator + m_authTokenSettingsFileName + " Exception=" + e.toString());
}
try
@ -268,7 +272,7 @@ public final class EnabledSvcsConfig
}
catch (Exception e)
{
System.err.println("EnabledSvcsConfig()- Exception accessing " + serviceFolder + File.separator + m_idenTokenSettingsFileName + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- Exception accessing " + serviceFolder + File.separator + m_idenTokenSettingsFileName + " Exception=" + e.toString());
}
// Make sure that we have a policy file
@ -281,18 +285,18 @@ public final class EnabledSvcsConfig
(idenTokenConfig != null) ? idenTokenConfig : m_defaultIdenTokenConfig);
// Add this entry to our map
System.err.println("EnabledSvcsConfig()- Adding entry in map for " + servicesConfigFolderObjs[i] + " " + hostFolderObjs[ii]);
m_log.info("EnabledSvcsConfig()- Adding entry in map for " + servicesConfigFolderObjs[i] + " " + hostFolderObjs[ii]);
enabledSvcsConfigMap.put(hostFolderObjs[ii], svcConfigEntry);
}
else
{
System.err.println("EnabledSvcsConfig()- Unable to enable " + servicesConfigFolderObjs[i] + " " + hostFolderObjs[ii] + " due to no configured authentication policy");
m_log.warn("EnabledSvcsConfig()- Unable to enable " + servicesConfigFolderObjs[i] + " " + hostFolderObjs[ii] + " due to no configured authentication policy");
}
}
}
catch (SecurityException e)
{
System.err.println("EnabledSvcsConfig()- SecurityException accessing " + serviceFolder + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- SecurityException accessing " + serviceFolder + " Exception=" + e.toString());
}
// Add this hosts enabled services configuration map to the hosts map
@ -301,29 +305,29 @@ public final class EnabledSvcsConfig
}
else
{
System.err.println("EnabledSvcsConfig()- No services configured for " + hostFolder);
m_log.info("EnabledSvcsConfig()- No services configured for " + hostFolder);
}
}
}
catch (SecurityException e)
{
System.err.println("EnabledSvcsConfig()- SecurityException accessing " + hostFolder + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- SecurityException accessing " + hostFolder + " Exception=" + e.toString());
}
}
}
else
{
System.err.println("EnabledSvcsConfig()- Unable to obtain services folder " + servicesConfigFolder + " objects");
m_log.warn("EnabledSvcsConfig()- Unable to obtain services folder " + servicesConfigFolder + " objects");
}
}
catch (SecurityException e)
{
System.err.println("EnabledSvcsConfig()- SecurityException accessing " + servicesConfigFolder + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- SecurityException accessing " + servicesConfigFolder + " Exception=" + e.toString());
}
}
catch (SecurityException e)
{
System.err.println("EnabledSvcsConfig()- SecurityException accessing " + configFolder + " Exception=" + e.toString());
m_log.warn("EnabledSvcsConfig()- SecurityException accessing " + configFolder + " Exception=" + e.toString());
}
}

View File

@ -24,6 +24,8 @@
package com.novell.casa.authtoksvc;
import org.apache.log4j.Logger;
import java.io.*;
import java.io.PrintWriter;
@ -36,6 +38,8 @@ import java.io.PrintWriter;
*/
public final class GetAuthPolicy implements RpcMethod
{
private static final Logger m_log = Logger.getLogger(GetAuthPolicy.class);
private SvcConfig m_svcConfig;
private EnabledSvcsConfig m_enabledSvcsConfig;
@ -71,7 +75,7 @@ public final class GetAuthPolicy implements RpcMethod
{
try
{
System.err.println("GetAuthPolicy.invoke()");
m_log.debug("GetAuthPolicy.invoke()");
// Read and parse the GetAuthPolicyReqMsg sent from the client
GetAuthPolicyReqMsg getAuthPolicyReqMsg = new GetAuthPolicyReqMsg(inStream);
@ -92,7 +96,7 @@ public final class GetAuthPolicy implements RpcMethod
}
else
{
System.err.println("GetAuthPolicy.invoke()- authPolicy is null for enabled service: " + getAuthPolicyReqMsg.getServiceName());
m_log.debug("GetAuthPolicy.invoke()- authPolicy is null for enabled service: " + getAuthPolicyReqMsg.getServiceName());
GetAuthPolicyRespMsg getAuthPolicyRespMsg = new GetAuthPolicyRespMsg(ProtoDefs.httpServerErrorStatusMsg,
ProtoDefs.httpServerErrorStatusCode);
out.println(getAuthPolicyRespMsg.toString());
@ -105,15 +109,15 @@ public final class GetAuthPolicy implements RpcMethod
ProtoDefs.httpNotFoundStatusCode);
out.println(getAuthPolicyRespMsg.toString());
System.err.println("GetAuthPolicy.invoke()- Service "
+ getAuthPolicyReqMsg.getServiceName()
+ " at " + getAuthPolicyReqMsg.getHostName()
+ " not enabled");
m_log.warn("GetAuthPolicy.invoke()- Service "
+ getAuthPolicyReqMsg.getServiceName()
+ " at " + getAuthPolicyReqMsg.getHostName()
+ " not enabled");
}
}
catch (Exception e)
{
System.err.println("GetAuthPolicy.invoke()- Exception: " + e.toString());
m_log.error("GetAuthPolicy.invoke()- Exception: " + e.toString());
// Write out the response
try
@ -124,7 +128,7 @@ public final class GetAuthPolicy implements RpcMethod
}
catch (Exception e2)
{
System.err.println("GetAuthPolicy.invoke()- Exception trying to construct response msg: " + e2.toString());
m_log.error("GetAuthPolicy.invoke()- Exception trying to construct response msg: " + e2.toString());
}
}
}

View File

@ -30,6 +30,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.apache.log4j.Logger;
/**
* GetAuthPolicyReqMsg Class.
@ -47,6 +48,7 @@ import org.xml.sax.helpers.XMLReaderFactory;
*/
public final class GetAuthPolicyReqMsg
{
private static final Logger m_log = Logger.getLogger(GetAuthPolicyReqMsg.class);
protected String m_serviceName = null;
protected String m_hostName = null;
@ -93,7 +95,7 @@ public final class GetAuthPolicyReqMsg
// Verify that we obtained all of the required elements
if (m_state != DONE_PARSING)
{
System.err.println("GetAuthPolicyReqMsg SAXHandler.endDocument()- Missing element");
m_log.error("GetAuthPolicyReqMsg SAXHandler.endDocument()- Missing element");
throw new SAXException("Missing element");
}
}
@ -121,7 +123,7 @@ public final class GetAuthPolicyReqMsg
}
else
{
System.err.println("GetAuthPolicyReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("GetAuthPolicyReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -135,7 +137,7 @@ public final class GetAuthPolicyReqMsg
}
else
{
System.err.println("GetAuthPolicyReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("GetAuthPolicyReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -149,14 +151,14 @@ public final class GetAuthPolicyReqMsg
}
else
{
System.err.println("GetAuthPolicyReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("GetAuthPolicyReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
default:
System.err.println("GetAuthPolicyReqMsg SAXHandler.startElement()- State error");
m_log.error("GetAuthPolicyReqMsg SAXHandler.startElement()- State error");
throw new SAXException("State error");
}
}
@ -183,7 +185,7 @@ public final class GetAuthPolicyReqMsg
}
else
{
System.err.println("GetAuthPolicyReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("GetAuthPolicyReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -197,7 +199,7 @@ public final class GetAuthPolicyReqMsg
}
else
{
System.err.println("GetAuthPolicyReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("GetAuthPolicyReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -211,13 +213,13 @@ public final class GetAuthPolicyReqMsg
}
else
{
System.err.println("GetAuthPolicyReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("GetAuthPolicyReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
default:
System.err.println("GetAuthPolicyReqMsg SAXHandler.endElement()- State error");
m_log.error("GetAuthPolicyReqMsg SAXHandler.endElement()- State error");
throw new SAXException("State error");
}
}
@ -289,7 +291,7 @@ public final class GetAuthPolicyReqMsg
}
catch (SAXException e)
{
System.err.println("GetAuthPolicyReqMsg()- Parse exception: " + e.toString());
m_log.error("GetAuthPolicyReqMsg()- Parse exception: " + e.toString());
throw new Exception("Protocol error", e);
}
}

View File

@ -24,6 +24,8 @@
package com.novell.casa.authtoksvc;
import org.apache.log4j.Logger;
/**
* GetAuthPolicyRespMsg Class.
* <p>
@ -52,6 +54,7 @@ package com.novell.casa.authtoksvc;
*/
public final class GetAuthPolicyRespMsg
{
private static final Logger m_log = Logger.getLogger(GetAuthPolicyRespMsg.class);
final String m_msg;

View File

@ -30,6 +30,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.apache.log4j.Logger;
/**
* GetAuthTokReqMsg Class.
@ -48,6 +49,7 @@ import org.xml.sax.helpers.XMLReaderFactory;
*/
public final class GetAuthTokReqMsg
{
private static final Logger m_log = Logger.getLogger(GetAuthTokReqMsg.class);
protected String m_serviceName = null;
protected String m_hostName = null;
@ -98,7 +100,7 @@ public final class GetAuthTokReqMsg
// Verify that we obtained all of the required elements
if (m_state != DONE_PARSING)
{
System.err.println("GetAuthTokReqMsg SAXHandler.endDocument()- Missing element");
m_log.error("GetAuthTokReqMsg SAXHandler.endDocument()- Missing element");
throw new SAXException("Missing element");
}
}
@ -126,7 +128,7 @@ public final class GetAuthTokReqMsg
}
else
{
System.err.println("GetAuthTokReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("GetAuthTokReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -140,7 +142,7 @@ public final class GetAuthTokReqMsg
}
else
{
System.err.println("GetAuthTokReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("GetAuthTokReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -154,7 +156,7 @@ public final class GetAuthTokReqMsg
}
else
{
System.err.println("GetAuthTokReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("GetAuthTokReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
@ -169,13 +171,13 @@ public final class GetAuthTokReqMsg
}
else
{
System.err.println("GetAuthTokReqMsg SAXHandler.startElement()- Un-expected element");
m_log.error("GetAuthTokReqMsg SAXHandler.startElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
default:
System.err.println("GetAuthTokReqMsg SAXHandler.startElement()- State error");
m_log.error("GetAuthTokReqMsg SAXHandler.startElement()- State error");
throw new SAXException("State error");
}
}
@ -202,7 +204,7 @@ public final class GetAuthTokReqMsg
}
else
{
System.err.println("GetAuthTokReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("GetAuthTokReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -216,7 +218,7 @@ public final class GetAuthTokReqMsg
}
else
{
System.err.println("GetAuthTokReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("GetAuthTokReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -230,7 +232,7 @@ public final class GetAuthTokReqMsg
}
else
{
System.err.println("GetAuthTokReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("GetAuthTokReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
@ -244,13 +246,13 @@ public final class GetAuthTokReqMsg
}
else
{
System.err.println("GetAuthTokReqMsg SAXHandler.endElement()- Un-expected element");
m_log.error("GetAuthTokReqMsg SAXHandler.endElement()- Un-expected element");
throw new SAXException("Un-expected element");
}
break;
default:
System.err.println("GetAuthTokReqMsg SAXHandler.endElement()- State error");
m_log.error("GetAuthTokReqMsg SAXHandler.endElement()- State error");
throw new SAXException("State error");
}
}
@ -335,7 +337,7 @@ public final class GetAuthTokReqMsg
}
catch (SAXException e)
{
System.err.println("GetAuthTokReqMsg()- Parse exception: " + e.toString());
m_log.error("GetAuthTokReqMsg()- Parse exception: " + e.toString());
throw new Exception("Protocol error", e);
}
}

View File

@ -24,6 +24,8 @@
package com.novell.casa.authtoksvc;
import org.apache.log4j.Logger;
/**
* GetAuthTokRespMsg Class.
* <p>
@ -52,6 +54,7 @@ package com.novell.casa.authtoksvc;
*/
public final class GetAuthTokRespMsg
{
private static final Logger m_log = Logger.getLogger(GetAuthTokRespMsg.class);
final String m_msg;

View File

@ -24,6 +24,8 @@
package com.novell.casa.authtoksvc;
import org.apache.log4j.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
@ -37,6 +39,8 @@ import java.io.PrintWriter;
*/
public final class GetAuthToken implements RpcMethod
{
private static final Logger m_log = Logger.getLogger(GetAuthToken.class);
private SvcConfig m_svcConfig;
private EnabledSvcsConfig m_enabledSvcsConfig;
@ -72,7 +76,7 @@ public final class GetAuthToken implements RpcMethod
{
try
{
System.err.println("GetAuthToken.invoke()");
m_log.debug("GetAuthToken.invoke()");
// Parse the GetAuthTokReqMsg sent from the client
GetAuthTokReqMsg getAuthTokReqMsg = new GetAuthTokReqMsg(inStream);
@ -104,7 +108,7 @@ public final class GetAuthToken implements RpcMethod
}
catch (Exception e)
{
System.err.println("GetAuthToken.invoke()- Exception: " + e.toString());
m_log.info("GetAuthToken.invoke()- Exception: " + e.toString());
// Write out the response
try
@ -115,7 +119,7 @@ public final class GetAuthToken implements RpcMethod
}
catch (Exception e2)
{
System.err.println("GetAuthToken.invoke()- Exception trying to construct response msg: " + e2.toString());
m_log.error("GetAuthToken.invoke()- Exception trying to construct response msg: " + e2.toString());
}
}
}
@ -129,7 +133,7 @@ public final class GetAuthToken implements RpcMethod
}
catch (Exception e)
{
System.err.println("GetAuthToken.invoke()- Exception: " + e.toString());
m_log.error("GetAuthToken.invoke()- Exception: " + e.toString());
// Write out the response
try
@ -140,7 +144,7 @@ public final class GetAuthToken implements RpcMethod
}
catch (Exception e2)
{
System.err.println("GetAuthToken.invoke()- Exception trying to construct response msg: " + e2.toString());
m_log.error("GetAuthToken.invoke()- Exception trying to construct response msg: " + e2.toString());
}
}
}

View File

@ -31,6 +31,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.apache.log4j.Logger;
/**
* IdenTokenConfig Class.
@ -40,6 +41,8 @@ import org.xml.sax.helpers.XMLReaderFactory;
*/
public final class IdenTokenConfig
{
private static final Logger m_log = Logger.getLogger(IdenTokenConfig.class);
// Well known identity token configuration settings
public final static String EncryptAttributes = "EncryptAttributes";
public final static String Attributes = "Attributes";
@ -56,7 +59,7 @@ public final class IdenTokenConfig
*/
public IdenTokenConfig()
{
System.err.println("IdenTokenConfig()- Default");
m_log.debug("IdenTokenConfig()- Default");
// Create a map to keep track of the token settings
m_tokenSettingsMap = new HashMap<String, String>();
@ -73,7 +76,7 @@ public final class IdenTokenConfig
*/
public IdenTokenConfig(String idenTokenSettingsFileName) throws Exception
{
System.err.println("IdenTokenConfig()-");
m_log.debug("IdenTokenConfig()-");
// Create a map to keep track of the token settings
m_tokenSettingsMap = new HashMap<String, String>();
@ -90,14 +93,14 @@ public final class IdenTokenConfig
SettingsFileSAXHandler handler = new SettingsFileSAXHandler(m_tokenSettingsMap);
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
InputSource source = new InputSource(inStream);
xr.parse(source);
// Process the specified attributes
if (m_tokenSettingsMap.containsKey(Attributes) == false)
{
System.err.println("IdenTokenConfig()- Attributes not configured, defaulting them.");
m_log.info("IdenTokenConfig()- Attributes not configured, defaulting them.");
m_tokenSettingsMap.put(Attributes, m_defaultAttributesValue);
}
String attributes = m_tokenSettingsMap.get(Attributes);
@ -105,22 +108,22 @@ public final class IdenTokenConfig
}
catch (SAXException e)
{
System.err.println("IdenTokenConfig()- " + idenTokenSettingsFileName + " format error, exception: " + e.toString());
m_log.warn("IdenTokenConfig()- " + idenTokenSettingsFileName + " format error, exception: " + e.toString());
throw new Exception("IdenTokenConfig()- authtoken.settings format error", e);
}
catch (SecurityException e)
{
System.err.println("IdenTokenConfig()- SecurityException accessing " + idenTokenSettingsFileName + " Exception=" + e.toString());
m_log.warn("IdenTokenConfig()- SecurityException accessing " + idenTokenSettingsFileName + " Exception=" + e.toString());
throw new Exception("IdenTokenConfig()- Not able to access file", e);
}
catch (FileNotFoundException e)
{
System.err.println("IdenTokenConfig()- File " + idenTokenSettingsFileName + " not found");
m_log.warn("IdenTokenConfig()- File " + idenTokenSettingsFileName + " not found");
throw new Exception("IdenTokenConfig()- File not found", e);
}
catch (IOException e)
{
System.err.println("IdenTokenConfig()- IOException accessing " + idenTokenSettingsFileName + " Exception=" + e.toString());
m_log.warn("IdenTokenConfig()- IOException accessing " + idenTokenSettingsFileName + " Exception=" + e.toString());
throw new Exception("IdenTokenConfig()- Read error", e);
}
finally
@ -151,14 +154,14 @@ public final class IdenTokenConfig
String value = m_tokenSettingsMap.get(settingName);
if (value == null)
{
System.err.println("IdenTokenConfig.getSetting()- Did not find setting " + settingName);
m_log.info("IdenTokenConfig.getSetting()- Did not find setting " + settingName);
// The setting is not in our map, check if it is one to
// which we have defaults.
if (settingName.equalsIgnoreCase(EncryptAttributes))
{
value = m_defaultEncryptAttributesValue;
System.err.println("AuthTokenConfig.getSetting()- Assigning default value " + value);
m_log.info("AuthTokenConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_tokenSettingsMap.put(EncryptAttributes, m_defaultEncryptAttributesValue);
@ -166,8 +169,8 @@ public final class IdenTokenConfig
}
else
{
System.err.println("IdenTokenConfig.getSetting()- Found setting " + settingName);
System.err.println("IdenTokenConfig.getSetting()- Setting value = " + value);
m_log.info("IdenTokenConfig.getSetting()- Found setting " + settingName);
m_log.info("IdenTokenConfig.getSetting()- Setting value = " + value);
}
return value;

View File

@ -24,6 +24,8 @@
package com.novell.casa.authtoksvc;
import org.apache.log4j.Logger;
/**
* IdentityToken Interface.
* <p>

View File

@ -44,6 +44,7 @@ import org.ietf.jgss.Oid;
import org.bandit.ia.IAContext;
import org.bandit.util.config.Realm;
import org.apache.log4j.Logger;
/**
* Krb5Authenticate Class.
@ -55,6 +56,8 @@ import org.bandit.util.config.Realm;
*/
public final class Krb5Authenticate implements AuthMechanism, Serializable
{
private static final Logger m_log = Logger.getLogger(Krb5Authenticate.class);
private SvcConfig m_svcConfig;
private AuthMechConfig m_mechConfig;
@ -64,7 +67,7 @@ public final class Krb5Authenticate implements AuthMechanism, Serializable
protected GSSManager m_manager;
protected Oid m_krb5;
protected GSSName m_svcName;
protected GSSCredential m_credential;
protected GSSCredential m_credential;
/**
* Krb5 Token Class.
@ -105,7 +108,7 @@ public final class Krb5Authenticate implements AuthMechanism, Serializable
}
catch (GSSException e)
{
System.err.println("Krb5Authenticate Krb5Token()- GSS Exception caught: " + e.getLocalizedMessage());
m_log.warn("Krb5Authenticate Krb5Token()- GSS Exception caught: " + e.getLocalizedMessage());
throw new Exception("Authentication Failure", e);
}
}
@ -127,7 +130,7 @@ public final class Krb5Authenticate implements AuthMechanism, Serializable
public Krb5Authenticate()
{
// Nothing to do at this time
}
}
/**
* Initialize the mechanism.
@ -160,24 +163,24 @@ public final class Krb5Authenticate implements AuthMechanism, Serializable
// Create our host based service name
m_svcName = m_manager.createName(servicePrincipal,
GSSName.NT_HOSTBASED_SERVICE,
GSSName.NT_HOSTBASED_SERVICE,
m_krb5);
// Now acquire our credentials
m_credential = m_manager.createCredential(m_svcName,
GSSCredential.INDEFINITE_LIFETIME,
m_krb5,
m_credential = m_manager.createCredential(m_svcName,
GSSCredential.INDEFINITE_LIFETIME,
m_krb5,
GSSCredential.ACCEPT_ONLY);
}
catch (GSSException e)
{
System.err.println("Krb5Authenticate()- GSS Exception caught: " + e.getLocalizedMessage());
m_log.warn("Krb5Authenticate()- GSS Exception caught: " + e.getLocalizedMessage());
throw new Exception("Failed to instantiate needed GSS objects", e);
}
}
else
{
System.err.println("Krb5Authenticate()- Service Principal Name not configured");
m_log.warn("Krb5Authenticate()- Service Principal Name not configured");
throw new Exception("Service Principal Name not configured");
}
}
@ -195,7 +198,7 @@ public final class Krb5Authenticate implements AuthMechanism, Serializable
try
{
System.err.println("Krb5Authenticate.invoke()");
m_log.debug("Krb5Authenticate.invoke()");
// Now parse the Kerberos Token
Krb5Token krb5Token = new Krb5Token(authReqMsg.getAuthMechToken(), this);
@ -235,13 +238,13 @@ public final class Krb5Authenticate implements AuthMechanism, Serializable
searchString = "(userPrincipalName={0})";
else
{
System.err.println("Krb5Authenticate.invoke()- Unsupported realm type " + realmType);
m_log.warn("Krb5Authenticate.invoke()- Unsupported realm type " + realmType);
throw new Exception("Realm configuration error");
}
}
else
{
System.err.println("Krb5Authenticate.invoke()- Failed to obtain realm type for realm " + authReqMsg.getRealm());
m_log.warn("Krb5Authenticate.invoke()- Failed to obtain realm type for realm " + authReqMsg.getRealm());
throw new Exception("Realm configuration error");
}
@ -270,18 +273,18 @@ public final class Krb5Authenticate implements AuthMechanism, Serializable
}
else
{
System.err.println("Krb5Authenticate.invoke()- No matching identity entities found");
m_log.info("Krb5Authenticate.invoke()- No matching identity entities found");
}
}
}
catch (NamingException e)
{
// Log the error
System.err.println("Krb5Authenticate.invoke()- NamingException: " + e.toString());
m_log.warn("Krb5Authenticate.invoke()- NamingException: " + e.toString());
}
catch (Exception e)
{
System.err.println("Krb5Authenticate.invoke()- Exception: " + e.toString());
m_log.warn("Krb5Authenticate.invoke()- Exception: " + e.toString());
}
// Return the authentication result

View File

@ -40,6 +40,7 @@ import javax.naming.NamingException;
import org.bandit.ia.IAContext;
import org.bandit.util.config.Realm;
import org.apache.log4j.Logger;
/**
@ -52,6 +53,8 @@ import org.bandit.util.config.Realm;
*/
public final class PwdAuthenticate implements AuthMechanism, Serializable
{
private static final Logger m_log = Logger.getLogger(PwdAuthenticate.class);
private SvcConfig m_svcConfig;
private AuthMechConfig m_mechConfig;
@ -96,7 +99,7 @@ public final class PwdAuthenticate implements AuthMechanism, Serializable
// Check against zero length passwords
if (m_password.equals(""))
{
System.err.println("PwToken()- Zero length password diss-allowed");
m_log.warn("PwToken()- Zero length password diss-allowed");
throw new Exception("Zero length password");
}
}
@ -143,7 +146,7 @@ public final class PwdAuthenticate implements AuthMechanism, Serializable
public PwdAuthenticate()
{
// Nothing to do at this time
}
}
/**
* Initialize the mechanism.
@ -171,7 +174,7 @@ public final class PwdAuthenticate implements AuthMechanism, Serializable
try
{
System.err.println("PwdAuthenticate.invoke()");
m_log.debug("PwdAuthenticate.invoke()");
// Now parse the PW Token
PwToken pwToken = new PwToken(authReqMsg.getAuthMechToken());
@ -214,13 +217,13 @@ public final class PwdAuthenticate implements AuthMechanism, Serializable
searchString = "(sAMAccountName={0})";
else
{
System.err.println("PwdAuthenticate.invoke()- Unsupported realm type " + realmType);
m_log.warn("PwdAuthenticate.invoke()- Unsupported realm type " + realmType);
throw new Exception("Realm configuration error");
}
}
else
{
System.err.println("PwdAuthenticate.invoke()- Failed to obtain realm type for realm " + authReqMsg.getRealm());
m_log.warn("PwdAuthenticate.invoke()- Failed to obtain realm type for realm " + authReqMsg.getRealm());
throw new Exception("Realm configuration error");
}
}
@ -266,7 +269,7 @@ public final class PwdAuthenticate implements AuthMechanism, Serializable
}
catch (NamingException e)
{
System.err.println("PwdAuthenticate.invoke()- NamingException: " + e.getExplanation());
m_log.warn("PwdAuthenticate.invoke()- NamingException: " + e.getExplanation());
}
}
}
@ -274,17 +277,17 @@ public final class PwdAuthenticate implements AuthMechanism, Serializable
// Check if we did not resolve the identity
if (identId == null)
{
System.err.println("PwdAuthenticate.invoke()- Failed to resolve identity for entity " + pwToken.getUsername());
m_log.warn("PwdAuthenticate.invoke()- Failed to resolve identity for entity " + pwToken.getUsername());
}
}
catch (NamingException e)
{
// Log the error
System.err.println("PwdAuthenticate.invoke()- NamingException on Proxy User: " + e.toString());
m_log.warn("PwdAuthenticate.invoke()- NamingException on Proxy User: " + e.toString());
}
catch (Exception e)
{
System.err.println("PwdAuthenticate.invoke()- Exception: " + e.toString());
m_log.warn("PwdAuthenticate.invoke()- Exception: " + e.toString());
}
// Return the authentication result

View File

@ -34,6 +34,7 @@ import javax.naming.directory.Attributes;
import org.bandit.ia.IAContext;
import org.bandit.util.config.Realm;
import org.apache.log4j.Logger;
import java.io.FileReader;
import java.util.Hashtable;
@ -47,6 +48,8 @@ import java.util.HashMap;
*/
public class RealmsInfo
{
private static final Logger m_log = Logger.getLogger(RealmsInfo.class);
// Internal constants
private final static String RealmUrl = "Url";
private final static String RealmType = "Type";
@ -144,7 +147,7 @@ public class RealmsInfo
else
{
// Ignore parameter
System.err.println("RealmsInfo: Unknown directory type");
m_log.debug("RealmsInfo: Unknown directory type");
}
}
else if (env[iii].getProp().equalsIgnoreCase("com.novell.casa.authtoksvc.contextless_search_string"))

View File

@ -25,6 +25,7 @@
package com.novell.casa.authtoksvc;
import org.bandit.ia.IAContext;
import org.apache.log4j.Logger;
import java.util.*;
@ -47,6 +48,8 @@ public final class Rpc extends javax.servlet.http.HttpServlet implements javax.s
{
private static final long serialVersionUID = -8264027868130334613L;
private static final Logger m_log = Logger.getLogger(Rpc.class);
private String m_appFolderPath = null;
private String m_configFolderPath = null;
@ -85,7 +88,7 @@ public final class Rpc extends javax.servlet.http.HttpServlet implements javax.s
*/
public final void run ()
{
System.err.println("ReconfigureThread.run()- Running");
m_log.debug("ReconfigureThread.run()- Running");
while (m_run)
{
@ -107,13 +110,13 @@ public final class Rpc extends javax.servlet.http.HttpServlet implements javax.s
// Check if it is no longer necessary to re-configure the servlet
if (m_rpc.m_reconfigureInterval == 0)
{
System.err.println("ReconfigureTask.run()- Configuration changed to no longer perform timed re-configuration");
m_log.info("ReconfigureTask.run()- Configuration changed to no longer perform timed re-configuration");
break;
}
}
catch (Exception e)
{
System.err.println("ReconfigureTask.run()- Exception caught during re-configure process, " + e.toString());
m_log.warn("ReconfigureTask.run()- Exception caught during re-configure process, " + e.toString());
}
}
}
@ -152,7 +155,7 @@ public final class Rpc extends javax.servlet.http.HttpServlet implements javax.s
}
catch (NumberFormatException e)
{
System.err.println("Rpc.configureServlet()- Invalid reconfigure interval value format");
m_log.warn("Rpc.configureServlet()- Invalid reconfigure interval value");
m_reconfigureInterval = Integer.parseInt(SvcConfig.DefaultReconfigureIntervalValue);
}
@ -189,7 +192,7 @@ public final class Rpc extends javax.servlet.http.HttpServlet implements javax.s
{
super.init(config);
System.err.println("Rpc.init()");
m_log.debug("Rpc.init()");
try
{
@ -230,12 +233,13 @@ public final class Rpc extends javax.servlet.http.HttpServlet implements javax.s
}
catch (Exception e)
{
System.err.println("Rpc.init()- Exception caught: " + e.toString());
m_log.fatal("Rpc.init()- Exception caught: " + e.toString());
e.printStackTrace();
throw new ServletException("Exception caught while instantiating Rpc methods", e);
}
catch (Error e)
{
System.err.println("Rpc.init()- Error caught: " + e.toString());
m_log.fatal("Rpc.init()- Error caught: " + e.toString());
e.printStackTrace();
throw new Error("Error caught while instantiating Rpc methods", e);
}
@ -248,7 +252,7 @@ public final class Rpc extends javax.servlet.http.HttpServlet implements javax.s
{
super.destroy();
System.err.println("Rpc.destroy()");
m_log.debug("Rpc.destroy()");
// Stop our re-configure thread
if (m_reconfigureThread != null)
@ -285,6 +289,8 @@ public final class Rpc extends javax.servlet.http.HttpServlet implements javax.s
try
{
m_log.debug("Rpc.doPost()");
// Get ready to send back a reply
response.setContentType("text/html");
out = response.getWriter();
@ -305,26 +311,26 @@ public final class Rpc extends javax.servlet.http.HttpServlet implements javax.s
else
{
// Unsupported method
System.err.println("Rpc.doPost()- Unsupported method");
m_log.warn("Rpc.doPost()- Unsupported method");
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
}
else
{
// Missing method parameter
System.err.println("Rpc.doPost()- Missing method parameter");
m_log.warn("Rpc.doPost()- Missing method parameter");
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
}
catch (Exception e)
{
// tbd
System.err.println("Rpc.doPost()- Exception caught: " + e.toString());
m_log.error("Rpc.doPost()- Exception caught: " + e.toString());
e.printStackTrace();
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
catch (Error e)
{
System.err.println("Rpc.doPost()- Error caught: " + e.toString());
m_log.error("Rpc.doPost()- Error caught: " + e.toString());
e.printStackTrace();
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}

View File

@ -33,6 +33,7 @@ import org.apache.axis.configuration.NullProvider;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPBody;
import org.apache.axis.message.MessageElement;
import org.apache.log4j.Logger;
import javax.xml.namespace.QName;
import java.io.*;
@ -54,6 +55,7 @@ import java.io.*;
*/
public final class SessionToken
{
private static final Logger m_log = Logger.getLogger(SessionToken.class);
private String m_id = null;
private String m_realm = null;
@ -168,14 +170,14 @@ public final class SessionToken
if (m_realm == null || m_id == null)
{
System.out.println("SessionToken()- Required data missing from session token");
m_log.warn("SessionToken()- Required data missing from session token");
throw new Exception("Error: Required data missing from session Token");
}
}
else
{
// Message verification failed
System.err.println("SessionToken()- Invalid Session Token");
m_log.warn("SessionToken()- Invalid Session Token");
throw new Exception("Invalid Session Token");
}
}
@ -246,7 +248,7 @@ public final class SessionToken
}
catch (Exception e)
{
System.out.println("SessionToken.getMessage() - Exception caught building message, error: " + e.getMessage());
m_log.error("SessionToken.getMessage() - Exception caught building message, error: " + e.getMessage());
secureMessage = null;
}
finally

View File

@ -31,6 +31,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import org.apache.log4j.Logger;
/**
* SvcConfig Class.
@ -40,6 +41,8 @@ import org.xml.sax.helpers.XMLReaderFactory;
*/
public final class SvcConfig
{
private static final Logger m_log = Logger.getLogger(SvcConfig.class);
// Well known service configuration settings
//
// The LifetimeShorter value is the value by which token lifetime
@ -85,9 +88,9 @@ public final class SvcConfig
*/
public SvcConfig(String appRootPath, String svcConfigPath) throws Exception
{
System.err.println("SvcConfig()-");
m_log.debug("SvcConfig()-");
System.err.println("SvcConfig()- SvcConfigPath = " + svcConfigPath);
m_log.info("SvcConfig()- SvcConfigPath = " + svcConfigPath);
// Create a map to keep track of the service settings
m_svcSettingsMap = new HashMap<String, String>();
@ -98,13 +101,13 @@ public final class SvcConfig
// Get an input stream to services settings file
File settingsFile = new File(svcConfigPath, m_svcSettingsFileName);
inStream = new FileInputStream(settingsFile);
// Parse the file
XMLReader xr = XMLReaderFactory.createXMLReader();
SettingsFileSAXHandler handler = new SettingsFileSAXHandler(m_svcSettingsMap);
xr.setContentHandler(handler);
xr.setErrorHandler(handler);
InputSource source = new InputSource(inStream);
xr.parse(source);
@ -119,8 +122,8 @@ public final class SvcConfig
tokenLifetime = Integer.valueOf(getSetting(SessionTokenLifetime)).intValue();
if (tokenLifetime < MinimumTokenLifetimeValue)
{
System.err.println("SvcConfig()- Configured token lifetime too small, defaulting to "
+ Integer.toString(MinimumTokenLifetimeValue) + " seconds");
m_log.info("SvcConfig()- Configured token lifetime too small, defaulting to "
+ Integer.toString(MinimumTokenLifetimeValue) + " seconds");
tokenLifetime = MinimumTokenLifetimeValue;
// Update the map with the new value for the setting
@ -129,8 +132,8 @@ public final class SvcConfig
}
catch (NumberFormatException e)
{
System.err.println("SvcConfig()- Invalid configured token lifetime value, defaulting to "
+ Integer.toString(MinimumTokenLifetimeValue) + " seconds");
m_log.info("SvcConfig()- Invalid configured token lifetime value, defaulting to "
+ Integer.toString(MinimumTokenLifetimeValue) + " seconds");
tokenLifetime = MinimumTokenLifetimeValue;
// Update the map with the new value for the setting
@ -143,8 +146,8 @@ public final class SvcConfig
lifetimeShorter = Integer.valueOf(getSetting(LifetimeShorter)).intValue();
if (lifetimeShorter < MinimumLifetimeShorterValue)
{
System.err.println("SvcConfig()- Configured lifetime shorter too small, defaulting to "
+ Integer.toString(MinimumLifetimeShorterValue) + " seconds");
m_log.info("SvcConfig()- Configured lifetime shorter too small, defaulting to "
+ Integer.toString(MinimumLifetimeShorterValue) + " seconds");
lifetimeShorter = MinimumLifetimeShorterValue;
// Update the map with the new value for the setting
@ -153,8 +156,8 @@ public final class SvcConfig
}
catch (NumberFormatException e)
{
System.err.println("SvcConfig()- Invalid configured lifetime shorter value, defaulting to "
+ Integer.toString(MinimumLifetimeShorterValue) + " seconds");
m_log.info("SvcConfig()- Invalid configured lifetime shorter value, defaulting to "
+ Integer.toString(MinimumLifetimeShorterValue) + " seconds");
lifetimeShorter = MinimumLifetimeShorterValue;
// Update the map with the new value for the setting
@ -164,8 +167,8 @@ public final class SvcConfig
if (lifetimeShorter > tokenLifetime
|| (tokenLifetime - lifetimeShorter) < MinimumLifetimeShorterDifferential)
{
System.err.println("SvcConfig()- Invalid lifetime shorter value, defaulting to "
+ Integer.toString(MinimumLifetimeShorterValue) + " seconds");
m_log.info("SvcConfig()- Invalid lifetime shorter value, defaulting to "
+ Integer.toString(MinimumLifetimeShorterValue) + " seconds");
// Update the map with the new value for the setting
m_svcSettingsMap.put(LifetimeShorter, Integer.toString(MinimumLifetimeShorterValue));
@ -178,8 +181,8 @@ public final class SvcConfig
if (reconfigureInterval != 0
&& reconfigureInterval < MinimumReconfigureIntervalValue)
{
System.err.println("SvcConfig()- Configured reconfigure interval too small, defaulting to "
+ Integer.toString(MinimumReconfigureIntervalValue) + " seconds");
m_log.info("SvcConfig()- Configured reconfigure interval too small, defaulting to "
+ Integer.toString(MinimumReconfigureIntervalValue) + " seconds");
// Update the map with the new value for the setting
m_svcSettingsMap.put(ReconfigureInterval, Integer.toString(MinimumReconfigureIntervalValue));
@ -187,8 +190,8 @@ public final class SvcConfig
}
catch (NumberFormatException e)
{
System.err.println("SvcConfig()- Invalid configured reconfigured interval value, defaulting to "
+ Integer.toString(MinimumReconfigureIntervalValue) + " seconds");
m_log.info("SvcConfig()- Invalid configured reconfigured interval value, defaulting to "
+ Integer.toString(MinimumReconfigureIntervalValue) + " seconds");
// Update the map with the new value for the setting
m_svcSettingsMap.put(ReconfigureInterval, Integer.toString(MinimumReconfigureIntervalValue));
@ -199,22 +202,22 @@ public final class SvcConfig
}
catch (SAXException e)
{
System.err.println("SvcConfig()- Parse exception: " + e.toString());
m_log.warn("SvcConfig()- Parse exception: " + e.toString());
throw new Exception("SvcConfig()- svc.settings format error", e);
}
catch (SecurityException e)
{
System.err.println("SvcConfig()- SecurityException caught while accessing " + svcConfigPath + File.separator + m_svcSettingsFileName + " Exception=" + e.toString());
m_log.warn("SvcConfig()- SecurityException caught while accessing " + svcConfigPath + File.separator + m_svcSettingsFileName + " Exception=" + e.toString());
throw new Exception("SvcConfig()- Not able to access file", e);
}
catch (FileNotFoundException e)
{
System.err.println("SvcConfig()- File " + svcConfigPath + File.separator + m_svcSettingsFileName + " not found");
m_log.warn("SvcConfig()- File " + svcConfigPath + File.separator + m_svcSettingsFileName + " not found");
throw new Exception("SvcConfig()- File not found", e);
}
catch (IOException e)
{
System.err.println("SvcConfig()- IOException caught while trying to read " + svcConfigPath + File.separator + m_svcSettingsFileName + " Exception=" + e.toString());
m_log.warn("SvcConfig()- IOException caught while trying to read " + svcConfigPath + File.separator + m_svcSettingsFileName + " Exception=" + e.toString());
throw new Exception("SvcConfig()- Read error", e);
}
finally
@ -246,14 +249,14 @@ public final class SvcConfig
String value = m_svcSettingsMap.get(settingName);
if (value == null)
{
System.err.println("SvcConfig.getSetting()- Did not find setting " + settingName);
m_log.info("SvcConfig.getSetting()- Did not find setting " + settingName);
// The setting is not in our map, check if it is one to
// which we have defaults.
if (settingName.equalsIgnoreCase(SessionTokenLifetime))
{
value = DefaultSessionTokenLifetimeValue;
System.err.println("SvcConfig.getSetting()- Assigning default value " + value);
m_log.info("SvcConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_svcSettingsMap.put(SessionTokenLifetime, DefaultSessionTokenLifetimeValue);
@ -261,7 +264,7 @@ public final class SvcConfig
else if (settingName.equalsIgnoreCase(LifetimeShorter))
{
value = DefaultLifetimeShorterValue;
System.err.println("SvcConfig.getSetting()- Assigning default value " + value);
m_log.info("SvcConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_svcSettingsMap.put(LifetimeShorter, DefaultLifetimeShorterValue);
@ -269,7 +272,7 @@ public final class SvcConfig
else if (settingName.equalsIgnoreCase(ReconfigureInterval))
{
value = DefaultReconfigureIntervalValue;
System.err.println("SvcConfig.getSetting()- Assigning default value " + value);
m_log.info("SvcConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_svcSettingsMap.put(ReconfigureInterval, DefaultReconfigureIntervalValue);
@ -277,7 +280,7 @@ public final class SvcConfig
else if (settingName.equalsIgnoreCase(SigningKeyAliasName))
{
value = DefaultSigningKeyAliasNameValue;
System.err.println("SvcConfig.getSetting()- Assigning default value " + value);
m_log.info("SvcConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_svcSettingsMap.put(SigningKeyAliasName, DefaultSigningKeyAliasNameValue);
@ -285,21 +288,21 @@ public final class SvcConfig
else if (settingName.equalsIgnoreCase(SigningKeyPassword))
{
value = DefaultSigningKeyPasswordValue;
System.err.println("SvcConfig.getSetting()- Assigning default value " + value);
m_log.info("SvcConfig.getSetting()- Assigning default value " + value);
// Add the key to the map so that it can be found quicker next time
m_svcSettingsMap.put(SigningKeyPassword, DefaultSigningKeyPasswordValue);
}
else if (settingName.equalsIgnoreCase(IdentityAbstractionConfigFile))
{
System.err.println("SvcConfig.getSetting()- Mandatory setting " + IdentityAbstractionConfigFile + " not set");
m_log.info("SvcConfig.getSetting()- Mandatory setting " + IdentityAbstractionConfigFile + " not set");
throw new Exception("Missing mandatory configuration setting");
}
}
else
{
System.err.println("SvcConfig.getSetting()- Found setting " + settingName);
System.err.println("SvcConfig.getSetting()- Setting value = " + value);
m_log.info("SvcConfig.getSetting()- Found setting " + settingName);
m_log.info("SvcConfig.getSetting()- Setting value = " + value);
}
return value;

View File

@ -36,6 +36,7 @@ import org.apache.ws.security.message.WSSecHeader;
import org.apache.ws.security.message.WSSecSignature;
import org.apache.ws.security.message.WSSecTimestamp;
import org.apache.xml.security.c14n.Canonicalizer;
import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -55,6 +56,8 @@ import java.util.Vector;
*/
public final class WSSecurity
{
private static final Logger m_log = Logger.getLogger(WSSecurity.class);
static final private WSSecurityEngine secEngine = new WSSecurityEngine();
static final private Crypto crypto = CryptoFactory.getInstance();
@ -237,17 +240,17 @@ public final class WSSecurity
if (timeStampProcessed && signatureProcessed)
{
System.out.println("WSSecurity.verifyMessage() - Validation succeded");
m_log.debug("WSSecurity.verifyMessage() - Validation succeded");
msgVerificationStatus = true;
}
else
{
System.out.println("WSSecurity.verifyMessage() - validation failed");
m_log.warn("WSSecurity.verifyMessage() - validation failed");
}
}
catch (WSSecurityException e)
{
System.out.println("WSSecurity.verifyMessage() - Verification failed with error:" + e.getMessage() + " code = " + e.getErrorCode());
m_log.warn("WSSecurity.verifyMessage() - Verification failed with error:" + e.getMessage() + " code = " + e.getErrorCode());
}
return msgVerificationStatus;