User: starksm
Date: 01/09/30 15:44:26
Modified: src/main/org/jboss/resource/security Tag: Branch_2_4
ManyToOnePrincipalMapping.java
PrincipalMapping.java PrincipalMappingSupport.java
Log:
Merge a main snapshot from 2001-08-22 into the 2.4 branch
Revision Changes Path
No revision
No revision
1.1.1.1.4.1 +81 -33
jbosscx/src/main/org/jboss/resource/security/ManyToOnePrincipalMapping.java
Index: ManyToOnePrincipalMapping.java
===================================================================
RCS file:
/cvsroot/jboss/jbosscx/src/main/org/jboss/resource/security/ManyToOnePrincipalMapping.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.1
diff -u -r1.1.1.1 -r1.1.1.1.4.1
--- ManyToOnePrincipalMapping.java 2001/02/06 06:54:41 1.1.1.1
+++ ManyToOnePrincipalMapping.java 2001/09/30 22:44:26 1.1.1.1.4.1
@@ -1,5 +1,5 @@
/*
- * JBoss, the OpenSource EJB server
+ * JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@@ -8,32 +8,29 @@
import java.security.Principal;
-import javax.security.auth.Subject;
-
import javax.resource.spi.security.PasswordCredential;
+import javax.security.auth.Subject;
+
/**
- * A principal mapping that maps all caller principals to a single
- * resource principal. Currently only basic password authentication
- * is supported.
+ * A principal mapping that maps all caller principals to a single resource
+ * principal. Currently only basic password authentication is supported. <p>
*
- * <p> The properties string is expected to contain (in
- * <code>Properties.load</code> format) two properties:
- * <code>userName</code> and <code>password</code>. These are used
- * to construct the <code>PasswordCredential</code> attached to the
- * resource principal.
+ * The properties string is expected to contain (in <code>Properties.load
+ * </code>format) two properties: <code>userName</code> and <code>password
+ * </code>. These are used to construct the <code>PasswordCredential</code>
+ * attached to the resource principal. <p>
*
- * <p> Additionally, the properties can contain a
- * <code>principalName</code> property that specifies the name of
- * the resource principal. If this property is not set then the
- * <code>userName</code> is used.
+ * Additionally, the properties can contain a <code>principalName</code>
+ * property that specifies the name of the resource principal. If this property
+ * is not set then the <code>userName</code> is used.
*
- * @see org.jboss.resource.ConnectionManagerImpl
- * @author Toby Allsopp ([EMAIL PROTECTED])
- * @version $Revision: 1.1.1.1 $
+ * @author Toby Allsopp ([EMAIL PROTECTED])
+ * @see org.jboss.resource.ConnectionManagerImpl
+ * @version $Revision: 1.1.1.1.4.1 $
*/
public class ManyToOnePrincipalMapping
- extends PrincipalMappingSupport
+ extends PrincipalMappingSupport
{
// Constants -----------------------------------------------------
@@ -51,6 +48,12 @@
// PrincipalMappingSupport overrides -----------------------------
+ /**
+ * #Description of the Method
+ *
+ * @param callerPrincipal Description of Parameter
+ * @return Description of the Returned Value
+ */
public Subject createSubject(Principal callerPrincipal)
{
if (userName == null)
@@ -61,21 +64,21 @@
Subject subject = new Subject();
subject.getPrincipals().add(resourcePrincipal);
- if (metadata.getAuthMechType().equals("basic-password"))
+ if (metadata.getAuthMechType().equals("BasicPassword"))
{
// The spec says that we need a new instance of this every
// time, because it is specific to a managed connection
// factory instance. We could probably get away with caching
// one per MCF, but who really cares?
PasswordCredential cred =
- new PasswordCredential(userName, password.toCharArray());
+ new PasswordCredential(userName, password.toCharArray());
cred.setManagedConnectionFactory(mcf);
subject.getPrivateCredentials().add(cred);
}
else
{
- throw new RuntimeException("Unsupported auth-mech-type: '" +
- metadata.getAuthMechType() + "'");
+ throw new RuntimeException("Unsupported authentication-mechanism-type: '" +
+ metadata.getAuthMechType() + "'");
}
return subject;
@@ -83,13 +86,18 @@
protected void afterSetProperties()
{
- userName = (String) properties.get("userName");
- password = (String) properties.get("password");
- if (password == null) password = "";
+ userName = (String)properties.get("userName");
+ password = (String)properties.get("password");
+ if (password == null)
+ {
+ password = "";
+ }
- String principalName = (String) properties.get("principalName");
+ String principalName = (String)properties.get("principalName");
if (principalName == null)
+ {
principalName = userName;
+ }
resourcePrincipal = new ResourcePrincipal(principalName);
}
@@ -101,26 +109,66 @@
// Inner classes -------------------------------------------------
+ /**
+ *
+ */
private static class ResourcePrincipal
- implements Principal
+ implements Principal
{
private final String name;
- private ResourcePrincipal(String name) { this.name = name; }
+ private ResourcePrincipal(String name)
+ {
+ this.name = name;
+ }
- public String getName() { return name; }
+ /**
+ * Gets the Name attribute of the ResourcePrincipal object
+ *
+ * @return The Name value
+ */
+ public String getName()
+ {
+ return name;
+ }
- public int hashCode() { return name.hashCode(); }
+ /**
+ * #Description of the Method
+ *
+ * @return Description of the Returned Value
+ */
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+ /**
+ * #Description of the Method
+ *
+ * @param other Description of Parameter
+ * @return Description of the Returned Value
+ */
public boolean equals(Object other)
{
if (other instanceof ResourcePrincipal)
- return ((ResourcePrincipal) other).name.equals(name);
+ {
+ return ((ResourcePrincipal)other).name.equals(name);
+ }
else
+ {
return false;
+ }
}
- public String toString() { return name; }
+ /**
+ * #Description of the Method
+ *
+ * @return Description of the Returned Value
+ */
+ public String toString()
+ {
+ return name;
+ }
}
}
1.1.1.1.4.1 +36 -33
jbosscx/src/main/org/jboss/resource/security/PrincipalMapping.java
Index: PrincipalMapping.java
===================================================================
RCS file:
/cvsroot/jboss/jbosscx/src/main/org/jboss/resource/security/PrincipalMapping.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.1
diff -u -r1.1.1.1 -r1.1.1.1.4.1
--- PrincipalMapping.java 2001/02/06 06:54:41 1.1.1.1
+++ PrincipalMapping.java 2001/09/30 22:44:26 1.1.1.1.4.1
@@ -1,5 +1,5 @@
/*
- * JBoss, the OpenSource EJB server
+ * JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@@ -8,23 +8,24 @@
import java.security.Principal;
-import javax.security.auth.Subject;
-
import javax.resource.spi.ManagedConnectionFactory;
+import javax.security.auth.Subject;
+
import org.jboss.logging.Log;
import org.jboss.resource.RARMetaData;
/**
- * Interface for classes that implement a mapping from caller
- * principal to resource principal.
+ * Interface for classes that implement a mapping from caller principal to
+ * resource principal. <p>
*
- * <p> The <code>set...</code> methods <strong>must</strong> be
- * called before <code>createSubject</code>.
+ * The <code>set...</code> methods <strong>must</strong> be called before
+ * <code>createSubject</code> .
*
- * @see org.jboss.resource.ConnectionManagerImpl
- * @author Toby Allsopp ([EMAIL PROTECTED])
- * @version $Revision: 1.1.1.1 $
+ * @author Toby Allsopp ([EMAIL PROTECTED])
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
+ * @see org.jboss.resource.ConnectionManagerImpl
+ * @version $Revision: 1.1.1.1.4.1 $
*/
public interface PrincipalMapping
{
@@ -33,46 +34,48 @@
// Public --------------------------------------------------------
/**
- * Sets the <code>Log</code> to which to log.
+ * Sets the <code>name</code> portion of the category for log4j logging.
+ *
+ * @param name The new Name value
*/
- void setLog(Log log);
+ void setName(String name);
/**
- * Sets the managed connection factory for which principals will be
- * mapped.
+ * Sets the managed connection factory for which principals will be mapped.
+ *
+ * @param mcf The new ManagedConnectionFactory value
*/
void setManagedConnectionFactory(ManagedConnectionFactory mcf);
/**
- * Sets the meta-data that describes the resource adapter for which
- * principals will be mapped.
+ * Sets the meta-data that describes the resource adapter for which
+ * principals will be mapped.
+ *
+ * @param metadata The new RARMetaData value
*/
void setRARMetaData(RARMetaData metadata);
/**
- * Sets configuration information for a particular implementation
- * of this interface. The format of this information is specific to
- * each implementation, but it is intended that a sequence of
- * name-value pairs in <code>Properties.load</code> format will be
- * used.
+ * Sets configuration information for a particular implementation of this
+ * interface. The format of this information is specific to each
+ * implementation, but it is intended that a sequence of name-value pairs in
+ * <code>Properties.load</code> format will be used.
*
- * @see java.util.Properties#load
+ * @param properties The new Properties value
+ * @see java.util.Properties#load
*/
void setProperties(String properties);
/**
- * Creates a <code>Subject</code> that contains the resource
- * principal and its credentials obtained from the principal
- * mapping implementation.
- *
- * @param callerPrincipal the identity under which the request for
- * a connection has been made, i.e. the
- * principal the requesting component is
- * running under.
+ * Creates a <code>Subject</code> that contains the resource principal and
+ * its credentials obtained from the principal mapping implementation.
*
- * @return a new <code>Subject</code> instance containing a single
- * principal, the mapped resource principal, and whatever
- * credentials are required for EIS sign-on
+ * @param callerPrincipal the identity under which the request for a
+ * connection has been made, i.e. the principal the requesting component
+ * is running under.
+ * @return a new <code>Subject</code> instance containing a
+ * single principal, the mapped resource principal, and whatever
+ * credentials are required for EIS sign-on
*/
Subject createSubject(Principal callerPrincipal);
}
1.1.1.1.4.1 +45 -19
jbosscx/src/main/org/jboss/resource/security/PrincipalMappingSupport.java
Index: PrincipalMappingSupport.java
===================================================================
RCS file:
/cvsroot/jboss/jbosscx/src/main/org/jboss/resource/security/PrincipalMappingSupport.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.1
diff -u -r1.1.1.1 -r1.1.1.1.4.1
--- PrincipalMappingSupport.java 2001/02/06 06:54:41 1.1.1.1
+++ PrincipalMappingSupport.java 2001/09/30 22:44:26 1.1.1.1.4.1
@@ -1,5 +1,5 @@
/*
- * JBoss, the OpenSource EJB server
+ * JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@@ -12,28 +12,29 @@
import javax.resource.spi.ManagedConnectionFactory;
-import org.jboss.logging.Log;
+import org.jboss.logging.log4j.JBossCategory;
import org.jboss.resource.RARMetaData;
/**
- * Base class for <code>PrincipalMapping</code> implementations that
- * want to share some implementation tedium.
+ * Base class for <code>PrincipalMapping</code> implementations that want to
+ * share some implementation tedium. <p>
*
- * <p> The implementation of <code>setProperties</code> assumes that
- * the properties string is in <code>Properties.load</code> format
- * and takes care of converting to a <code>Properties</code> object.
+ * The implementation of <code>setProperties</code> assumes that the properties
+ * string is in <code>Properties.load</code> format and takes care of
+ * converting to a <code>Properties</code> object.
*
- * @author Toby Allsopp ([EMAIL PROTECTED])
- * @version $Revision: 1.1.1.1 $
+ * @author Toby Allsopp ([EMAIL PROTECTED])
+ * @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
+ * @version $Revision: 1.1.1.1.4.1 $
*/
public abstract class PrincipalMappingSupport
- implements PrincipalMapping
+ implements PrincipalMapping
{
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
- protected Log log;
+ protected JBossCategory category;
protected ManagedConnectionFactory mcf;
protected RARMetaData metadata;
protected Properties properties;
@@ -46,31 +47,54 @@
// PrincipalMapping implementation -------------------------------
- public void setLog(Log log) { this.log = log; }
+ /**
+ * Sets the Name attribute of the PrincipalMappingSupport object
+ *
+ * @param name The new Name value
+ */
+ public void setName(String name)
+ {
+ category = (JBossCategory)JBossCategory.getInstance(getClass().getName() +
"." + name);
+ }
+ /**
+ * Sets the ManagedConnectionFactory attribute of the PrincipalMappingSupport
+ * object
+ *
+ * @param mcf The new ManagedConnectionFactory value
+ */
public void setManagedConnectionFactory(ManagedConnectionFactory mcf)
{
this.mcf = mcf;
}
+ /**
+ * Sets the RARMetaData attribute of the PrincipalMappingSupport object
+ *
+ * @param metadata The new RARMetaData value
+ */
public void setRARMetaData(RARMetaData metadata)
{
this.metadata = metadata;
}
+ /**
+ * Sets the Properties attribute of the PrincipalMappingSupport object
+ *
+ * @param propStr The new Properties value
+ */
public void setProperties(String propStr)
{
properties = new Properties();
try
{
properties.load(
- new ByteArrayInputStream(propStr.getBytes("ISO-8859-1")));
+ new ByteArrayInputStream(propStr.getBytes("ISO-8859-1")));
}
catch (IOException ioe)
{
- log.error("Couldn't convert properties string '" + propStr + "' to " +
- "Properties");
- log.exception(ioe);
+ category.error("Couldn't convert properties string '" + propStr + "' to " +
+ "Properties", ioe);
}
afterSetProperties();
}
@@ -80,10 +104,12 @@
// Protected -----------------------------------------------------
/**
- * Called once the <code>properties</code> field has been
- * initialised and populated.
+ * Called once the <code>properties</code> field has been initialised and
+ * populated.
*/
- protected void afterSetProperties() {}
+ protected void afterSetProperties()
+ {
+ }
// Private -------------------------------------------------------
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development