You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2004/01/03 02:09:31 UTC
cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/util ConfigurationUtil.java
djencks 2004/01/02 17:09:31
Modified: modules/core/src/java/org/apache/geronimo/security
EJBModuleConfiguration.java
WebModuleConfiguration.java
modules/core/src/java/org/apache/geronimo/security/util
ConfigurationUtil.java
Log:
Important parts of Geronimo-138maven.xml
Revision Changes Path
1.6 +35 -35 incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/EJBModuleConfiguration.java
Index: EJBModuleConfiguration.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/EJBModuleConfiguration.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EJBModuleConfiguration.java 2 Jan 2004 04:31:44 -0000 1.5
+++ EJBModuleConfiguration.java 3 Jan 2004 01:09:31 -0000 1.6
@@ -67,6 +67,7 @@
import org.apache.geronimo.deployment.model.geronimo.j2ee.Realm;
import org.apache.geronimo.deployment.model.geronimo.j2ee.Role;
import org.apache.geronimo.deployment.model.geronimo.j2ee.RoleMappings;
+import org.apache.geronimo.deployment.model.geronimo.j2ee.Security;
import org.apache.geronimo.deployment.model.j2ee.SecurityRole;
import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
import org.apache.geronimo.security.util.ConfigurationUtil;
@@ -110,37 +111,41 @@
ConfigurationUtil.configure(configuration, ejbJar);
setConfigured(true);
- RoleMappings roleMappings = ejbJar.getSecurity().getRoleMappings();
- if (roleMappings != null) {
- Role[] roles = roleMappings.getRole();
- for (int i=0; i<roles.length; i++) {
- Role role = roles[i];
- Realm[] realms = role.getRealm();
- for (int j=0; j<realms.length; j++) {
- Realm realm = realms[j];
- Principal[] principals = realm.getPrincipal();
- HashSet set = new HashSet();
- for (int k=0; k<principals.length; k++) {
- Principal principal = principals[k];
- java.security.Principal p = null;
- try {
- Class clazz = Class.forName(principal.getClassName());
- Constructor constructor = clazz.getDeclaredConstructor(new Class[]{ String.class });
- p = (java.security.Principal)constructor.newInstance(new Object[] { principal.getName() });
- set.add(new RealmPrincipal(realm.getRealmName(), p));
- } catch (InstantiationException e) {
- throw new GeronimoSecurityException(e);
- } catch (IllegalAccessException e) {
- throw new GeronimoSecurityException(e);
- } catch (ClassNotFoundException e) {
- throw new GeronimoSecurityException(e);
- } catch (NoSuchMethodException e) {
- throw new GeronimoSecurityException(e);
- } catch (InvocationTargetException e) {
- throw new GeronimoSecurityException(e);
+ Security security = ejbJar.getSecurity();
+ //TODO not clear if schema allows/should allow security == null
+ if (security != null) {
+ RoleMappings roleMappings = security.getRoleMappings();
+ if (roleMappings != null) {
+ Role[] roles = roleMappings.getRole();
+ for (int i = 0; i < roles.length; i++) {
+ Role role = roles[i];
+ Realm[] realms = role.getRealm();
+ for (int j = 0; j < realms.length; j++) {
+ Realm realm = realms[j];
+ Principal[] principals = realm.getPrincipal();
+ HashSet set = new HashSet();
+ for (int k = 0; k < principals.length; k++) {
+ Principal principal = principals[k];
+ java.security.Principal p = null;
+ try {
+ Class clazz = Class.forName(principal.getClassName());
+ Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class});
+ p = (java.security.Principal) constructor.newInstance(new Object[]{principal.getName()});
+ set.add(new RealmPrincipal(realm.getRealmName(), p));
+ } catch (InstantiationException e) {
+ throw new GeronimoSecurityException(e);
+ } catch (IllegalAccessException e) {
+ throw new GeronimoSecurityException(e);
+ } catch (ClassNotFoundException e) {
+ throw new GeronimoSecurityException(e);
+ } catch (NoSuchMethodException e) {
+ throw new GeronimoSecurityException(e);
+ } catch (InvocationTargetException e) {
+ throw new GeronimoSecurityException(e);
+ }
}
+ super.addRoleMapping(role.getRoleName(), set);
}
- super.addRoleMapping(role.getRoleName(), set);
}
}
}
@@ -149,11 +154,6 @@
public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception {
GeronimoMBeanInfo mbeanInfo = AbstractModuleConfiguration.getGeronimoMBeanInfo();
mbeanInfo.setTargetClass(EJBModuleConfiguration.class);
- /*mbeanInfo.addOperationInfo(new GeronimoOperationInfo("configure",
- new GeronimoParameterInfo[] {
- new GeronimoParameterInfo("EJBJar", EjbJar.class, "Geronimo POJO ejb jar descriptor")},
- GeronimoOperationInfo.ACTION,
- "Translate the EJB deployment descriptors into equivalent security permissions")); */
return mbeanInfo;
}
}
1.6 +35 -35 incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/WebModuleConfiguration.java
Index: WebModuleConfiguration.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/WebModuleConfiguration.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WebModuleConfiguration.java 2 Jan 2004 04:31:44 -0000 1.5
+++ WebModuleConfiguration.java 3 Jan 2004 01:09:31 -0000 1.6
@@ -66,6 +66,7 @@
import org.apache.geronimo.deployment.model.geronimo.j2ee.Realm;
import org.apache.geronimo.deployment.model.geronimo.j2ee.Role;
import org.apache.geronimo.deployment.model.geronimo.j2ee.RoleMappings;
+import org.apache.geronimo.deployment.model.geronimo.j2ee.Security;
import org.apache.geronimo.deployment.model.geronimo.web.WebApp;
import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
import org.apache.geronimo.security.util.ConfigurationUtil;
@@ -112,37 +113,41 @@
ConfigurationUtil.configure(configuration, webApp);
setConfigured(true);
- RoleMappings roleMappings = webApp.getSecurity().getRoleMappings();
- if (roleMappings != null) {
- Role[] roles = roleMappings.getRole();
- for (int i=0; i<roles.length; i++) {
- Role role = roles[i];
- Realm[] realms = role.getRealm();
- for (int j=0; j<realms.length; j++) {
- Realm realm = realms[j];
- Principal[] principals = realm.getPrincipal();
- HashSet set = new HashSet();
- for (int k=0; k<principals.length; k++) {
- Principal principal = principals[k];
- java.security.Principal p = null;
- try {
- Class clazz = Class.forName(principal.getClassName());
- Constructor constructor = clazz.getDeclaredConstructor(new Class[]{ String.class });
- p = (java.security.Principal)constructor.newInstance(new Object[] { principal.getName() });
- set.add(new RealmPrincipal(realm.getRealmName(), p));
- } catch (InstantiationException e) {
- throw new GeronimoSecurityException(e);
- } catch (IllegalAccessException e) {
- throw new GeronimoSecurityException(e);
- } catch (ClassNotFoundException e) {
- throw new GeronimoSecurityException(e);
- } catch (NoSuchMethodException e) {
- throw new GeronimoSecurityException(e);
- } catch (InvocationTargetException e) {
- throw new GeronimoSecurityException(e);
+ Security security = webApp.getSecurity();
+ //TODO not clear if schema allows/should allow security == null
+ if (security != null) {
+ RoleMappings roleMappings = security.getRoleMappings();
+ if (roleMappings != null) {
+ Role[] roles = roleMappings.getRole();
+ for (int i = 0; i < roles.length; i++) {
+ Role role = roles[i];
+ Realm[] realms = role.getRealm();
+ for (int j = 0; j < realms.length; j++) {
+ Realm realm = realms[j];
+ Principal[] principals = realm.getPrincipal();
+ HashSet set = new HashSet();
+ for (int k = 0; k < principals.length; k++) {
+ Principal principal = principals[k];
+ java.security.Principal p = null;
+ try {
+ Class clazz = Class.forName(principal.getClassName());
+ Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class});
+ p = (java.security.Principal) constructor.newInstance(new Object[]{principal.getName()});
+ set.add(new RealmPrincipal(realm.getRealmName(), p));
+ } catch (InstantiationException e) {
+ throw new GeronimoSecurityException(e);
+ } catch (IllegalAccessException e) {
+ throw new GeronimoSecurityException(e);
+ } catch (ClassNotFoundException e) {
+ throw new GeronimoSecurityException(e);
+ } catch (NoSuchMethodException e) {
+ throw new GeronimoSecurityException(e);
+ } catch (InvocationTargetException e) {
+ throw new GeronimoSecurityException(e);
+ }
}
+ super.addRoleMapping(role.getRoleName(), set);
}
- super.addRoleMapping(role.getRoleName(), set);
}
}
}
@@ -151,11 +156,6 @@
public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception {
GeronimoMBeanInfo mbeanInfo = AbstractModuleConfiguration.getGeronimoMBeanInfo();
mbeanInfo.setTargetClass(WebModuleConfiguration.class);
- /*mbeanInfo.addOperationInfo(new GeronimoOperationInfo("configure",
- new GeronimoParameterInfo[] {
- new GeronimoParameterInfo("WebApp", WebApp.class, "Geronimo POJO web-app descriptor")},
- GeronimoOperationInfo.ACTION,
- "Translate the Web deployment descriptors into equivalent security permissions"));*/
return mbeanInfo;
}
}
1.4 +11 -10 incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/util/ConfigurationUtil.java
Index: ConfigurationUtil.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/security/util/ConfigurationUtil.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConfigurationUtil.java 2 Jan 2004 04:31:44 -0000 1.3
+++ ConfigurationUtil.java 3 Jan 2004 01:09:31 -0000 1.4
@@ -109,7 +109,7 @@
public static void registerPolicyContextHandler(PolicyContextHandler handler, boolean replace) throws PolicyContextException {
String[] keys = handler.getKeys();
- for (int i=0; i<keys.length; i++) {
+ for (int i = 0; i < keys.length; i++) {
PolicyContext.registerHandler(keys[i], handler, replace);
}
}
@@ -124,7 +124,6 @@
* the security descriptor or the state of the module configuration.
* @see javax.security.jacc.PolicyConfiguration
* @see "Java Authorization Contract for Containers", section 3.1.3
- * @jmx:managed-operation
*/
public static void configure(PolicyConfiguration configuration, WebApp webApp) throws GeronimoSecurityException {
@@ -279,7 +278,9 @@
String name = pattern.getQualifiedPattern(allSet);
String actions = pattern.getComplementedMethods();
- if (actions.length() == 0) continue;
+ if (actions.length() == 0) {
+ continue;
+ }
configuration.addToUncheckedPolicy(new WebResourcePermission(name, actions));
configuration.addToUncheckedPolicy(new WebUserDataPermission(name, actions));
@@ -318,9 +319,9 @@
for (int j = 0; j < methods.length; j++) {
Method method = methods[j];
EJBMethodPermission permission = new EJBMethodPermission(method.getEjbName(),
- method.getMethodName(),
- method.getMethodIntf(),
- method.getMethodParam());
+ method.getMethodName(),
+ method.getMethodIntf(),
+ method.getMethodParam());
try {
if (methodPermission.isUnchecked()) {
@@ -345,9 +346,9 @@
try {
for (int i = 0; i < methods.length; i++) {
EJBMethodPermission permission = new EJBMethodPermission(methods[i].getEjbName(),
- methods[i].getMethodName(),
- methods[i].getMethodIntf(),
- methods[i].getMethodParam());
+ methods[i].getMethodName(),
+ methods[i].getMethodIntf(),
+ methods[i].getMethodParam());
configuration.addToExcludedPolicy(permission);
}
} catch (PolicyContextException e) {