Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JBoss/WildFly
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JBoss/WildFly
getcallerprincipal().getname()=anonymous jboss 7.1.1 as
Doan Long
Greenhorn
Posts: 20
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
sessioncontext lookup local interface jboss 7.1.1
javax.naming.NameNotFoundException: ejb:fmis2-ear/ztest-ejb//ReportManagementFacade!remote
Failed to setup EJB remote context using jboss 7.1.1
base64 encoding for digests
auth-method none? for a JBoss simple SSO using digital signature?
More...