A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Products
»
JBoss
Author
getcallerprincipal().getname()=anonymous jboss 7.1.1 as
Doan Long
Greenhorn
Joined: Jul 26, 2012
Posts: 20
posted
Oct 02, 2012 02:16:53
0
File .WAR
public String checkLogin() { try { ServiceLocator.setUserAndPass(username, password); imDelegate = Delegate.getService(IIdentityManager.class); } catch (Exception e) { e.printStackTrace(); } if (imDelegate.checkLogin("admin", "123")) { .................... } } private ServiceLocator() throws ServiceLocatorException { try { ResourceBundle resource = ResourcesFactory .getConfigResource(ResourcesFactory.CONFIG.JNDI); Properties p = new Properties(); earName = resource.getString("earName"); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); p.put(Context.PROVIDER_URL, "remote://localhost:4447"); p.put(Context.SECURITY_PRINCIPAL, user); p.put(Context.SECURITY_CREDENTIALS, pass); initialContext = new InitialContext(p); cache = Collections.synchronizedMap(new HashMap()); } catch (NamingException ex) { throw new ServiceLocatorException(ex); } catch (Exception ex) { throw new ServiceLocatorException(ex); } }
Run App call checkLogin();
File .EAR
@Stateless @SecurityDomain("FMISDomain") public class IdentityManagerFacade implements IIdentityManager, IIdentityManagerLocal { @Resource SessionContext sessionContext; @PersistenceContext(unitName = "FMIS2") private EntityManager entityManager; ........................... public boolean checkLogin(String user, String pass) { try { getUserID(); UserService userService = new UserService(entityManager); Users users = userService.getByUserAndPass(user, Security.calculateRFC2104HMAC(pass, Security.HMAC_KEY)); Security.setUser(user); iMasterdataLocal = (IMasterdataLocal) sessionContext .lookup(CommonUtil .getLocalFacadeName(IMasterdataLocal.class)); if (users != null) { userId = sessionContext.getCallerPrincipal().getName(); identityService = new IdentityService(entityManager, users.getId(), iLoggingFacade, iMasterdataLocal); identityService.refreshLoginUserInfo(); // GVariable.ID_MACOP = identityService.getIdMaCopForOwner(); return true; } else { return false; } } catch (Exception e) { e.printStackTrace(); throw CommonException.error(e, "facade.identitymanager.IdentityManagerFacade.checkLogin"); } } }
standalone.xml
<security-realm name="FMISRealm"> <authentication> <jaas name="FMISDomain"/> </authentication> </security-realm> <datasource jta="true" jndi-name="java:jboss/datasources/fmis2Datasource" pool-name="fmis2Datasource" enabled="true" use-java-context="true" use-ccm="true"> .................... </datasource> <subsystem xmlns="urn:jboss:domain:remoting:1.1"> <connector name="remoting-connector" socket-binding="remoting"/> </subsystem> <security-domain name="FMISDomain" cache-type="default"> <authentication> <login-module code="Remoting" flag="optional"> <module-option name="password-stacking" value="useFirstPass"/> </login-module> <login-module code="Database" flag="required"> <module-option name="dsJndiName" value="java:jboss/datasources/fmis2Datasource"/> <module-option name="principalsQuery" value="Select password_usr From im_users_usr Where blocked_usr = 0 And id_usr = ?"/> <module-option name="rolesQuery" value="Select user, Roles From im_users_usr Where id_usr = ?"/> <module-option name="password-stacking" value="useFirstPass"/> </login-module> </authentication> </security-domain>
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: getcallerprincipal().getname()=anonymous jboss 7.1.1 as
Similar Threads
auth-method none? for a JBoss simple SSO using digital signature?
Failed to setup EJB remote context using jboss 7.1.1
javax.naming.NameNotFoundException: ejb:fmis2-ear/ztest-ejb//ReportManagementFacade!remote
base64 encoding for digests
sessioncontext lookup local interface jboss 7.1.1
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter