|
|
|
@ -25,7 +25,6 @@ import java.util.List; |
|
|
|
import javax.naming.Context; |
|
|
|
import javax.naming.Context; |
|
|
|
import javax.naming.InitialContext; |
|
|
|
import javax.naming.InitialContext; |
|
|
|
import javax.naming.NamingException; |
|
|
|
import javax.naming.NamingException; |
|
|
|
import javax.rmi.PortableRemoteObject; |
|
|
|
|
|
|
|
import javax.security.auth.Subject; |
|
|
|
import javax.security.auth.Subject; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
@ -44,6 +43,8 @@ final class DefaultWASUsernameAndGroupsExtractor implements WASUsernameAndGroups |
|
|
|
private static final Log logger = LogFactory |
|
|
|
private static final Log logger = LogFactory |
|
|
|
.getLog(DefaultWASUsernameAndGroupsExtractor.class); |
|
|
|
.getLog(DefaultWASUsernameAndGroupsExtractor.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String PORTABLE_REMOTE_OBJECT_CLASSNAME = "javax.rmi.PortableRemoteObject"; |
|
|
|
|
|
|
|
|
|
|
|
private static final String USER_REGISTRY = "UserRegistry"; |
|
|
|
private static final String USER_REGISTRY = "UserRegistry"; |
|
|
|
|
|
|
|
|
|
|
|
private static Method getRunAsSubject = null; |
|
|
|
private static Method getRunAsSubject = null; |
|
|
|
@ -52,6 +53,8 @@ final class DefaultWASUsernameAndGroupsExtractor implements WASUsernameAndGroups |
|
|
|
|
|
|
|
|
|
|
|
private static Method getSecurityName = null; |
|
|
|
private static Method getSecurityName = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Method narrow = null; |
|
|
|
|
|
|
|
|
|
|
|
// SEC-803
|
|
|
|
// SEC-803
|
|
|
|
private static Class<?> wsCredentialClass = null; |
|
|
|
private static Class<?> wsCredentialClass = null; |
|
|
|
|
|
|
|
|
|
|
|
@ -80,7 +83,7 @@ final class DefaultWASUsernameAndGroupsExtractor implements WASUsernameAndGroups |
|
|
|
.iterator().next(); |
|
|
|
.iterator().next(); |
|
|
|
if (credential != null) { |
|
|
|
if (credential != null) { |
|
|
|
userSecurityName = (String) invokeMethod(getSecurityNameMethod(), |
|
|
|
userSecurityName = (String) invokeMethod(getSecurityNameMethod(), |
|
|
|
credential, null); |
|
|
|
credential); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
@ -125,8 +128,7 @@ final class DefaultWASUsernameAndGroupsExtractor implements WASUsernameAndGroups |
|
|
|
// TODO: Cache UserRegistry object
|
|
|
|
// TODO: Cache UserRegistry object
|
|
|
|
ic = new InitialContext(); |
|
|
|
ic = new InitialContext(); |
|
|
|
Object objRef = ic.lookup(USER_REGISTRY); |
|
|
|
Object objRef = ic.lookup(USER_REGISTRY); |
|
|
|
Object userReg = PortableRemoteObject.narrow(objRef, |
|
|
|
Object userReg = invokeMethod(getNarrowMethod(), null , objRef, Class.forName("com.ibm.websphere.security.UserRegistry")); |
|
|
|
Class.forName("com.ibm.websphere.security.UserRegistry")); |
|
|
|
|
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
logger.debug("Determining WebSphere groups for user " + securityName |
|
|
|
logger.debug("Determining WebSphere groups for user " + securityName |
|
|
|
+ " using WebSphere UserRegistry " + userReg); |
|
|
|
+ " using WebSphere UserRegistry " + userReg); |
|
|
|
@ -156,7 +158,7 @@ final class DefaultWASUsernameAndGroupsExtractor implements WASUsernameAndGroups |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static Object invokeMethod(Method method, Object instance, Object[] args) { |
|
|
|
private static Object invokeMethod(Method method, Object instance, Object... args) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
return method.invoke(instance, args); |
|
|
|
return method.invoke(instance, args); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -230,6 +232,13 @@ final class DefaultWASUsernameAndGroupsExtractor implements WASUsernameAndGroups |
|
|
|
return getSecurityName; |
|
|
|
return getSecurityName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Method getNarrowMethod() { |
|
|
|
|
|
|
|
if (narrow == null) { |
|
|
|
|
|
|
|
narrow = getMethod(PORTABLE_REMOTE_OBJECT_CLASSNAME, "narrow", new String[] { Object.class.getName() , Class.class.getName()}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return narrow; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SEC-803
|
|
|
|
// SEC-803
|
|
|
|
private static Class<?> getWSCredentialClass() { |
|
|
|
private static Class<?> getWSCredentialClass() { |
|
|
|
if (wsCredentialClass == null) { |
|
|
|
if (wsCredentialClass == null) { |
|
|
|
|