Issue #1412 User Admin dialog should refresh with changes made to authentication data

Change-Id: I407dc061a50bf30cb2b37a5fa3b1fe8c5e63ce23

Former-commit-id: bad7b754e5 [formerly b7ed75896b] [formerly bad7b754e5 [formerly b7ed75896b] [formerly a354bac4da [formerly 5e89b4f6c1cbb9db68b5ac185ba09ca5a6543e3b]]]
Former-commit-id: a354bac4da
Former-commit-id: 424a70dbfe [formerly 0d5bb5ba95]
Former-commit-id: 09a33ab8ac
This commit is contained in:
Dustin Johnson 2013-01-09 13:15:04 -06:00
parent 1b9a9383c1
commit d4d1a95461
20 changed files with 796 additions and 248 deletions

View file

@ -19,33 +19,24 @@
**/ **/
package com.raytheon.uf.viz.plugin.nwsauth; package com.raytheon.uf.viz.plugin.nwsauth;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.xml.bind.JAXBContext; import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import com.raytheon.uf.common.auth.user.IPermission; import com.raytheon.uf.common.auth.user.IPermission;
import com.raytheon.uf.common.auth.user.IRole; import com.raytheon.uf.common.auth.user.IRole;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
import com.raytheon.uf.common.plugin.nwsauth.NwsPermission; import com.raytheon.uf.common.plugin.nwsauth.NwsPermission;
import com.raytheon.uf.common.plugin.nwsauth.NwsRole; import com.raytheon.uf.common.plugin.nwsauth.NwsRole;
import com.raytheon.uf.common.plugin.nwsauth.NwsRoleDataRequest;
import com.raytheon.uf.common.plugin.nwsauth.NwsRoleDataRequest.NwsRoleDataRequestType;
import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData; import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData;
import com.raytheon.uf.common.plugin.nwsauth.xml.PermissionXML; import com.raytheon.uf.common.plugin.nwsauth.xml.PermissionXML;
import com.raytheon.uf.common.plugin.nwsauth.xml.RoleXML; import com.raytheon.uf.common.plugin.nwsauth.xml.RoleXML;
import com.raytheon.uf.common.plugin.nwsauth.xml.UserXML; import com.raytheon.uf.common.plugin.nwsauth.xml.UserXML;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.status.UFStatus.Priority;
@ -61,6 +52,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* May 30, 2012 mpduff Initial creation * May 30, 2012 mpduff Initial creation
* Nov 06, 2012 1302 djohnson Move to nwsauth plugin. * Nov 06, 2012 1302 djohnson Move to nwsauth plugin.
* Jan 09, 2013 1412 djohnson Move localization file writing to the server.
* *
* </pre> * </pre>
* *
@ -68,34 +60,17 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* @version 1.0 * @version 1.0
*/ */
public class FileManager { public class NwsRoleDataManager {
/** Status handler */ /** Status handler */
private static final IUFStatusHandler statusHandler = UFStatus private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(FileManager.class); .getHandler(NwsRoleDataManager.class);
private static final FileManager instance = new FileManager(); private static final NwsRoleDataManager instance = new NwsRoleDataManager();
private final String ROLE_DIR = "roles"; private Map<String, NwsRoleData> roleDataMap = new HashMap<String, NwsRoleData>();
/** JAXB context */ private NwsRoleDataManager() {
private JAXBContext jax; retrieveRoleDataFromServer();
/** Marshaller object */
private Marshaller marshaller;
/** Unmarshaller object */
private Unmarshaller unmarshaller;
private final Map<String, NwsRoleData> roleDataMap = new HashMap<String, NwsRoleData>();
/**
* Application name -> LocalizationFile map.
*/
private final Map<String, LocalizationFile> roleFileMap = new HashMap<String, LocalizationFile>();
private FileManager() {
createContext();
readXML();
} }
/** /**
@ -103,28 +78,10 @@ public class FileManager {
* *
* @return an instance * @return an instance
*/ */
public static FileManager getInstance() { public static NwsRoleDataManager getInstance() {
return instance; return instance;
} }
private void createContext() {
@SuppressWarnings("rawtypes")
Class[] classes = new Class[] { NwsRoleData.class, PermissionXML.class,
RoleXML.class, UserXML.class };
try {
jax = JAXBContext.newInstance(classes);
this.unmarshaller = jax.createUnmarshaller();
this.marshaller = jax.createMarshaller();
// format the output xml file
this.marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
} catch (JAXBException e) {
e.printStackTrace();
}
}
/** /**
* Get the NwsRoleData object. * Get the NwsRoleData object.
* *
@ -318,65 +275,54 @@ public class FileManager {
} }
/** /**
* Save the NwsRoleData object. * {@inheritDoc}
*
* @param application
*/ */
public void save(String application) { public void save(String application) {
NwsRoleData roleData = roleDataMap.get(application); updateRoleDataOnTheServer(application);
LocalizationFile lf = roleFileMap.get(application);
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
LocalizationFile locFile = pm
.getLocalizationFile(context, lf.getName());
;
try {
marshaller.marshal(roleData, locFile.getFile());
locFile.save();
} catch (JAXBException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} catch (LocalizationOpFailedException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
} }
private void readXML() { /**
try { * Updates the role data on the server.
IPathManager pm = PathManagerFactory.getPathManager(); *
LocalizationContext[] contexts = new LocalizationContext[2]; * @param application
contexts[0] = pm.getContext(LocalizationType.COMMON_STATIC, * the application to send updated role data for
LocalizationLevel.BASE); */
contexts[1] = pm.getContext(LocalizationType.COMMON_STATIC, private void updateRoleDataOnTheServer(String application) {
LocalizationLevel.SITE); Map<String, NwsRoleData> roleDataMapUpdates = new HashMap<String, NwsRoleData>();
LocalizationFile[] roleFiles = pm.listFiles(contexts, ROLE_DIR, roleDataMapUpdates.put(application, roleDataMap.get(application));
null, false, true);
for (LocalizationFile lf : roleFiles) { NwsRoleDataRequest request = new NwsRoleDataRequest();
File f = lf.getFile(true); request.setRoleDataMap(roleDataMapUpdates);
if (f != null && f.exists()) { request.setType(NwsRoleDataRequestType.SUBMIT);
System.out.println(f.getAbsolutePath()); try {
NwsRoleData roleData = (NwsRoleData) unmarshaller RequestRouter.route(request);
.unmarshal(f); } catch (Exception e) {
this.roleDataMap.put(roleData.getApplication(), roleData);
this.roleFileMap.put(roleData.getApplication(), lf);
}
}
} catch (JAXBException e1) {
statusHandler statusHandler
.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1); .handle(Priority.PROBLEM,
"Unable to send updated role data to the server.",
e);
}
}
private void retrieveRoleDataFromServer() {
try {
NwsRoleDataRequest request = new NwsRoleDataRequest();
request.setType(NwsRoleDataRequestType.REQUEST);
NwsRoleDataRequest response = (NwsRoleDataRequest) ((SuccessfulExecution) RequestRouter
.route(request)).getResponse();
this.roleDataMap = response.getRoleDataMap();
} catch (Exception e) { } catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} }
} }
/** /**
* Reload theXML files from disk. * Reload theXML files from disk.
*/ */
public void reloadXML() { public void reloadRoleData() {
readXML(); retrieveRoleDataFromServer();
} }
} }

View file

@ -88,7 +88,7 @@ public class NwsUserManager implements IUserManager {
@Override @Override
public List<IPermission> getPermissions(String application) { public List<IPermission> getPermissions(String application) {
// TODO: Should this pass through to EDEX to get this stuff? // TODO: Should this pass through to EDEX to get this stuff?
return FileManager.getInstance().getPermissions(application); return NwsRoleDataManager.getInstance().getPermissions(application);
} }
/** /**
@ -97,6 +97,6 @@ public class NwsUserManager implements IUserManager {
@Override @Override
public List<IRole> getRoles(String application) { public List<IRole> getRoles(String application) {
// TODO: Should this pass through to EDEX to get this stuff? // TODO: Should this pass through to EDEX to get this stuff?
return FileManager.getInstance().getRoles(application); return NwsRoleDataManager.getInstance().getRoles(application);
} }
} }

View file

@ -36,7 +36,7 @@ import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData; import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData;
import com.raytheon.uf.common.plugin.nwsauth.xml.RoleXML; import com.raytheon.uf.common.plugin.nwsauth.xml.RoleXML;
import com.raytheon.uf.common.plugin.nwsauth.xml.UserXML; import com.raytheon.uf.common.plugin.nwsauth.xml.UserXML;
import com.raytheon.uf.viz.plugin.nwsauth.FileManager; import com.raytheon.uf.viz.plugin.nwsauth.NwsRoleDataManager;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.widgets.duallist.DualList; import com.raytheon.viz.ui.widgets.duallist.DualList;
import com.raytheon.viz.ui.widgets.duallist.DualListConfig; import com.raytheon.viz.ui.widgets.duallist.DualListConfig;
@ -66,10 +66,10 @@ public class ManageUserDlg extends CaveSWTDialog implements IUpdate {
private final StackLayout stackLayout = new StackLayout(); private final StackLayout stackLayout = new StackLayout();
/** Type of permissions */ /** Type of permissions */
private String type; private final String type;
/** Selection */ /** Selection */
private String selection; private final String selection;
/** Edit combo box */ /** Edit combo box */
private Combo editCbo; private Combo editCbo;
@ -87,7 +87,7 @@ public class ManageUserDlg extends CaveSWTDialog implements IUpdate {
private Composite stackComp; private Composite stackComp;
/** The application currently selected.*/ /** The application currently selected.*/
private String application; private final String application;
/** /**
* Constructor. * Constructor.
@ -165,7 +165,7 @@ public class ManageUserDlg extends CaveSWTDialog implements IUpdate {
stackComp = new Composite(shell, SWT.NONE); stackComp = new Composite(shell, SWT.NONE);
stackComp.setLayout(stackLayout); stackComp.setLayout(stackLayout);
FileManager manager = FileManager.getInstance(); NwsRoleDataManager manager = NwsRoleDataManager.getInstance();
ArrayList<String> selectedList = new ArrayList<String>(); ArrayList<String> selectedList = new ArrayList<String>();
ArrayList<String> fullList = new ArrayList<String>(); ArrayList<String> fullList = new ArrayList<String>();
String availableLabel = "Available Roles:"; String availableLabel = "Available Roles:";
@ -291,7 +291,7 @@ public class ManageUserDlg extends CaveSWTDialog implements IUpdate {
String[] permissions = permDualList.getSelectedListItems(); String[] permissions = permDualList.getSelectedListItems();
String[] roles = roleDualList.getSelectedListItems(); String[] roles = roleDualList.getSelectedListItems();
FileManager man = FileManager.getInstance(); NwsRoleDataManager man = NwsRoleDataManager.getInstance();
NwsRoleData roleData = man.getRoleData(application); NwsRoleData roleData = man.getRoleData(application);
if (type.equalsIgnoreCase("User")) { if (type.equalsIgnoreCase("User")) {

View file

@ -31,7 +31,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData; import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData;
import com.raytheon.uf.viz.plugin.nwsauth.FileManager; import com.raytheon.uf.viz.plugin.nwsauth.NwsRoleDataManager;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/** /**
@ -52,13 +52,13 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*/ */
public class NewDlg extends CaveSWTDialog { public class NewDlg extends CaveSWTDialog {
private String type; private final String type;
private Text newTextField; private Text newTextField;
private Text description; private Text description;
private String application; private final String application;
/** /**
* Constructor. * Constructor.
@ -154,7 +154,7 @@ public class NewDlg extends CaveSWTDialog {
private void handleOK() { private void handleOK() {
if (newTextField.getText() != null && newTextField.getText().length() > 0) { if (newTextField.getText() != null && newTextField.getText().length() > 0) {
FileManager manager = FileManager.getInstance(); NwsRoleDataManager manager = NwsRoleDataManager.getInstance();
NwsRoleData roleData = manager.getRoleData(application); NwsRoleData roleData = manager.getRoleData(application);
if (type.equalsIgnoreCase("User")) { if (type.equalsIgnoreCase("User")) {
roleData.addUser(newTextField.getText().trim()); roleData.addUser(newTextField.getText().trim());

View file

@ -22,6 +22,8 @@ package com.raytheon.uf.viz.useradmin.ui;
import java.util.ArrayList; import java.util.ArrayList;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseListener;
@ -43,28 +45,35 @@ import org.eclipse.swt.widgets.TabItem;
import com.raytheon.uf.common.plugin.nwsauth.xml.PermissionXML; import com.raytheon.uf.common.plugin.nwsauth.xml.PermissionXML;
import com.raytheon.uf.common.plugin.nwsauth.xml.RoleXML; import com.raytheon.uf.common.plugin.nwsauth.xml.RoleXML;
import com.raytheon.uf.viz.plugin.nwsauth.FileManager; import com.raytheon.uf.common.useradmin.request.UserAdminConstants;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.notification.INotificationObserver;
import com.raytheon.uf.viz.core.notification.NotificationMessage;
import com.raytheon.uf.viz.core.notification.jobs.NotificationManagerJob;
import com.raytheon.uf.viz.plugin.nwsauth.NwsRoleDataManager;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog; import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/** /**
* Main User Administration Dialog. * Main User Administration Dialog.
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* May 23, 2012 mpduff Initial creation. * May 23, 2012 mpduff Initial creation.
* Nov 26, 2012 1347 mpduff Make resizable. * Nov 26, 2012 1347 mpduff Make resizable.
* * Jan 09, 2013 1412 djohnson Listen for user authentication data changes.
*
* </pre> * </pre>
* *
* @author mpduff * @author mpduff
* @version 1.0 * @version 1.0
*/ */
public class UserAdminSelectDlg extends CaveSWTDialog { public class UserAdminSelectDlg extends CaveSWTDialog implements
INotificationObserver {
private Combo appCombo; private Combo appCombo;
private TabFolder tabFolder; private TabFolder tabFolder;
@ -95,18 +104,19 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
/** /**
* Constructor. * Constructor.
* *
* @param parent * @param parent
* The parent shell * The parent shell
*/ */
public UserAdminSelectDlg(Shell parent) { public UserAdminSelectDlg(Shell parent) {
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.PERSPECTIVE_INDEPENDENT); super(parent, SWT.DIALOG_TRIM | SWT.RESIZE,
CAVE.PERSPECTIVE_INDEPENDENT);
setText("User Admin"); setText("User Admin");
} }
@Override @Override
protected void initializeComponents(Shell shell) { protected void initializeComponents(Shell shell) {
FileManager man = FileManager.getInstance(); NwsRoleDataManager man = NwsRoleDataManager.getInstance();
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
GridLayout gl = new GridLayout(1, false); GridLayout gl = new GridLayout(1, false);
shell.setLayout(gl); shell.setLayout(gl);
@ -130,7 +140,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
appCombo.addSelectionListener(new SelectionAdapter() { appCombo.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
selectedApplication = appCombo.getItem(appCombo.getSelectionIndex()); selectedApplication = appCombo.getItem(appCombo
.getSelectionIndex());
populateLists(); populateLists();
} }
}); });
@ -181,13 +192,14 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
if (dirty) { if (dirty) {
MessageBox messageDialog = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO); MessageBox messageDialog = new MessageBox(getShell(),
SWT.ICON_WARNING | SWT.YES | SWT.NO);
messageDialog.setText("Unsaved Changes"); messageDialog.setText("Unsaved Changes");
messageDialog.setMessage("Unsaved changes are present.\n" + messageDialog.setMessage("Unsaved changes are present.\n"
"Are you sure you want to close without saving?"); + "Are you sure you want to close without saving?");
int answer = messageDialog.open(); int answer = messageDialog.open();
if (answer == SWT.YES) { if (answer == SWT.YES) {
FileManager.getInstance().reloadXML(); NwsRoleDataManager.getInstance().reloadRoleData();
close(); close();
return; return;
} }
@ -198,10 +210,24 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
} }
}); });
NotificationManagerJob.addObserver(
UserAdminConstants.USER_AUTHENTICATION_CHANGED_TOPIC, this);
getShell().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
NotificationManagerJob.removeObserver(
UserAdminConstants.USER_AUTHENTICATION_CHANGED_TOPIC,
UserAdminSelectDlg.this);
}
});
populateLists(); populateLists();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened() * @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/ */
@Override @Override
@ -238,7 +264,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true); GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true);
listData.widthHint = 150; listData.widthHint = 150;
listData.heightHint = 175; listData.heightHint = 175;
userList = new List(listComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); userList = new List(listComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
| SWT.H_SCROLL);
userList.setLayoutData(listData); userList.setLayoutData(listData);
userList.addSelectionListener(new SelectionAdapter() { userList.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -310,7 +337,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
Label l = new Label(userRoleComp, SWT.NONE); Label l = new Label(userRoleComp, SWT.NONE);
l.setText("Defined Roles/Permissions:"); l.setText("Defined Roles/Permissions:");
userPermList = new List(userRoleComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); userPermList = new List(userRoleComp, SWT.BORDER | SWT.MULTI
| SWT.V_SCROLL | SWT.H_SCROLL);
userPermList.setLayoutData(listData); userPermList.setLayoutData(listData);
userPermList.addMouseListener(new MouseAdapter() { userPermList.addMouseListener(new MouseAdapter() {
@Override @Override
@ -322,17 +350,21 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
item1.addSelectionListener(new SelectionAdapter() { item1.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent arg0) { public void widgetSelected(SelectionEvent arg0) {
String selection = userPermList.getItem(userPermList.getSelectionIndex()); String selection = userPermList
.getItem(userPermList.getSelectionIndex());
StringBuilder messageText = new StringBuilder(); StringBuilder messageText = new StringBuilder();
boolean roleFlag = false; boolean roleFlag = false;
FileManager man = FileManager.getInstance(); NwsRoleDataManager man = NwsRoleDataManager.getInstance();
for (RoleXML role : man.getRoleData(selectedApplication).getRoleList()) { for (RoleXML role : man.getRoleData(
selectedApplication).getRoleList()) {
if (selection.equals(role.getRoleId())) { if (selection.equals(role.getRoleId())) {
messageText.append("Role: " + selection); messageText.append("Role: " + selection);
messageText.append("\n\nDescription: " + role.getRoleDescription().trim()); messageText.append("\n\nDescription: "
+ role.getRoleDescription().trim());
if (role.getPermissionList().size() > 0) { if (role.getPermissionList().size() > 0) {
messageText.append("\n\nPermissions: "); messageText.append("\n\nPermissions: ");
for (String perm : role.getPermissionList()) { for (String perm : role
.getPermissionList()) {
messageText.append("\n " + perm); messageText.append("\n " + perm);
} }
} }
@ -342,10 +374,14 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
} }
if (roleFlag == false) { if (roleFlag == false) {
for (PermissionXML perm : man.getRoleData(selectedApplication).getPermissionList()) { for (PermissionXML perm : man.getRoleData(
selectedApplication)
.getPermissionList()) {
if (perm.getId().equals(selection)) { if (perm.getId().equals(selection)) {
messageText.append("Permission: " + selection); messageText.append("Permission: "
messageText.append("\nDescription: " + perm.getDescription()); + selection);
messageText.append("\nDescription: "
+ perm.getDescription());
break; break;
} }
} }
@ -353,7 +389,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
if (messageText.length() == 0) { if (messageText.length() == 0) {
messageText.append("No Description"); messageText.append("No Description");
} }
MessageBox messageDialog = new MessageBox(shell, SWT.ICON_INFORMATION); MessageBox messageDialog = new MessageBox(shell,
SWT.ICON_INFORMATION);
if (roleFlag) { if (roleFlag) {
messageDialog.setText("Role Description"); messageDialog.setText("Role Description");
} else { } else {
@ -412,7 +449,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
listData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); listData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
listData.widthHint = 150; listData.widthHint = 150;
listData.heightHint = 175; listData.heightHint = 175;
roleList = new List(listComp2, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); roleList = new List(listComp2, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
| SWT.H_SCROLL);
roleList.setLayoutData(listData); roleList.setLayoutData(listData);
roleList.addSelectionListener(new SelectionAdapter() { roleList.addSelectionListener(new SelectionAdapter() {
@Override @Override
@ -444,17 +482,21 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
item1.addSelectionListener(new SelectionAdapter() { item1.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent arg0) { public void widgetSelected(SelectionEvent arg0) {
String selection = roleList.getItem(roleList.getSelectionIndex()); String selection = roleList.getItem(roleList
.getSelectionIndex());
String messageText = null; String messageText = null;
FileManager man = FileManager.getInstance(); NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex()); String app = appCombo.getItem(appCombo
for (RoleXML role : man.getRoleData(app).getRoleList()) { .getSelectionIndex());
for (RoleXML role : man.getRoleData(app)
.getRoleList()) {
if (selection.equals(role.getRoleId())) { if (selection.equals(role.getRoleId())) {
messageText = role.getRoleDescription(); messageText = role.getRoleDescription();
break; break;
} }
} }
MessageBox messageDialog = new MessageBox(shell, SWT.ICON_INFORMATION); MessageBox messageDialog = new MessageBox(shell,
SWT.ICON_INFORMATION);
messageDialog.setText("Role Description"); messageDialog.setText("Role Description");
messageDialog.setMessage(messageText.toString()); messageDialog.setMessage(messageText.toString());
messageDialog.open(); messageDialog.open();
@ -527,12 +569,13 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
Label l2 = new Label(permComp, SWT.NONE); Label l2 = new Label(permComp, SWT.NONE);
l2.setText("Roles/Permissions:"); l2.setText("Roles/Permissions:");
rolePermList = new List(permComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); rolePermList = new List(permComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
| SWT.H_SCROLL);
rolePermList.setLayoutData(listData); rolePermList.setLayoutData(listData);
} }
private void populateLists() { private void populateLists() {
FileManager man = FileManager.getInstance(); NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex()); String app = appCombo.getItem(appCombo.getSelectionIndex());
userTab.setText(app + " Users"); userTab.setText(app + " Users");
@ -563,7 +606,7 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
} }
private void populateUserRoleList() { private void populateUserRoleList() {
FileManager man = FileManager.getInstance(); NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex()); String app = appCombo.getItem(appCombo.getSelectionIndex());
if (userList.getSelectionIndex() != -1) { if (userList.getSelectionIndex() != -1) {
@ -585,7 +628,7 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
} }
private void populatePermissionList() { private void populatePermissionList() {
FileManager man = FileManager.getInstance(); NwsRoleDataManager man = NwsRoleDataManager.getInstance();
rolePermList.removeAll(); rolePermList.removeAll();
String app = appCombo.getItem(appCombo.getSelectionIndex()); String app = appCombo.getItem(appCombo.getSelectionIndex());
if (roleList.getSelectionIndex() != -1) { if (roleList.getSelectionIndex() != -1) {
@ -608,11 +651,12 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
MessageBox messageDialog = new MessageBox(this.shell, SWT.YES | SWT.NO); MessageBox messageDialog = new MessageBox(this.shell, SWT.YES | SWT.NO);
messageDialog.setText("Title"); messageDialog.setText("Title");
messageDialog.setMessage("Are you sure you wish to delete user " + user); messageDialog
.setMessage("Are you sure you wish to delete user " + user);
int response = messageDialog.open(); int response = messageDialog.open();
if (response == SWT.YES) { if (response == SWT.YES) {
FileManager man = FileManager.getInstance(); NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex()); String app = appCombo.getItem(appCombo.getSelectionIndex());
man.deleteUser(user, app); man.deleteUser(user, app);
dirty = true; dirty = true;
@ -623,7 +667,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
private void handleEditRole() { private void handleEditRole() {
String role = roleList.getItem(roleList.getSelectionIndex()); String role = roleList.getItem(roleList.getSelectionIndex());
ManageUserDlg mud = new ManageUserDlg(this.shell, "Role", role, selectedApplication); ManageUserDlg mud = new ManageUserDlg(this.shell, "Role", role,
selectedApplication);
boolean changes = (Boolean) mud.open(); boolean changes = (Boolean) mud.open();
if (changes) { if (changes) {
dirty = true; dirty = true;
@ -635,11 +680,12 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
MessageBox messageDialog = new MessageBox(this.shell, SWT.YES | SWT.NO); MessageBox messageDialog = new MessageBox(this.shell, SWT.YES | SWT.NO);
messageDialog.setText("Title"); messageDialog.setText("Title");
messageDialog.setMessage("Are you sure you wish to delete role " + role); messageDialog
.setMessage("Are you sure you wish to delete role " + role);
int response = messageDialog.open(); int response = messageDialog.open();
if (response == SWT.YES) { if (response == SWT.YES) {
FileManager man = FileManager.getInstance(); NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex()); String app = appCombo.getItem(appCombo.getSelectionIndex());
man.deleteRole(role, app); man.deleteRole(role, app);
dirty = true; dirty = true;
@ -663,7 +709,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
private void handleEditUser() { private void handleEditUser() {
String user = userList.getItem(userList.getSelectionIndex()); String user = userList.getItem(userList.getSelectionIndex());
ManageUserDlg mud = new ManageUserDlg(this.shell, "User", user, selectedApplication); ManageUserDlg mud = new ManageUserDlg(this.shell, "User", user,
selectedApplication);
boolean changes = (Boolean) mud.open(); boolean changes = (Boolean) mud.open();
if (changes) { if (changes) {
dirty = true; dirty = true;
@ -671,8 +718,25 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
} }
private void handleOK() { private void handleOK() {
FileManager manager = FileManager.getInstance(); NwsRoleDataManager manager = NwsRoleDataManager.getInstance();
manager.save(selectedApplication); manager.save(selectedApplication);
dirty = false; dirty = false;
} }
/**
* {@inheritDoc}
*/
@Override
public void notificationArrived(NotificationMessage[] messages) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
NwsRoleDataManager.getInstance().reloadRoleData();
if (!UserAdminSelectDlg.this.isDisposed()) {
populateLists();
}
}
});
}
} }

View file

@ -9,7 +9,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.2", Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.2",
com.raytheon.uf.common.auth;bundle-version="1.12.1174", com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174", com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.raytheon.uf.common.localization;bundle-version="1.12.1174" com.raytheon.uf.common.localization;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174"
Export-Package: com.raytheon.uf.common.plugin.nwsauth, Export-Package: com.raytheon.uf.common.plugin.nwsauth,
com.raytheon.uf.common.plugin.nwsauth.exception, com.raytheon.uf.common.plugin.nwsauth.exception,
com.raytheon.uf.common.plugin.nwsauth.user, com.raytheon.uf.common.plugin.nwsauth.user,

View file

@ -0,0 +1,87 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.plugin.nwsauth;
import java.util.Map;
import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest;
import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
/**
* A request to retrieve, or submit, the NWS role date.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 09, 2013 1412 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@DynamicSerialize
public class NwsRoleDataRequest extends AbstractPrivilegedRequest {
// Ticket #1315 should use this class to actually retrieve/submit role data
// changes
public static enum NwsRoleDataRequestType {
REQUEST, SUBMIT;
}
@DynamicSerializeElement
private NwsRoleDataRequestType type;
@DynamicSerializeElement
private Map<String, NwsRoleData> roleDataMap;
/**
* @return the type
*/
public NwsRoleDataRequestType getType() {
return type;
}
/**
* @param request
*/
public void setType(NwsRoleDataRequestType type) {
this.type = type;
}
/**
* @return
*/
public Map<String, NwsRoleData> getRoleDataMap() {
return roleDataMap;
}
/**
* @param roleDataMap2
*/
public void setRoleDataMap(Map<String, NwsRoleData> roleDataMap2) {
this.roleDataMap = roleDataMap2;
}
}

View file

@ -82,7 +82,7 @@ public class RoleXML implements ISerializableObject {
* @return the description * @return the description
*/ */
public String getRoleDescription() { public String getRoleDescription() {
return roleDescription.trim(); return roleDescription == null ? null : roleDescription.trim();
} }
/** /**

View file

@ -1,4 +1,5 @@
source.. = src/ source.. = src/
output.. = bin/ output.. = bin/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
. .,\
res/

View file

@ -0,0 +1,10 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<util:constant id="userAuthenticationChangedTopic"
static-field="com.raytheon.uf.common.useradmin.request.UserAdminConstants.USER_AUTHENTICATION_CHANGED_TOPIC" />
</beans>

View file

@ -0,0 +1,48 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.useradmin.request;
/**
* Constants for working with user administration.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 09, 2013 1412 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public final class UserAdminConstants {
/**
* The topic uri on which user authentication data changes are sent.
*/
public static final String USER_AUTHENTICATION_CHANGED_TOPIC = "user.authentication.changed";
private UserAdminConstants() {
}
}

View file

@ -0,0 +1,45 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.useradmin.request;
import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
/**
* A marker object that informs observers in the system that user authentication
* data has changed.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 09, 2013 1412 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
@DynamicSerialize
public class UserAuthenticationDataChanged extends AbstractPrivilegedRequest {
}

View file

@ -1,48 +1,24 @@
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd http://www.springframework.org/schema/util
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<bean id="datadeliveryAuthorization" <bean id="datadeliveryAuthorization"
class="com.raytheon.uf.edex.datadelivery.service.services.DataDeliveryPrivilegedRequestHandler" /> class="com.raytheon.uf.edex.datadelivery.service.services.DataDeliveryPrivilegedRequestHandler" />
<bean factory-bean="handlerRegistry" factory-method="register"> <bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg <constructor-arg
value="com.raytheon.uf.common.datadelivery.request.DataDeliveryAuthRequest" /> value="com.raytheon.uf.common.datadelivery.request.DataDeliveryAuthRequest" />
<constructor-arg ref="datadeliveryAuthorization" /> <constructor-arg ref="datadeliveryAuthorization" />
</bean> </bean>
<bean id="subscriptionDeleteService"
<bean id="roleStorage" class="com.raytheon.uf.edex.datadelivery.service.services.SubscriptionDeleteHandler" />
class="com.raytheon.uf.edex.plugin.nwsauth.NwsRoleStorage" />
<bean id="authenticator"
class="com.raytheon.uf.edex.plugin.nwsauth.authentication.Authenticator" />
<bean id="authStorage"
class="com.raytheon.uf.edex.plugin.nwsauth.authentication.AuthenticationStorage" />
<!--
<bean id="roleStorage"
class="com.raytheon.uf.edex.datadelivery.service.roles.DataDeliveryRoleStorage" />
<bean id="authenticator"
class="com.raytheon.uf.edex.datadelivery.service.authentication.Authenticator" />
<bean id="authStorage"
class="com.raytheon.uf.edex.datadelivery.service.authentication.AuthenticationStorage" />
-->
<bean id="authManager" class="com.raytheon.uf.edex.auth.AuthManager">
<property name="authenticationStorage" ref="authStorage" />
<property name="authenticator" ref="authenticator" />
<property name="roleStorage" ref="roleStorage" />
</bean>
<bean id="authFactory" class="com.raytheon.uf.edex.auth.AuthManagerFactory"
factory-method="getInstance">
<property name="manager" ref="authManager" />
</bean>
<bean id="subscriptionDeleteService" class="com.raytheon.uf.edex.datadelivery.service.services.SubscriptionDeleteHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register"> <bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.datadelivery.registry.SubscriptionDeleteRequest"/> <constructor-arg
<constructor-arg ref="subscriptionDeleteService"/> value="com.raytheon.uf.common.datadelivery.registry.SubscriptionDeleteRequest" />
<constructor-arg ref="subscriptionDeleteService" />
</bean> </bean>
</beans> </beans>

View file

@ -9,7 +9,9 @@ Require-Bundle: com.raytheon.uf.edex.auth;bundle-version="1.12.2",
com.raytheon.uf.common.auth;bundle-version="1.12.2", com.raytheon.uf.common.auth;bundle-version="1.12.2",
com.raytheon.uf.common.plugin.nwsauth;bundle-version="1.0.0", com.raytheon.uf.common.plugin.nwsauth;bundle-version="1.0.0",
com.raytheon.uf.common.status;bundle-version="1.12.1174", com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.raytheon.uf.common.localization com.raytheon.uf.common.localization,
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
com.raytheon.uf.common.useradmin;bundle-version="1.0.0"
Import-Package: com.raytheon.uf.common.localization, Import-Package: com.raytheon.uf.common.localization,
com.raytheon.uf.common.serialization, com.raytheon.uf.common.serialization,
com.raytheon.uf.common.status, com.raytheon.uf.common.status,

View file

@ -1,21 +1,34 @@
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd http://www.springframework.org/schema/util
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<bean id="roleStorage" class="com.raytheon.uf.edex.plugin.nwsauth.NwsRoleStorage"/> <bean id="roleStorage" class="com.raytheon.uf.edex.plugin.nwsauth.NwsRoleStorage" />
<bean id="authenticator" class="com.raytheon.uf.edex.plugin.nwsauth.authentication.Authenticator"/> <bean id="authenticator"
<bean id="authStorage" class="com.raytheon.uf.edex.plugin.nwsauth.authentication.AuthenticationStorage"/> class="com.raytheon.uf.edex.plugin.nwsauth.authentication.Authenticator" />
<bean id="authStorage"
<bean id="authManager" class="com.raytheon.uf.edex.auth.AuthManager"> class="com.raytheon.uf.edex.plugin.nwsauth.authentication.AuthenticationStorage" />
<property name="authenticationStorage" ref="authStorage"/>
<property name="authenticator" ref="authenticator"/> <bean id="authManager" class="com.raytheon.uf.edex.auth.AuthManager">
<property name="roleStorage" ref="roleStorage"/> <property name="authenticationStorage" ref="authStorage" />
</bean> <property name="authenticator" ref="authenticator" />
<property name="roleStorage" ref="roleStorage" />
<bean id="authFactory" class="com.raytheon.uf.edex.auth.AuthManagerFactory" factory-method="getInstance"> </bean>
<property name="manager" ref="authManager"/>
</bean> <bean id="authFactory" class="com.raytheon.uf.edex.auth.AuthManagerFactory"
factory-method="getInstance">
<property name="manager" ref="authManager" />
</bean>
<bean id="edexNwsRoleManager"
class="com.raytheon.uf.edex.plugin.nwsauth.EdexNwsRoleManager" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.plugin.nwsauth.NwsRoleDataRequest" />
<constructor-arg ref="edexNwsRoleManager" />
</bean>
</beans> </beans>

View file

@ -0,0 +1,85 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.nwsauth;
import java.util.Map;
import com.raytheon.uf.common.auth.exception.AuthorizationException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.plugin.nwsauth.NwsRoleDataRequest;
import com.raytheon.uf.common.plugin.nwsauth.NwsRoleDataRequest.NwsRoleDataRequestType;
import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.common.useradmin.request.UserAuthenticationDataChanged;
import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler;
import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
/**
* Receives requests to retrieve or submit NWS role data.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 09, 2013 1412 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class EdexNwsRoleManager extends
AbstractPrivilegedRequestHandler<NwsRoleDataRequest> {
/**
* {@inheritDoc}
*/
@Override
public Object handleRequest(NwsRoleDataRequest request) throws Exception {
final FileManager fileManager = FileManager.getInstance();
final NwsRoleDataRequestType type = request.getType();
switch (type) {
case REQUEST:
request.setRoleDataMap(fileManager.getRoleDataMap());
break;
case SUBMIT:
final Map<String, NwsRoleData> roleDataMap = request
.getRoleDataMap();
fileManager.writeApplicationRoleData(roleDataMap);
RequestRouter.route(new UserAuthenticationDataChanged());
break;
}
return request;
}
/**
* {@inheritDoc}
*/
@Override
public AuthorizationResponse authorized(IUser user,
NwsRoleDataRequest request) throws AuthorizationException {
return new AuthorizationResponse(true);
}
}

View file

@ -0,0 +1,171 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.plugin.nwsauth;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.bind.JAXBException;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
import com.raytheon.uf.common.plugin.nwsauth.xml.NwsRoleData;
import com.raytheon.uf.common.plugin.nwsauth.xml.PermissionXML;
import com.raytheon.uf.common.plugin.nwsauth.xml.RoleXML;
import com.raytheon.uf.common.plugin.nwsauth.xml.UserXML;
import com.raytheon.uf.common.serialization.JAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
* Uses localization data to determine role/permissions. Intentionally
* package-private as all access should remain localized to the NWS plugin.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 09, 2013 1412 djohnson Moved file writing from viz plugin to server-side.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
class FileManager {
/** Status handler */
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(FileManager.class);
private static final FileManager instance = new FileManager();
private static JAXBManager jaxbManager;
private final String ROLE_DIR = "roles";
private final Map<String, NwsRoleData> roleDataMap = new HashMap<String, NwsRoleData>();
/**
* Application name -> LocalizationFile map.
*/
private final Map<String, LocalizationFile> roleFileMap = new HashMap<String, LocalizationFile>();
private FileManager() {
readXML();
}
/**
* Get an instance.
*
* @return an instance
*/
public static FileManager getInstance() {
return instance;
}
/**
* {@inheritDoc}
*/
public void save(String application) {
NwsRoleData roleData = roleDataMap.get(application);
LocalizationFile lf = roleFileMap.get(application);
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext context = pm.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.SITE);
LocalizationFile locFile = pm
.getLocalizationFile(context, lf.getName());
try {
JAXBManager jaxbManager = getJaxbManager();
jaxbManager.getJaxbContext().createMarshaller()
.marshal(roleData, locFile.getFile());
locFile.save();
} catch (JAXBException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
} catch (LocalizationOpFailedException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
private void readXML() {
try {
getJaxbManager();
IPathManager pm = PathManagerFactory.getPathManager();
LocalizationContext[] contexts = new LocalizationContext[2];
contexts[0] = pm.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.BASE);
contexts[1] = pm.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.SITE);
LocalizationFile[] roleFiles = pm.listFiles(contexts, ROLE_DIR,
new String[] { ".xml" }, false, true);
for (LocalizationFile lf : roleFiles) {
NwsRoleData roleData = lf.jaxbUnmarshal(NwsRoleData.class,
getJaxbManager());
if (roleData != null) {
this.roleDataMap.put(roleData.getApplication(), roleData);
this.roleFileMap.put(roleData.getApplication(), lf);
}
}
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
private JAXBManager getJaxbManager() throws JAXBException {
if (jaxbManager == null) {
jaxbManager = new JAXBManager(NwsRoleData.class,
PermissionXML.class, RoleXML.class, UserXML.class);
}
return jaxbManager;
}
/**
* @return
*/
public Map<String, NwsRoleData> getRoleDataMap() {
return roleDataMap;
}
/**
* @param roleDataWithChanges
*/
public void writeApplicationRoleData(Map<String, NwsRoleData> roleDataWithChanges) {
for (Entry<String, NwsRoleData> entry : roleDataWithChanges.entrySet()) {
final String application = entry.getKey();
roleDataMap.put(application, entry.getValue());
save(application);
}
}
}

View file

@ -10,7 +10,6 @@ Require-Bundle: com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
com.raytheon.uf.common.useradmin;bundle-version="1.0.0", com.raytheon.uf.common.useradmin;bundle-version="1.0.0",
com.raytheon.uf.common.status;bundle-version="1.12.1174", com.raytheon.uf.common.status;bundle-version="1.12.1174",
com.raytheon.uf.edex.plugin.nwsauth;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization;bundle-version="1.12.1174", com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.edex.core;bundle-version="1.12.1174", com.raytheon.uf.edex.core;bundle-version="1.12.1174",
com.raytheon.uf.common.localization;bundle-version="1.12.1174" com.raytheon.uf.common.localization;bundle-version="1.12.1174"

View file

@ -1,34 +1,28 @@
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd http://www.springframework.org/schema/util
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<bean id="userAdminAuthorization" <bean id="userAdminAuthorization"
class="com.raytheon.uf.edex.useradmin.services.UserAdminPrivilegedRequestHandler" /> class="com.raytheon.uf.edex.useradmin.services.UserAdminPrivilegedRequestHandler" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.useradmin.request.UserAdminAuthRequest" />
<constructor-arg ref="userAdminAuthorization" />
</bean>
<bean id="userAuthenticationDataChangedHandler"
class="com.raytheon.uf.edex.useradmin.services.UserAuthenticationDataChangedHandler">
<constructor-arg type="java.lang.String"
value="jms-generic:topic:user.authentication.changed?destinationResolver=#qpidDurableResolver" />
</bean>
<bean id="roleStorage" <bean factory-bean="handlerRegistry" factory-method="register">
class="com.raytheon.uf.edex.plugin.nwsauth.NwsRoleStorage" /> <constructor-arg
<bean id="authenticator" value="com.raytheon.uf.common.useradmin.request.UserAdminAuthRequest" />
class="com.raytheon.uf.edex.plugin.nwsauth.authentication.Authenticator" /> <constructor-arg ref="userAdminAuthorization" />
<bean id="authStorage" </bean>
class="com.raytheon.uf.edex.plugin.nwsauth.authentication.AuthenticationStorage" />
<bean id="authManager" class="com.raytheon.uf.edex.auth.AuthManager"> <bean factory-bean="handlerRegistry" factory-method="register">
<property name="authenticationStorage" ref="authStorage" /> <constructor-arg
<property name="authenticator" ref="authenticator" /> value="com.raytheon.uf.common.useradmin.request.UserAuthenticationDataChanged" />
<property name="roleStorage" ref="roleStorage" /> <constructor-arg ref="userAuthenticationDataChangedHandler" />
</bean> </bean>
<bean id="authFactory" class="com.raytheon.uf.edex.auth.AuthManagerFactory"
factory-method="getInstance">
<property name="manager" ref="authManager" />
</bean>
</beans> </beans>

View file

@ -0,0 +1,106 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.useradmin.services;
import com.raytheon.uf.common.auth.exception.AuthorizationException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.useradmin.request.UserAuthenticationDataChanged;
import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler;
import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.core.EdexException;
/**
* Receives requests signifying that user authentication data has changed, and
* publishes them on the observer topic.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 09, 2013 1412 djohnson Initial creation
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class UserAuthenticationDataChangedHandler extends
AbstractPrivilegedRequestHandler<UserAuthenticationDataChanged> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(UserAuthenticationDataChangedHandler.class);
private final String topicUri;
public UserAuthenticationDataChangedHandler(String topicUri) {
this.topicUri = topicUri;
}
/**
* {@inheritDoc}
*/
@Override
public Object handleRequest(UserAuthenticationDataChanged request)
throws Exception {
send(request, topicUri);
return request;
}
/**
* {@inheritDoc}
*/
@Override
public AuthorizationResponse authorized(IUser user,
UserAuthenticationDataChanged request)
throws AuthorizationException {
// Returns false because it should only ever be invoked from another
// plugin implements the useradmin API running in the local EDEX, which
// does not require authentication
return new AuthorizationResponse(false);
}
/**
* Sends the object to the topic observers are listening on.
*
* @param obj
* @param endpoint
* the endpoint to send to
*/
public void send(Object obj, String endpoint) {
try {
byte[] bytes = SerializationUtil.transformToThrift(obj);
EDEXUtil.getMessageProducer().sendAsyncUri(endpoint, bytes);
} catch (EdexException e) {
statusHandler.error("Error sending object to " + endpoint, e);
} catch (SerializationException e) {
statusHandler.error("Error serializing object to " + endpoint, e);
}
}
}