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;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
import com.raytheon.uf.common.auth.user.IPermission;
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.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.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.comm.RequestRouter;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
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
* Nov 06, 2012 1302 djohnson Move to nwsauth plugin.
* Jan 09, 2013 1412 djohnson Move localization file writing to the server.
*
* </pre>
*
@ -68,34 +60,17 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* @version 1.0
*/
public class FileManager {
public class NwsRoleDataManager {
/** Status handler */
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 JAXBContext jax;
/** 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();
private NwsRoleDataManager() {
retrieveRoleDataFromServer();
}
/**
@ -103,28 +78,10 @@ public class FileManager {
*
* @return an instance
*/
public static FileManager getInstance() {
public static NwsRoleDataManager getInstance() {
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.
*
@ -318,65 +275,54 @@ public class FileManager {
}
/**
* Save the NwsRoleData object.
*
* @param application
* {@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 {
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);
}
updateRoleDataOnTheServer(application);
}
private void readXML() {
try {
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,
null, false, true);
/**
* Updates the role data on the server.
*
* @param application
* the application to send updated role data for
*/
private void updateRoleDataOnTheServer(String application) {
Map<String, NwsRoleData> roleDataMapUpdates = new HashMap<String, NwsRoleData>();
roleDataMapUpdates.put(application, roleDataMap.get(application));
for (LocalizationFile lf : roleFiles) {
File f = lf.getFile(true);
if (f != null && f.exists()) {
System.out.println(f.getAbsolutePath());
NwsRoleData roleData = (NwsRoleData) unmarshaller
.unmarshal(f);
this.roleDataMap.put(roleData.getApplication(), roleData);
this.roleFileMap.put(roleData.getApplication(), lf);
}
}
} catch (JAXBException e1) {
NwsRoleDataRequest request = new NwsRoleDataRequest();
request.setRoleDataMap(roleDataMapUpdates);
request.setType(NwsRoleDataRequestType.SUBMIT);
try {
RequestRouter.route(request);
} catch (Exception e) {
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) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
/**
* Reload theXML files from disk.
*/
public void reloadXML() {
readXML();
public void reloadRoleData() {
retrieveRoleDataFromServer();
}
}

View file

@ -88,7 +88,7 @@ public class NwsUserManager implements IUserManager {
@Override
public List<IPermission> getPermissions(String application) {
// 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
public List<IRole> getRoles(String application) {
// 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.RoleXML;
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.widgets.duallist.DualList;
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();
/** Type of permissions */
private String type;
private final String type;
/** Selection */
private String selection;
private final String selection;
/** Edit combo box */
private Combo editCbo;
@ -87,7 +87,7 @@ public class ManageUserDlg extends CaveSWTDialog implements IUpdate {
private Composite stackComp;
/** The application currently selected.*/
private String application;
private final String application;
/**
* Constructor.
@ -165,7 +165,7 @@ public class ManageUserDlg extends CaveSWTDialog implements IUpdate {
stackComp = new Composite(shell, SWT.NONE);
stackComp.setLayout(stackLayout);
FileManager manager = FileManager.getInstance();
NwsRoleDataManager manager = NwsRoleDataManager.getInstance();
ArrayList<String> selectedList = new ArrayList<String>();
ArrayList<String> fullList = new ArrayList<String>();
String availableLabel = "Available Roles:";
@ -291,7 +291,7 @@ public class ManageUserDlg extends CaveSWTDialog implements IUpdate {
String[] permissions = permDualList.getSelectedListItems();
String[] roles = roleDualList.getSelectedListItems();
FileManager man = FileManager.getInstance();
NwsRoleDataManager man = NwsRoleDataManager.getInstance();
NwsRoleData roleData = man.getRoleData(application);
if (type.equalsIgnoreCase("User")) {

View file

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

View file

@ -22,6 +22,8 @@ package com.raytheon.uf.viz.useradmin.ui;
import java.util.ArrayList;
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.MouseEvent;
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.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;
/**
* Main User Administration Dialog.
*
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 23, 2012 mpduff Initial creation.
* Nov 26, 2012 1347 mpduff Make resizable.
*
* Jan 09, 2013 1412 djohnson Listen for user authentication data changes.
*
* </pre>
*
*
* @author mpduff
* @version 1.0
*/
public class UserAdminSelectDlg extends CaveSWTDialog {
public class UserAdminSelectDlg extends CaveSWTDialog implements
INotificationObserver {
private Combo appCombo;
private TabFolder tabFolder;
@ -95,18 +104,19 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
/**
* Constructor.
*
*
* @param parent
* The parent shell
*/
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");
}
@Override
protected void initializeComponents(Shell shell) {
FileManager man = FileManager.getInstance();
NwsRoleDataManager man = NwsRoleDataManager.getInstance();
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
GridLayout gl = new GridLayout(1, false);
shell.setLayout(gl);
@ -130,7 +140,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
appCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedApplication = appCombo.getItem(appCombo.getSelectionIndex());
selectedApplication = appCombo.getItem(appCombo
.getSelectionIndex());
populateLists();
}
});
@ -181,13 +192,14 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent e) {
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.setMessage("Unsaved changes are present.\n" +
"Are you sure you want to close without saving?");
messageDialog.setMessage("Unsaved changes are present.\n"
+ "Are you sure you want to close without saving?");
int answer = messageDialog.open();
if (answer == SWT.YES) {
FileManager.getInstance().reloadXML();
NwsRoleDataManager.getInstance().reloadRoleData();
close();
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();
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
@ -238,7 +264,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true);
listData.widthHint = 150;
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.addSelectionListener(new SelectionAdapter() {
@Override
@ -310,7 +337,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
Label l = new Label(userRoleComp, SWT.NONE);
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.addMouseListener(new MouseAdapter() {
@Override
@ -322,17 +350,21 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
item1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
String selection = userPermList.getItem(userPermList.getSelectionIndex());
String selection = userPermList
.getItem(userPermList.getSelectionIndex());
StringBuilder messageText = new StringBuilder();
boolean roleFlag = false;
FileManager man = FileManager.getInstance();
for (RoleXML role : man.getRoleData(selectedApplication).getRoleList()) {
NwsRoleDataManager man = NwsRoleDataManager.getInstance();
for (RoleXML role : man.getRoleData(
selectedApplication).getRoleList()) {
if (selection.equals(role.getRoleId())) {
messageText.append("Role: " + selection);
messageText.append("\n\nDescription: " + role.getRoleDescription().trim());
messageText.append("\n\nDescription: "
+ role.getRoleDescription().trim());
if (role.getPermissionList().size() > 0) {
messageText.append("\n\nPermissions: ");
for (String perm : role.getPermissionList()) {
for (String perm : role
.getPermissionList()) {
messageText.append("\n " + perm);
}
}
@ -342,10 +374,14 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
}
if (roleFlag == false) {
for (PermissionXML perm : man.getRoleData(selectedApplication).getPermissionList()) {
for (PermissionXML perm : man.getRoleData(
selectedApplication)
.getPermissionList()) {
if (perm.getId().equals(selection)) {
messageText.append("Permission: " + selection);
messageText.append("\nDescription: " + perm.getDescription());
messageText.append("Permission: "
+ selection);
messageText.append("\nDescription: "
+ perm.getDescription());
break;
}
}
@ -353,7 +389,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
if (messageText.length() == 0) {
messageText.append("No Description");
}
MessageBox messageDialog = new MessageBox(shell, SWT.ICON_INFORMATION);
MessageBox messageDialog = new MessageBox(shell,
SWT.ICON_INFORMATION);
if (roleFlag) {
messageDialog.setText("Role Description");
} else {
@ -412,7 +449,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
listData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
listData.widthHint = 150;
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.addSelectionListener(new SelectionAdapter() {
@Override
@ -444,17 +482,21 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
item1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
String selection = roleList.getItem(roleList.getSelectionIndex());
String selection = roleList.getItem(roleList
.getSelectionIndex());
String messageText = null;
FileManager man = FileManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex());
for (RoleXML role : man.getRoleData(app).getRoleList()) {
NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo
.getSelectionIndex());
for (RoleXML role : man.getRoleData(app)
.getRoleList()) {
if (selection.equals(role.getRoleId())) {
messageText = role.getRoleDescription();
break;
}
}
MessageBox messageDialog = new MessageBox(shell, SWT.ICON_INFORMATION);
MessageBox messageDialog = new MessageBox(shell,
SWT.ICON_INFORMATION);
messageDialog.setText("Role Description");
messageDialog.setMessage(messageText.toString());
messageDialog.open();
@ -527,12 +569,13 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
Label l2 = new Label(permComp, SWT.NONE);
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);
}
private void populateLists() {
FileManager man = FileManager.getInstance();
NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex());
userTab.setText(app + " Users");
@ -563,7 +606,7 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
}
private void populateUserRoleList() {
FileManager man = FileManager.getInstance();
NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex());
if (userList.getSelectionIndex() != -1) {
@ -585,7 +628,7 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
}
private void populatePermissionList() {
FileManager man = FileManager.getInstance();
NwsRoleDataManager man = NwsRoleDataManager.getInstance();
rolePermList.removeAll();
String app = appCombo.getItem(appCombo.getSelectionIndex());
if (roleList.getSelectionIndex() != -1) {
@ -608,11 +651,12 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
MessageBox messageDialog = new MessageBox(this.shell, SWT.YES | SWT.NO);
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();
if (response == SWT.YES) {
FileManager man = FileManager.getInstance();
NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex());
man.deleteUser(user, app);
dirty = true;
@ -623,7 +667,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
private void handleEditRole() {
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();
if (changes) {
dirty = true;
@ -635,11 +680,12 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
MessageBox messageDialog = new MessageBox(this.shell, SWT.YES | SWT.NO);
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();
if (response == SWT.YES) {
FileManager man = FileManager.getInstance();
NwsRoleDataManager man = NwsRoleDataManager.getInstance();
String app = appCombo.getItem(appCombo.getSelectionIndex());
man.deleteRole(role, app);
dirty = true;
@ -663,7 +709,8 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
private void handleEditUser() {
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();
if (changes) {
dirty = true;
@ -671,8 +718,25 @@ public class UserAdminSelectDlg extends CaveSWTDialog {
}
private void handleOK() {
FileManager manager = FileManager.getInstance();
NwsRoleDataManager manager = NwsRoleDataManager.getInstance();
manager.save(selectedApplication);
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",
com.raytheon.uf.common.auth;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,
com.raytheon.uf.common.plugin.nwsauth.exception,
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
*/
public String getRoleDescription() {
return roleDescription.trim();
return roleDescription == null ? null : roleDescription.trim();
}
/**

View file

@ -1,4 +1,5 @@
source.. = src/
output.. = bin/
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"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
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">
<bean id="datadeliveryAuthorization"
class="com.raytheon.uf.edex.datadelivery.service.services.DataDeliveryPrivilegedRequestHandler" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.datadelivery.request.DataDeliveryAuthRequest" />
<constructor-arg ref="datadeliveryAuthorization" />
</bean>
<bean id="datadeliveryAuthorization"
class="com.raytheon.uf.edex.datadelivery.service.services.DataDeliveryPrivilegedRequestHandler" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.datadelivery.request.DataDeliveryAuthRequest" />
<constructor-arg ref="datadeliveryAuthorization" />
</bean>
<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="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 id="subscriptionDeleteService"
class="com.raytheon.uf.edex.datadelivery.service.services.SubscriptionDeleteHandler" />
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.datadelivery.registry.SubscriptionDeleteRequest"/>
<constructor-arg ref="subscriptionDeleteService"/>
<constructor-arg
value="com.raytheon.uf.common.datadelivery.registry.SubscriptionDeleteRequest" />
<constructor-arg ref="subscriptionDeleteService" />
</bean>
</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.plugin.nwsauth;bundle-version="1.0.0",
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,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.status,

View file

@ -1,21 +1,34 @@
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<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="authStorage" class="com.raytheon.uf.edex.plugin.nwsauth.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>
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">
<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="authStorage"
class="com.raytheon.uf.edex.plugin.nwsauth.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="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>

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.useradmin;bundle-version="1.0.0",
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.edex.core;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"
xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
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">
<bean id="userAdminAuthorization"
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="userAdminAuthorization"
class="com.raytheon.uf.edex.useradmin.services.UserAdminPrivilegedRequestHandler" />
<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"
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 factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.useradmin.request.UserAdminAuthRequest" />
<constructor-arg ref="userAdminAuthorization" />
</bean>
<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 factory-bean="handlerRegistry" factory-method="register">
<constructor-arg
value="com.raytheon.uf.common.useradmin.request.UserAuthenticationDataChanged" />
<constructor-arg ref="userAuthenticationDataChangedHandler" />
</bean>
</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);
}
}
}