List of usage examples for org.apache.shiro.authc.pam AtLeastOneSuccessfulStrategy AtLeastOneSuccessfulStrategy
AtLeastOneSuccessfulStrategy
From source file:com.yea.shiro.mgt.ShiroSecurityManager.java
License:Apache License
public ShiroSecurityManager() { super();//from w w w .j av a 2 s . c o m // authenticator ModularRealmAuthenticator authenticator = new ModularRealmAuthenticator(); authenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy()); setAuthenticator(authenticator); // authorizer ModularRealmAuthorizer authorizer = new ModularRealmAuthorizer(); authorizer.setPermissionResolver(new WildcardPermissionResolver()); setAuthorizer(authorizer); // ?Matcher credentialsMatcher = new RetryLimitHashedCredentialsMatcher(); credentialsMatcher.setHashAlgorithmName(EncrytPassword.PASSWORD_HASH); credentialsMatcher.setHashIterations(EncrytPassword.HASH_ITERATIONS); credentialsMatcher.setStoredCredentialsHexEncoded(true); }
From source file:com.yea.shiro.web.mgt.WebSecurityManager.java
License:Apache License
public WebSecurityManager() { super();/*from w w w . j av a2 s. c om*/ // authenticator ModularRealmAuthenticator authenticator = new ModularRealmAuthenticator(); authenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy()); setAuthenticator(authenticator); // authorizer ModularRealmAuthorizer authorizer = new ModularRealmAuthorizer(); authorizer.setPermissionResolver(new WildcardPermissionResolver()); setAuthorizer(authorizer); // ?Matcher credentialsMatcher = new RetryLimitHashedCredentialsMatcher(); credentialsMatcher.setHashAlgorithmName(EncrytPassword.PASSWORD_HASH); credentialsMatcher.setHashIterations(EncrytPassword.HASH_ITERATIONS); credentialsMatcher.setStoredCredentialsHexEncoded(true); }
From source file:de.lemo.apps.pages.Start.java
License:Open Source License
public Object onSubmitFromLoginForm() { try {// w w w . j a v a 2 s . co m AuthenticationStrategy authenticationStrategy = new AtLeastOneSuccessfulStrategy(); this.modularRealmAuthenticator.setAuthenticationStrategy(authenticationStrategy); final Subject currentUser = this.securityService.getSubject(); if (currentUser == null) { throw new IllegalStateException("Error during login. Can't obtain user from security service."); } final UsernamePasswordToken token = new UsernamePasswordToken(this.username, this.password); this.logger.debug("Prepare Logintoken. Username: " + this.username); currentUser.login(token); if (!userDAO.doExist(this.username)) { try { this.logger .debug("Login: The user " + username + " doesn't exist locally. And will be created."); addCourses(); } catch (Exception e) { logger.debug("Login: Can't create user. " + e.getMessage()); } } } catch (AuthenticationException ex) { this.logger.info("Login unsuccessful."); this.loginForm.recordError(this.messages.get("error.login")); this.alertManager.info("Login or password not correct."); /* * If user authentification fails we will start a lookup to check whether this username is known by the dms */ if (!userDAO.doExist(this.username)) { ResultListLongObject result = null; try { result = init.identifyUserName(this.username); } catch (RestServiceCommunicationException e) { logger.error(e.getMessage()); } if (result != null && result.getElements() != null && result.getElements().size() > 0) { Long dmsUserId = result.getElements().get(result.getElements().size() - 1); logger.debug("Corresponding LeMo user ID : " + dmsUserId); registerPage.setDmsUserId(dmsUserId); registerPage.setDmsUserName(this.username); return registerPage; } else { return Start.class; } } else return Start.class; } return this.pageService.getSuccessPage(); }