@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
WebApplicationContext ctx = WebApplicationContextUtils
.getWebApplicationContext(getServlet().getServletContext());
UserManagementService userManagementService = (UserManagementService) ctx.getBean("userManagementService");
// check if user needs to get his shared two-factor authorization secret
User loggedInUser = userManagementService.getUserByLogin(request.getRemoteUser());
if (loggedInUser.isTwoFactorAuthenticationEnabled() && loggedInUser.getTwoFactorAuthenticationSecret() == null) {
GoogleAuthenticator gAuth = new GoogleAuthenticator();
final GoogleAuthenticatorKey key = gAuth.createCredentials();
String sharedSecret = key.getKey();
loggedInUser.setTwoFactorAuthenticationSecret(sharedSecret);
userManagementService.saveUser(loggedInUser);
request.setAttribute("sharedSecret", sharedSecret);
String QRCode = GoogleAuthenticatorQRGenerator.getOtpAuthURL(null, "LAMS account: " + loggedInUser.getLogin(), key);
request.setAttribute("QRCode", QRCode);
}
return mapping.findForward("secret");
}
java类org.springframework.web.context.support.WebApplicationContextUtils的实例源码
TwoFactorAuthenticationAction.java 文件源码
项目:lams
阅读 17
收藏 0
点赞 0
评论 0
SpringCreator.java 文件源码
项目:parabuild-ci
阅读 22
收藏 0
点赞 0
评论 0
/**
* @return A found BeanFactory configuration
*/
private BeanFactory getBeanFactory()
{
// If someone has set a resource name then we need to load that.
if (configLocation != null && configLocation.length > 0)
{
log.info("Spring BeanFactory via ClassPathXmlApplicationContext using " + configLocation.length + "configLocations.");
return new ClassPathXmlApplicationContext(configLocation);
}
ServletContext srvCtx = WebContextFactory.get().getServletContext();
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
if (request != null)
{
return RequestContextUtils.getWebApplicationContext(request, srvCtx);
}
else
{
return WebApplicationContextUtils.getWebApplicationContext(srvCtx);
}
}
WebXBeanBrokerFactory.java 文件源码
项目:hevelian-activemq
阅读 21
收藏 0
点赞 0
评论 0
@Override
protected ApplicationContext createApplicationContext(String uri) throws MalformedURLException {
Resource resource = Utils.resourceFromString(uri);
LOG.debug("Using " + resource + " from " + uri);
try {
return new ResourceXmlApplicationContext(resource) {
@Override
protected ConfigurableEnvironment createEnvironment() {
return new ReversePropertySourcesStandardServletEnvironment();
}
@Override
protected void initPropertySources() {
WebApplicationContextUtils.initServletPropertySources(getEnvironment().getPropertySources(),
ServletContextHolder.getServletContext());
}
};
} catch (FatalBeanException errorToLog) {
LOG.error("Failed to load: " + resource + ", reason: " + errorToLog.getLocalizedMessage(), errorToLog);
throw errorToLog;
}
}
ContextLoaderListener.java 文件源码
项目:azeroth
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void contextInitialized(ServletContextEvent event) {
String serviceName = event.getServletContext().getInitParameter("appName");
System.setProperty("serviceName", serviceName == null ? "undefined" : serviceName);
super.contextInitialized(event);
WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext());
SpringInstanceProvider provider = new SpringInstanceProvider(applicationContext);
InstanceFactory.setInstanceProvider(provider);
}
EmailUserAction.java 文件源码
项目:lams
阅读 15
收藏 0
点赞 0
评论 0
private IUserManagementService getUserManagementService() {
if (EmailUserAction.userManagementService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
EmailUserAction.userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return EmailUserAction.userManagementService;
}
PortraitBatchUploadAction.java 文件源码
项目:lams
阅读 13
收藏 0
点赞 0
评论 0
private IUserManagementService getUserManagementService() {
if (userManagementService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return userManagementService;
}
AuthoringAction.java 文件源码
项目:lams
阅读 17
收藏 0
点赞 0
评论 0
private IMonitoringService getMonitoringService() {
if (AuthoringAction.monitoringService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
AuthoringAction.monitoringService = (IMonitoringService) ctx.getBean("monitoringService");
}
return AuthoringAction.monitoringService;
}
PublicApiWebScriptServlet.java 文件源码
项目:alfresco-remote-api
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void init() throws ServletException
{
super.init();
ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
container = (RuntimeContainer)context.getBean("publicapi.container");
apiAssistant = (ApiAssistant) context.getBean("apiAssistant");
}
HomeAction.java 文件源码
项目:lams
阅读 25
收藏 0
点赞 0
评论 0
private IGroupUserDAO getGroupUserDAO() {
if (HomeAction.groupUserDAO == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
HomeAction.groupUserDAO = (IGroupUserDAO) ctx.getBean("groupUserDAO");
}
return HomeAction.groupUserDAO;
}
AuthoringAction.java 文件源码
项目:lams
阅读 19
收藏 0
点赞 0
评论 0
public ILamsToolService getToolService() {
if (AuthoringAction.toolService == null) {
WebApplicationContext wac = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
AuthoringAction.toolService = (ILamsToolService) wac.getBean(AuthoringConstants.TOOL_SERVICE_BEAN_NAME);
}
return AuthoringAction.toolService;
}
LessonConditionsAction.java 文件源码
项目:lams
阅读 18
收藏 0
点赞 0
评论 0
private ISecurityService getSecurityService() {
if (LessonConditionsAction.securityService == null) {
WebApplicationContext webContext = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
LessonConditionsAction.securityService = (ISecurityService) webContext.getBean("securityService");
}
return LessonConditionsAction.securityService;
}
SecurityRequestPostProcessors.java 文件源码
项目:nixmash-blog
阅读 22
收藏 0
点赞 0
评论 0
private UsernamePasswordAuthenticationToken authentication(ServletContext servletContext) {
ApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
UserDetailsService userDetailsService = userDetailsService(context);
UserDetails userDetails = userDetailsService.loadUserByUsername(this.username);
return new UsernamePasswordAuthenticationToken(
userDetails, userDetails.getPassword(), userDetails.getAuthorities());
}
HomeAction.java 文件源码
项目:lams
阅读 26
收藏 0
点赞 0
评论 0
private ILearningDesignService getLearningDesignService() {
if (HomeAction.learningDesignService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
HomeAction.learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService");
}
return HomeAction.learningDesignService;
}
LearningAction.java 文件源码
项目:lams
阅读 34
收藏 0
点赞 0
评论 0
@Override
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
long toolSessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
WebApplicationContext wac = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
ILearnerService learnerService = (ILearnerService) wac.getBean("learnerService");
String finishURL = learnerService.completeToolSession(toolSessionId, user.getUserID().longValue());
return new RedirectingActionForward(finishURL);
}
CasEnvironmentContextListener.java 文件源码
项目:cas-server-4.2.1
阅读 17
收藏 0
点赞 0
评论 0
@Override
public void contextInitialized(final ServletContextEvent event) {
final ServletContext servletContext = event.getServletContext();
final ApplicationContext ctx =
WebApplicationContextUtils.getWebApplicationContext(servletContext);
LOGGER.info("[{}] has loaded the CAS servlet application context: {}",
servletContext.getServerInfo(), ctx);
}
AutoLoginFilter.java 文件源码
项目:sdudoc
阅读 17
收藏 0
点赞 0
评论 0
@Override
public void init(FilterConfig filterConfig) throws ServletException {
log.info("AutoLoginFilter Init");
//使用以下方式来完成userService的注入
ServletContext context = filterConfig.getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
userService = (UserService) ctx.getBean("userService");
}
CleanupPreviewLessonsAction.java 文件源码
项目:lams
阅读 20
收藏 0
点赞 0
评论 0
private IMonitoringService getMonitoringService() {
if (monitoringService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
monitoringService = (IMonitoringService) ctx.getBean("monitoringService");
}
return monitoringService;
}
GradebookServlet.java 文件源码
项目:lams
阅读 17
收藏 0
点赞 0
评论 0
private IntegrationService getIntegrationService() {
if (integrationService == null) {
integrationService = (IntegrationService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServletContext()).getBean("integrationService");
}
return integrationService;
}
EmailUserAction.java 文件源码
项目:lams
阅读 19
收藏 0
点赞 0
评论 0
private MessageService getMessageService() {
if (EmailUserAction.messageService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
EmailUserAction.messageService = (MessageService) ctx
.getBean(CentralConstants.CENTRAL_MESSAGE_SERVICE_BEAN_NAME);
}
return EmailUserAction.messageService;
}
TutorialAction.java 文件源码
项目:lams
阅读 14
收藏 0
点赞 0
评论 0
private IUserManagementService getService() {
if (TutorialAction.service == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
TutorialAction.service = (IUserManagementService) ctx.getBean("userManagementService");
}
return TutorialAction.service;
}
GradebookLearningAction.java 文件源码
项目:lams
阅读 18
收藏 0
点赞 0
评论 0
private ISecurityService getSecurityService() {
if (GradebookLearningAction.securityService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
GradebookLearningAction.securityService = (ISecurityService) ctx.getBean("securityService");
}
return GradebookLearningAction.securityService;
}
GradebookMonitoringAction.java 文件源码
项目:lams
阅读 17
收藏 0
点赞 0
评论 0
private IUserManagementService getUserService() {
if (GradebookMonitoringAction.userService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
GradebookMonitoringAction.userService = (IUserManagementService) ctx.getBean("userManagementService");
}
return GradebookMonitoringAction.userService;
}
HomeAction.java 文件源码
项目:lams
阅读 24
收藏 0
点赞 0
评论 0
private ILessonService getLessonService() {
if (HomeAction.lessonService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
HomeAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return HomeAction.lessonService;
}
GradebookMonitoringAction.java 文件源码
项目:lams
阅读 19
收藏 0
点赞 0
评论 0
private ISecurityService getSecurityService() {
if (GradebookMonitoringAction.securityService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
GradebookMonitoringAction.securityService = (ISecurityService) ctx.getBean("securityService");
}
return GradebookMonitoringAction.securityService;
}
GradebookAction.java 文件源码
项目:lams
阅读 21
收藏 0
点赞 0
评论 0
private IUserManagementService getUserService() {
if (GradebookAction.userService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
GradebookAction.userService = (IUserManagementService) ctx.getBean("userManagementService");
}
return GradebookAction.userService;
}
GradebookAction.java 文件源码
项目:lams
阅读 19
收藏 0
点赞 0
评论 0
private ILessonService getLessonService() {
if (GradebookAction.lessonService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
GradebookAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return GradebookAction.lessonService;
}
LDAPAuthenticator.java 文件源码
项目:lams
阅读 26
收藏 0
点赞 0
评论 0
public LDAPAuthenticator(IUserManagementService userManagementService) {
if (LDAPAuthenticator.userManagementService == null) {
LDAPAuthenticator.userManagementService = userManagementService;
}
if (LDAPAuthenticator.ldapService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getWebApplicationContext(SessionManager.getServletContext());
LDAPAuthenticator.ldapService = (ILdapService) ctx.getBean("ldapService");
}
}
CompleteActivityAction.java 文件源码
项目:lams
阅读 18
收藏 0
点赞 0
评论 0
private IntegrationService getIntegrationService() {
if (CompleteActivityAction.integrationService == null) {
CompleteActivityAction.integrationService = (IntegrationService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext()).getBean("integrationService");
}
return CompleteActivityAction.integrationService;
}
LamsAuthoringFinishAction.java 文件源码
项目:lams
阅读 18
收藏 0
点赞 0
评论 0
/**
* Get AuditService bean
*/
private IAuditService getAuditService() {
if (auditService == null) {
WebApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext(getServlet().getServletContext());
auditService = (IAuditService) ctx.getBean("auditService");
}
return auditService;
}
LessonManagerServlet.java 文件源码
项目:lams
阅读 22
收藏 0
点赞 0
评论 0
/**
* Initialization of the servlet. <br>
*
* @throws ServletException
* if an error occured
*/
@Override
public void init() throws ServletException {
integrationService = (IntegrationService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServletContext()).getBean("integrationService");
monitoringService = (IMonitoringService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServletContext()).getBean("monitoringService");
lessonService = (ILessonService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServletContext()).getBean("lessonService");
exportService = (IExportToolContentService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServletContext()).getBean("exportToolContentService");
toolService = (ILamsCoreToolService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServletContext()).getBean("lamsCoreToolService");
gradebookService = (IGradebookService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServletContext()).getBean("gradebookService");
userManagementService = (IUserManagementService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServletContext()).getBean("userManagementService");
securityService = (ISecurityService) WebApplicationContextUtils
.getRequiredWebApplicationContext(getServletContext()).getBean("securityService");
}