diff --git a/account-ui/pom.xml b/account-ui/pom.xml
index 03293bc..bcae1a2 100644
--- a/account-ui/pom.xml
+++ b/account-ui/pom.xml
@@ -1,140 +1,145 @@
-
-
- 4.0.0
-
- shared
- de.muehlencord
- 1.1-SNAPSHOT
-
-
- de.muehlencord.shared
- shared-account-ui
- 1.1-SNAPSHOT
- war
-
- shared-account-ui
-
-
- UTF-8
- ${maven.build.timestamp}
- 10
- 10
-
-
- development
-
-
-
-
- org.primefaces
- primefaces
-
-
-
- com.github.adminfaces
- admin-template
- 1.0.0-RC19
-
-
-
- org.omnifaces
- omnifaces
- 2.7
-
-
-
- org.apache.shiro
- shiro-core
-
-
- org.apache.shiro
- shiro-web
-
-
- de.muehlencord.shared
- shared-shiro-faces
- 1.1-SNAPSHOT
-
-
- de.muehlencord.shared
- shared-account
- 1.1-SNAPSHOT
- jar
-
-
- de.muehlencord.sf
- filter
- 1.0
-
-
- javax
- javaee-web-api
- 7.0
- provided
-
-
-
-
-
- ${basedir}/src/main/filters/${filter.name}.properties
-
-
-
-
-
- src/main/resources
- true
-
- **/*.properties
-
-
-
-
- account
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
- 10
- 10
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
- 3.2.2
-
- false
-
-
- ${basedir}/src/main/webapp
- true
-
- WEB-INF/web.xml
- WEB-INF/shiro.ini
-
-
-
-
-
-
-
-
-
-
- development
-
- development
-
-
-
-
- production
-
- production
-
-
-
-
+
+
+ 4.0.0
+
+ shared
+ de.muehlencord
+ 1.1-SNAPSHOT
+
+
+ de.muehlencord.shared
+ shared-account-ui
+ 1.1-SNAPSHOT
+ war
+
+ shared-account-ui
+
+
+ UTF-8
+ ${maven.build.timestamp}
+ 10
+ 10
+
+
+ development
+
+
+
+
+ org.primefaces
+ primefaces
+
+
+
+ com.github.adminfaces
+ admin-template
+ 1.0.0-RC19
+
+
+
+ org.omnifaces
+ omnifaces
+ 2.7
+
+
+
+ org.apache.shiro
+ shiro-core
+
+
+ org.apache.shiro
+ shiro-web
+
+
+ de.muehlencord.shared
+ shared-shiro-faces
+ 1.1-SNAPSHOT
+
+
+ de.muehlencord.shared
+ shared-account
+ 1.1-SNAPSHOT
+
+
+ de.muehlencord.shared
+ shared-util
+ 1.1-SNAPSHOT
+
+
+ de.muehlencord.sf
+ filter
+ 1.0
+
+
+ javax
+ javaee-web-api
+ 7.0
+ provided
+
+
+
+
+
+ ${basedir}/src/main/filters/${filter.name}.properties
+
+
+
+
+
+ src/main/resources
+ true
+
+ **/*.properties
+ **/*.xml
+
+
+
+
+ account
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+ 10
+ 10
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 3.2.2
+
+ false
+
+
+ ${basedir}/src/main/webapp
+ true
+
+ WEB-INF/web.xml
+ WEB-INF/shiro.ini
+
+
+
+
+
+
+
+
+
+
+ development
+
+ development
+
+
+
+
+ production
+
+ production
+
+
+
+
diff --git a/account-ui/src/main/java/de/muehlencord/shared/account/web/ApplicationProducer.java b/account-ui/src/main/java/de/muehlencord/shared/account/web/ApplicationProducer.java
new file mode 100644
index 0000000..f6c4239
--- /dev/null
+++ b/account-ui/src/main/java/de/muehlencord/shared/account/web/ApplicationProducer.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2018 Joern Muehlencord .
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package de.muehlencord.shared.account.web;
+
+import de.muehlencord.shared.account.business.application.boundary.ApplicationService;
+import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
+import java.util.UUID;
+import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author Joern Muehlencord
+ */
+@Named("applicationProdiucer")
+@ApplicationScoped
+public class ApplicationProducer {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationProducer.class);
+
+ @EJB
+ ApplicationService applicationService;
+
+ private ApplicationEntity application = null;
+
+ @PostConstruct
+ public void init() {
+ String id = "143a2bd3-7e0b-4162-a76e-3031331c7dfe"; // TODO load from properties file
+ this.application = applicationService.findById(UUID.fromString(id));
+ if (application == null) {
+ LOGGER.error("Could not find application with id ");
+ } else {
+ LOGGER.info("Found application {} for id{}", application.getApplicationName(), id);
+ }
+ }
+
+ /**
+ * needs to return link to "Account UI" and not to current selected
+ * application TODO: ensure only Account UI can call functions where
+ * appliction can be handed in all other applications need to call the
+ * function which use the injected application
+ */
+ @Produces
+ public ApplicationEntity getApplication() {
+ return application;
+
+ }
+
+}
diff --git a/account-ui/src/main/java/de/muehlencord/shared/account/web/presentation/AccountView.java b/account-ui/src/main/java/de/muehlencord/shared/account/web/presentation/AccountView.java
index beff1b7..94e2695 100644
--- a/account-ui/src/main/java/de/muehlencord/shared/account/web/presentation/AccountView.java
+++ b/account-ui/src/main/java/de/muehlencord/shared/account/web/presentation/AccountView.java
@@ -1,186 +1,300 @@
-package de.muehlencord.shared.account.web.presentation;
-
-import de.muehlencord.shared.account.business.account.boundary.AccountControl;
-import de.muehlencord.shared.account.business.account.boundary.ApplicationRoleControl;
-import de.muehlencord.shared.account.business.account.entity.AccountEntity;
-import de.muehlencord.shared.account.business.account.entity.AccountException;
-import de.muehlencord.shared.account.business.account.entity.AccountStatus;
-import de.muehlencord.shared.account.business.account.entity.ApplicationRoleEntity;
-import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
-import de.muehlencord.shared.jeeutil.FacesUtil;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import javax.ejb.EJB;
-import javax.faces.view.ViewScoped;
-import javax.inject.Named;
-import javax.inject.Inject;
-import org.primefaces.event.SelectEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- * @author jomu
- */
-@ViewScoped
-@Named("accountView")
-public class AccountView implements Serializable {
-
- private static final long serialVersionUID = -8050582392249849438L;
- private static final Logger LOGGER = LoggerFactory.getLogger(AccountView.class);
-
- @Inject
- private ApplicationView applicationView;
- @EJB
- private AccountControl accountService;
- @EJB
- private ApplicationRoleControl appliationRoleService;
-
- /**
- * boolean flag to determine wether disabled accounts should be shown
- * accounts are not deleted but disabled and can be activated in case
- */
- private boolean showDisabledAccounts = false;
-
- // cached accounts
- private List accountList = null;
- // cached application roles
- private List applicationRoles = null;
-
- // account currently on edit
- private AccountEntity currentAccount;
- private List currentAccountRoles = null;
-
- public List getAccounts() {
- if (accountList == null) {
- accountList = accountService.getAccounts(showDisabledAccounts);
- }
- return accountList;
- }
-
- public List getAllApplicationRoles() {
- if (applicationRoles == null) {
- ApplicationEntity application = applicationView.getCurrentApplication();
- applicationRoles = appliationRoleService.getAllRoles(application);
- }
- return applicationRoles;
- }
-
- public void selectAccount(SelectEvent event) {
- if (currentAccount == null) {
- applicationRoles = null;
- currentAccountRoles = null;
- }
- }
-
- public boolean getAccountSelected() {
- return currentAccount != null;
- }
-
- public void newAccount() {
- currentAccount = new AccountEntity();
- currentAccount.setUsername(null);
- currentAccount.setStatus("NEW"); // TODO add status enum
- currentAccountRoles = new ArrayList<>();
- }
-
- public void editAccount() {
- // function called by webpage
- if (currentAccount == null) {
- currentAccountRoles = null;
- } else {
- currentAccount = accountService.getAccountEntity(currentAccount.getUsername(), true);
- this.currentAccountRoles = new ArrayList<>();
- if (currentAccount.getApplicationRoleList() != null) {
- currentAccountRoles.addAll(currentAccount.getApplicationRoleList());
- }
- }
- }
-
- public void cancelEditAccount() {
- currentAccount = null;
- currentAccountRoles = null;
- }
-
- public void saveEditAccount() {
- String username = currentAccount.getUsername();
- AccountEntity existingEntity = accountService.getAccountEntity(username, true);
- // check if it is a new user (createdBy == null) but a user with same name already exists
- if ((currentAccount.getCreatedBy() == null) && (existingEntity != null)) {
- currentAccount.setUsername(null);
- FacesUtil.addErrorMessage("editDialogMessaegs", "Create new account failed", "Account with username " + username + " already exists");
- } else {
- accountService.saveAccount(applicationView.getCurrentApplication(), currentAccount, currentAccountRoles);
- if (currentAccount.getId() == null) {
- // this was a new account
- // force accounts to be loaded from database again
- accountList = null;
- }
- }
- }
-
- public void deleteAccount() {
- try {
- accountService.deleteAccount(currentAccount);
- accountList.remove(currentAccount);
- FacesUtil.addGlobalInfoMessage("Info", "Account " + currentAccount.getUsername() + " deleted");
- currentAccount = null;
- currentAccountRoles = null;
- } catch (AccountException ex) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug(ex.toString(), ex);
- } else {
- LOGGER.error(ex.toString());
- }
-
- FacesUtil.addGlobalErrorMessage("Error deleting account", ex.getMessage());
- }
- }
-
- public void showDisabledAccountsChange() {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("show diabled accounts changed to {}", showDisabledAccounts);
- }
- this.accountList = null;
- }
-
- public List getStatusList() {
- return AccountStatus.getAllStatusNames();
- }
-
- /* **** getter / setter **** */
- /**
- * setter for managed property applicationView
- *
- * @param applicationView the applicaton view to inject
- */
- public void setApplicationView(ApplicationView applicationView) {
- this.applicationView = applicationView;
- }
-
- public AccountEntity getCurrentAccount() {
- return currentAccount;
- }
-
- public void setCurrentAccount(AccountEntity currentAccount) {
- this.currentAccount = currentAccount;
- }
-
- public boolean isShowDisabledAccounts() {
- return showDisabledAccounts;
- }
-
- public void setShowDisabledAccounts(boolean showDisabledAccounts) {
- this.showDisabledAccounts = showDisabledAccounts;
- }
-
- public List getCurrentAccountRoles() {
- return currentAccountRoles;
- }
-
- public void setCurrentAccountRoles(List currentAccountRoles) {
- this.currentAccountRoles = currentAccountRoles;
- }
-
-}
+package de.muehlencord.shared.account.web.presentation;
+
+import de.muehlencord.shared.account.business.account.boundary.AccountControl;
+import de.muehlencord.shared.account.business.account.boundary.ApplicationRoleControl;
+import de.muehlencord.shared.account.business.account.entity.AccountEntity;
+import de.muehlencord.shared.account.business.account.entity.AccountException;
+import de.muehlencord.shared.account.business.account.entity.AccountLoginEntity;
+import de.muehlencord.shared.account.business.account.entity.AccountStatus;
+import de.muehlencord.shared.account.business.account.entity.ApplicationRoleEntity;
+import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
+import de.muehlencord.shared.jeeutil.FacesUtil;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import javax.ejb.EJB;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.view.ViewScoped;
+import javax.inject.Named;
+import javax.inject.Inject;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.subject.Subject;
+import org.primefaces.event.SelectEvent;
+import org.primefaces.event.UnselectEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author jomu
+ */
+@ViewScoped
+@Named("accountView")
+public class AccountView implements Serializable {
+
+ private static final long serialVersionUID = -8050582392249849438L;
+ private static final Logger LOGGER = LoggerFactory.getLogger(AccountView.class);
+
+ @Inject
+ private ApplicationView applicationView;
+ @EJB
+ private AccountControl accountService;
+ @EJB
+ private ApplicationRoleControl appliationRoleService;
+
+ /**
+ * boolean flag to determine wether disabled accounts should be shown
+ * accounts are not deleted but disabled and can be activated in case
+ */
+ private boolean showDisabledAccounts = false;
+
+ // cached accounts
+ private List accountList = null;
+ // cached application roles
+ private List applicationRoles = null;
+
+ // account currently on edit
+ private AccountEntity currentAccount;
+ private List currentAccountRoles = null;
+ private AccountLoginEntity currentAccountLogin;
+ private String password = null;
+ private String repeatPassword = null;
+
+ public List getAccounts() {
+ if (accountList == null) {
+ accountList = accountService.getAccounts(showDisabledAccounts);
+ }
+ return accountList;
+ }
+
+ public List getAllApplicationRoles() {
+ if (applicationRoles == null) {
+ ApplicationEntity application = applicationView.getCurrentApplication();
+ applicationRoles = appliationRoleService.getAllRoles(application);
+ }
+ return applicationRoles;
+ }
+
+ public void selectAccount(SelectEvent event) {
+ // nothing to do, currentAccountRoles are loaded before dialog is shown
+ }
+
+ public void unselectAccount(UnselectEvent event) {
+ applicationRoles = null;
+ currentAccountRoles = null;
+ }
+
+ public boolean getAccountSelected() {
+ return currentAccount != null;
+ }
+
+ public void newAccount() {
+ currentAccount = new AccountEntity();
+ currentAccount.setStatus("NEW"); // TODO add status enum
+ currentAccountRoles = new ArrayList<>();
+ }
+
+ public void editAccount() {
+ // function called by webpage
+ if (currentAccount == null) {
+ currentAccountRoles = null;
+ } else {
+ currentAccount = accountService.getAccountEntity(currentAccount.getUsername(), true);
+ this.currentAccountRoles = new ArrayList<>();
+ if (currentAccount.getApplicationRoleList() != null) {
+ currentAccountRoles.addAll(currentAccount.getApplicationRoleList());
+ }
+ }
+ }
+
+ public void cancelEditAccount() {
+ currentAccount = null;
+ currentAccountRoles = null;
+ }
+
+ public void saveEditAccount() {
+ String username = currentAccount.getUsername();
+ AccountEntity existingEntity = accountService.getAccountEntity(username, true);
+ // check if it is a new user (createdBy == null) but a user with same name already exists
+ if ((currentAccount.getCreatedBy() == null) && (existingEntity != null)) {
+ FacesUtil.addErrorMessage("editDialogMessaegs", "Create new account failed", "Account with username " + username + " already exists");
+ } else {
+ accountService.saveAccount(currentAccount, currentAccountRoles);
+ // force accounts to be loaded from database again
+ accountList = null;
+
+ }
+ }
+
+ public void deleteAccount() {
+ try {
+ accountService.deleteAccount(currentAccount);
+ accountList.remove(currentAccount);
+ FacesUtil.addGlobalInfoMessage("Info", "Account " + currentAccount.getUsername() + " deleted");
+ currentAccount = null;
+ currentAccountRoles = null;
+ } catch (AccountException ex) {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(ex.toString(), ex);
+ } else {
+ LOGGER.error(ex.toString());
+ }
+
+ FacesUtil.addGlobalErrorMessage("Error deleting account", ex.getMessage());
+ }
+ }
+
+ public void showDisabledAccountsChange() {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("show diabled accounts changed to {}", showDisabledAccounts);
+ }
+ this.accountList = null;
+ }
+
+ public List getStatusList() {
+ return AccountStatus.getAllStatusNames();
+ }
+
+ /* **** account login methods **** */
+ public boolean validatePasswords(FacesContext context, List components, List