use of com.hack23.cia.model.internal.application.user.impl.UserAccount in project cia by Hack23.
the class SetGoogleAuthenticatorCredentialService method processService.
@Override
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
public SetGoogleAuthenticatorCredentialResponse processService(final SetGoogleAuthenticatorCredentialRequest serviceRequest) {
final SetGoogleAuthenticatorCredentialResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
LOGGER.info("{}:{}", serviceRequest.getClass().getSimpleName(), serviceRequest.getSessionId());
final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
final UserAccount userAccount = getUserAccountFromSecurityContext();
final SetGoogleAuthenticatorCredentialResponse response = new SetGoogleAuthenticatorCredentialResponse(ServiceResult.SUCCESS);
if (userAccount != null) {
eventRequest.setUserId(userAccount.getUserId());
final GoogleAuthenticator gAuth = new GoogleAuthenticator();
final GoogleAuthenticatorKey gKey = gAuth.createCredentials();
final UserAccount updateUserAccount = userDAO.load(userAccount.getHjid());
updateUserAccount.setGoogleAuthKey(gKey.getKey());
updateUserAccount.setGoogleAuthVerificationCode(gKey.getVerificationCode());
updateUserAccount.setGoogleAuthScratchCodes(gKey.getScratchCodes());
userDAO.merge(updateUserAccount);
final String otpAuthTotpURL = GoogleAuthenticatorQRGenerator.getOtpAuthTotpURL(agencyDAO.getAll().get(0).getAgencyName(), updateUserAccount.getEmail(), gKey);
response.setOtpAuthTotpURL(otpAuthTotpURL);
response.setGoogleAuthKey(gKey.getKey());
response.setGoogleAuthVerificationCode(gKey.getVerificationCode());
response.setGoogleAuthScratchCodes(gKey.getScratchCodes());
}
eventRequest.setApplicationMessage(response.getResult().toString());
createApplicationEventService.processService(eventRequest);
return response;
}
use of com.hack23.cia.model.internal.application.user.impl.UserAccount in project cia by Hack23.
the class UserHomeApplicationEventsPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
userHomeMenuItemFactory.createUserHomeMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, USER_EVENTS);
final Long userIdFromSecurityContext = UserContextUtil.getUserInternalIdFromSecurityContext();
if (userIdFromSecurityContext == null) {
UI.getCurrent().getNavigator().navigateTo(CommonsViews.MAIN_VIEW_NAME);
} else {
final DataContainer<UserAccount, Long> dataContainer = getApplicationManager().getDataContainer(UserAccount.class);
final UserAccount userAccount = dataContainer.load(userIdFromSecurityContext);
final DataContainer<ApplicationActionEvent, Long> eventDataContainer = getApplicationManager().getDataContainer(ApplicationActionEvent.class);
getGridFactory().createBasicBeanItemGrid(panelContent, ApplicationActionEvent.class, eventDataContainer.findOrderedListByProperty(ApplicationActionEvent_.userId, userAccount.getUserId(), ApplicationActionEvent_.createdDate), APPLICATION_ACTION_EVENT, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
}
panel.setCaption(NAME + "::" + USERHOME + USER_EVENTS);
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_USER_HOME_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
return panelContent;
}
use of com.hack23.cia.model.internal.application.user.impl.UserAccount in project cia by Hack23.
the class UserHomeApplicationSessionsPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
userHomeMenuItemFactory.createUserHomeMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, USER_VISITS);
final Long userIdFromSecurityContext = UserContextUtil.getUserInternalIdFromSecurityContext();
if (userIdFromSecurityContext == null) {
UI.getCurrent().getNavigator().navigateTo(CommonsViews.MAIN_VIEW_NAME);
} else {
final DataContainer<UserAccount, Long> dataContainer = getApplicationManager().getDataContainer(UserAccount.class);
final UserAccount userAccount = dataContainer.load(userIdFromSecurityContext);
final DataContainer<ApplicationSession, Long> sessionDataContainer = getApplicationManager().getDataContainer(ApplicationSession.class);
getGridFactory().createBasicBeanItemGrid(panelContent, ApplicationSession.class, sessionDataContainer.findOrderedListByProperty(ApplicationSession_.userId, userAccount.getUserId(), ApplicationSession_.createdDate), APPLICATION_SESSION, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, COLLECTION_PROPERTY_CONVERTERS);
}
panel.setCaption(NAME + "::" + USERHOME + USER_VISITS);
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_USER_HOME_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
return panelContent;
}
use of com.hack23.cia.model.internal.application.user.impl.UserAccount in project cia by Hack23.
the class UserHomeOverviewPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
userHomeMenuItemFactory.createUserHomeMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, OVERVIEW);
final Button logoutButton = new Button(LOGOUT, VaadinIcons.SIGN_OUT);
final LogoutRequest logoutRequest = new LogoutRequest();
logoutRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
logoutButton.addClickListener(new LogoutClickListener(logoutRequest));
panelContent.addComponent(logoutButton);
final DataContainer<UserAccount, Long> dataContainer = getApplicationManager().getDataContainer(UserAccount.class);
final Long userIdFromSecurityContext = UserContextUtil.getUserInternalIdFromSecurityContext();
if (userIdFromSecurityContext == null) {
UI.getCurrent().getNavigator().navigateTo(CommonsViews.MAIN_VIEW_NAME);
} else {
final UserAccount userAccount = dataContainer.load(userIdFromSecurityContext);
getFormFactory().addFormPanelTextFields(panelContent, userAccount, UserAccount.class, AS_LIST);
panelContent.setExpandRatio(logoutButton, ContentRatio.SMALL);
final VerticalLayout overviewLayout = new VerticalLayout();
overviewLayout.setSizeFull();
panelContent.addComponent(overviewLayout);
panelContent.setExpandRatio(overviewLayout, ContentRatio.LARGE_FORM);
userHomeMenuItemFactory.createOverviewPage(overviewLayout);
}
panel.setCaption(NAME + "::" + USERHOME);
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_USER_HOME_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
return panelContent;
}
Aggregations