Class Util
java.lang.Object
org.jboss.as.test.shared.integration.ejb.security.Util
Holder for couple of utility methods used while testing EJB3 security.
- Author:
- Darran Lofthouse
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ContextHelper to create InitialContext with necessary properties.static StringcreateRemoteEjbJndiContext(String appName, String moduleName, String distinctName, String beanName, String viewClassName, boolean isStateful) Creates JNDI context string based on given parameters.static <T> TswitchIdentity(String username, String password, Callable<T> callable) Switch the user's identity using Elytron.static <T> TswitchIdentity(String username, String password, Callable<T> callable, boolean validateException) Switch the user's identity using Elytron.static <T> TswitchIdentity(String username, String password, Callable<T> callable, boolean validateException, ClassLoader classLoader) Switch the user's identity using Elytron.static <T> TswitchIdentity(String username, String password, Callable<T> callable, ClassLoader classLoader) Switch the user's identity using Elytron.static <T> TswitchIdentitySCF(String username, String password, Callable<T> callable) Switch the user's identity using Elytron.
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
createRemoteEjbJndiContext
public static String createRemoteEjbJndiContext(String appName, String moduleName, String distinctName, String beanName, String viewClassName, boolean isStateful) Creates JNDI context string based on given parameters. See details at https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI- Parameters:
appName- - typically the ear name without the .ear - could be empty string when deploying just jar with EJBsmoduleName- - jar file name without trailing .jardistinctName- - AS7 allows each deployment to have an (optional) distinct name - could be empty string when not specifiedbeanName- - The EJB name which by default is the simple class name of the bean implementation classviewClassName- - the remote view is fully qualified class name of @Remote EJB interfaceisStateful- - if the bean is stateful set to true- Returns:
- - JNDI context string to use in your client JNDI lookup
-
createNamingContext
Helper to create InitialContext with necessary properties.- Returns:
- new InitialContext.
- Throws:
NamingException
-
switchIdentity
public static <T> T switchIdentity(String username, String password, Callable<T> callable) throws Exception Switch the user's identity using Elytron.- Type Parameters:
T- the result type of the callable task- Parameters:
username- the new usernamepassword- the new passwordcallable- the callable task to execute under the new identity- Returns:
- the result of the callable task
- Throws:
Exception- if an error occurs while switching the user's identity or if an error occurs while executing the callable task
-
switchIdentity
public static <T> T switchIdentity(String username, String password, Callable<T> callable, ClassLoader classLoader) throws Exception Switch the user's identity using Elytron.- Type Parameters:
T- the result type of the callable task- Parameters:
username- the new usernamepassword- the new passwordcallable- the callable task to execute under the new identityclassLoader- the class loader to use when checking for a security domain association- Returns:
- the result of the callable task
- Throws:
Exception- if an error occurs while switching the user's identity or if an error occurs while executing the callable task
-
switchIdentity
public static <T> T switchIdentity(String username, String password, Callable<T> callable, boolean validateException) throws Exception Switch the user's identity using Elytron.- Type Parameters:
T- the result type of the callable task- Parameters:
username- the new usernamepassword- the new passwordcallable- the callable task to execute under the new identityvalidateException- whether or not to validate an exception thrown by the callable taskuseClientLoginModule-trueifClientLoginModuleshould be used for legacy security,falseifSecurityClientFactoryshould be used for legacy security instead- Returns:
- the result of the callable task
- Throws:
Exception- if an error occurs while switching the user's identity or if an error occurs while executing the callable task
-
switchIdentity
public static <T> T switchIdentity(String username, String password, Callable<T> callable, boolean validateException, ClassLoader classLoader) throws Exception Switch the user's identity using Elytron.- Type Parameters:
T- the result type of the callable task- Parameters:
username- the new usernamepassword- the new passwordcallable- the callable task to execute under the new identityvalidateException- whether or not to validate an exception thrown by the callable taskfalseifSecurityClientFactoryshould be used for legacy security insteadclassLoader- the class loader to use when checking for a security domain association- Returns:
- the result of the callable task
- Throws:
Exception- if an error occurs while switching the user's identity or if an error occurs while executing the callable task
-
switchIdentitySCF
public static <T> T switchIdentitySCF(String username, String password, Callable<T> callable) throws Exception Switch the user's identity using Elytron.- Type Parameters:
T- the result type of the callable task- Parameters:
username- the new usernamepassword- the new passwordcallable- the callable task to execute under the new identity- Returns:
- the result of the callable task
- Throws:
Exception- if an error occurs while switching the user's identity or if an error occurs while executing the callable task
-