Issue #1981 - OUPRequest is now a privileged request.

Also proctecting TafQueueRequest

Change-Id: I3a05a407a21b8f9d2e6426c4f456e2218479242a

Former-commit-id: acc1b993db8d78f7edfc3bd287b7d3ca39c0d391
This commit is contained in:
Mike Duff 2013-06-07 12:07:35 -05:00
parent 03a377c552
commit ee5e9c1435
23 changed files with 379 additions and 90 deletions

View file

@ -37,6 +37,7 @@ import com.raytheon.uf.viz.core.requests.INotAuthHandler;
* ------------ ---------- ----------- --------------------------
* May 21, 2010 mschenke Initial creation
* Nov 06, 2012 1302 djohnson Add ability to get roles/permissions for an application.
* Jun 07, 2013 1981 mpduff Add ability to update with the user id as a string.
*
* </pre>
*
@ -85,4 +86,14 @@ public interface IUserManager {
* @return the list of roles
*/
List<IRole> getRoles(String application);
/**
* Update the user object with the authentication data update
*
* @param userId
* User's id
* @param authData
* User's authentication data
*/
void updateUserObject(String userId, IAuthenticationData authData);
}

View file

@ -55,6 +55,7 @@ import com.raytheon.uf.viz.core.requests.INotAuthHandler;
* Nov 06, 2012 1302 djohnson Add ability to retrieve the {@link IUserManager}.
* Jan 04, 2013 1451 djohnson Move static block code to an implementation of an interface.
* Mar 21, 2013 1794 djohnson ServiceLoaderUtil now requires the requesting class.
* Jun 07, 2013 1981 mpduff Add ability to update with the user id as a string.
*
* </pre>
*
@ -166,6 +167,12 @@ public class UserController {
return Collections.emptyList();
}
@Override
public void updateUserObject(String userId,
IAuthenticationData authData) {
}
};
}
return manager;
@ -194,6 +201,16 @@ public class UserController {
manager.updateUserObject(manager.getUserObject(), data);
}
/**
* Update the user's id.
*
* @param userID
* The user id
*/
public static void updateUserData(String userID) {
manager.updateUserObject(userID, null);
}
public static INotAuthHandler getNotAuthHandler() {
return manager.getNotAuthHandler();
}

View file

@ -20,6 +20,7 @@
package com.raytheon.uf.viz.core.comm;
import com.raytheon.uf.common.comm.IHttpsCredentialsHandler;
import com.raytheon.uf.viz.core.auth.UserController;
/**
* Cave implementation of the IHttpsCredentialsHandler. Displays the Cave login
@ -31,7 +32,8 @@ import com.raytheon.uf.common.comm.IHttpsCredentialsHandler;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 4, 2013 1786 mpduff Initial creation
* Mar 04, 2013 1786 mpduff Initial creation.
* Jun 07, 2013 1981 mpduff Save user's username in UserController.
*
* </pre>
*
@ -52,6 +54,9 @@ public class CaveHttpsCredentialsHandler implements IHttpsCredentialsHandler {
}
HttpsLoginDlg login = new HttpsLoginDlg(message);
login.open();
return login.getCredentials();
String[] credentials = login.getCredentials();
// Save off the user's username in the UserController
UserController.updateUserData(credentials[0]);
return credentials;
}
}

View file

@ -38,6 +38,7 @@ import com.raytheon.uf.viz.core.requests.INotAuthHandler;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 27, 2010 rgeorge Initial creation
* Jun 07, 2013 1981 mpduff Add an IUser field.
*
* </pre>
*
@ -49,6 +50,9 @@ public class NwsUserManager implements IUserManager {
private final NwsNotAuthHandler notAuthHandler = new NwsNotAuthHandler();
/** Saved User Name */
private IUser user;
/*
* (non-Javadoc)
*
@ -66,8 +70,13 @@ public class NwsUserManager implements IUserManager {
*/
@Override
public IUser getUserObject() {
String userId = System.getProperty("user.name");
return new User(userId);
if (this.user == null) {
String userId = System.getProperty("user.name");
this.user = new User(userId);
return this.user;
} else {
return user;
}
}
/*
@ -80,6 +89,7 @@ public class NwsUserManager implements IUserManager {
*/
@Override
public void updateUserObject(IUser user, IAuthenticationData authData) {
this.user = user;
}
/**
@ -99,4 +109,12 @@ public class NwsUserManager implements IUserManager {
// TODO: Should this pass through to EDEX to get this stuff?
return NwsRoleDataManager.getInstance().getRoles(application);
}
/**
* {@inheritDoc}
*/
@Override
public void updateUserObject(String userId, IAuthenticationData authData) {
user = new User(userId);
}
}

View file

@ -25,7 +25,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.viz.ui.personalities.awips;bundle-version="1.12.1174",
com.raytheon.uf.viz.application;bundle-version="1.0.0",
com.raytheon.uf.common.tafqueue;bundle-version="1.0.0",
org.apache.commons.lang;bundle-version="2.3.0"
org.apache.commons.lang;bundle-version="2.3.0",
com.raytheon.uf.common.auth;bundle-version="1.12.1174"
Bundle-ActivationPolicy: lazy
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
Export-Package: com.raytheon.viz.aviation,

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.common.tafqueue.ServerResponse;
import com.raytheon.uf.common.tafqueue.TafQueueRecord;
import com.raytheon.uf.common.tafqueue.TafQueueRequest;
import com.raytheon.uf.common.tafqueue.TafQueueRequest.Type;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.aviation.AviationDialog;
@ -70,6 +71,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 12/08/2011 11745 rferrel Updated header time to transmission time.
* 08AUG2012 15613 zhao Determine proper BBB for transmission
* 09OCT2012 1229 rferrel Make dialog non-blocking.
* 0yJUN2013 1981 mpduff Set user on the request.
*
* </pre>
*
@ -116,12 +118,12 @@ public class SendDialog extends CaveSWTDialog {
/**
* Tab composite containing the TAF Viewer and the TAF Editor.
*/
private EditorTafTabComp tabComp;
private final EditorTafTabComp tabComp;
/**
* Message status composite.
*/
private IStatusSettable msgStatComp;
private final IStatusSettable msgStatComp;
/**
* Main composite.
@ -136,7 +138,7 @@ public class SendDialog extends CaveSWTDialog {
/**
* Send the TAFs individually or as a collective.
*/
private boolean sendCollective;
private final boolean sendCollective;
/**
* Constructor.
@ -346,6 +348,7 @@ public class SendDialog extends CaveSWTDialog {
private void sendAction() {
TafQueueRequest request = new TafQueueRequest();
request.setType(Type.CREATE);
request.setUser(UserController.getUserObject());
// Forecaster ID
int forecasterId = forecasterArray.get(personList.getSelectionIndex())
@ -473,11 +476,12 @@ public class SendDialog extends CaveSWTDialog {
try {
TafQueueRequest request = new TafQueueRequest();
request.setType(Type.GET_LIST);
request.setUser(UserController.getUserObject());
request.setState(TafQueueRecord.TafQueueState.SENT);
ServerResponse<java.util.List<String>> response = (ServerResponse<java.util.List<String>>) ThriftClient
.sendRequest(request);
java.util.List<String> payload = response.getPayload();
String[] records = (String[]) payload.toArray(new String[0]);
String[] records = payload.toArray(new String[0]);
int numRecords = records.length;
for (int i = numRecords - 1; i >= 0; i--) {
if (records[i].contains(siteId)) {

View file

@ -42,6 +42,7 @@ import com.raytheon.uf.common.tafqueue.ServerResponse;
import com.raytheon.uf.common.tafqueue.TafQueueRecord.TafQueueState;
import com.raytheon.uf.common.tafqueue.TafQueueRequest;
import com.raytheon.uf.common.tafqueue.TafQueueRequest.Type;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.aviation.resource.ResourceConfigMgr;
@ -62,6 +63,7 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList;
* 14 MAY 2012 14715 rferrel Use EDEX to perform requests.
* 10 OCT 2012 1229 rferrel Make dialog non-blocking.
* 10 OCT 2012 1229 rferrel Changes for non-blocking HelpUsageDlg.
* 07 JUN 2013 1981 mpduff Set user on the request.
*
* </pre>
*
@ -113,8 +115,8 @@ public class TransmissionQueueDlg extends CaveSWTDialog {
*
* @author lvenable
*/
private String[] dayOfWeek = new String[] { "Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday" };
private final String[] dayOfWeek = new String[] { "Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
/**
* The Selected day of the week Calendar day of the week value.
@ -306,8 +308,7 @@ public class TransmissionQueueDlg extends CaveSWTDialog {
+ " moved back to 'pending'. The transmission time (the last\n"
+ " part of the file name) is updated to the current time.\n"
+ " Help: displays this window";
usageDlg = new HelpUsageDlg(shell, description,
helpText);
usageDlg = new HelpUsageDlg(shell, description, helpText);
usageDlg.open();
} else {
usageDlg.bringToTop();
@ -333,6 +334,7 @@ public class TransmissionQueueDlg extends CaveSWTDialog {
request.setType(Type.RETRANSMIT);
request.setState(getDisplayState());
request.setArgument(idList);
request.setUser(UserController.getUserObject());
try {
ServerResponse<java.util.List<String>> response = (ServerResponse<java.util.List<String>>) ThriftClient
@ -384,6 +386,8 @@ public class TransmissionQueueDlg extends CaveSWTDialog {
TafQueueRequest request = new TafQueueRequest();
request.setType(Type.GET_TAFS);
request.setArgument(idList);
request.setUser(UserController.getUserObject());
ServerResponse<String> response = null;
try {
response = (ServerResponse<String>) ThriftClient
@ -426,6 +430,7 @@ public class TransmissionQueueDlg extends CaveSWTDialog {
request.setType(Type.REMOVE_SELECTED);
request.setState(getDisplayState());
request.setArgument(idList);
request.setUser(UserController.getUserObject());
try {
ServerResponse<java.util.List<String>> response = (ServerResponse<java.util.List<String>>) ThriftClient
@ -634,6 +639,7 @@ public class TransmissionQueueDlg extends CaveSWTDialog {
selectedDayEnd.add(Calendar.DAY_OF_MONTH, 1);
dateList.add(selectedDayEnd.getTime());
request.setArgument(dateList);
request.setUser(UserController.getUserObject());
try {
ServerResponse<String> response = (ServerResponse<String>) ThriftClient
@ -660,6 +666,7 @@ public class TransmissionQueueDlg extends CaveSWTDialog {
request.setType(Type.GET_LIST);
request.setState(getDisplayState());
request.setUser(UserController.getUserObject());
ServerResponse<java.util.List<String>> response = (ServerResponse<java.util.List<String>>) ThriftClient
.sendRequest(request);

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.SimulatedTime;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.core.mode.CAVEMode;
@ -68,6 +69,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 02apr2013 15564 mgamazaychikov Ensured awipsWanPil to be 10 characters space-padded long
* 08 MAY 2013 1842 dgilling Use VtecUtil to set product ETNs, fix
* warnings.
* 07 Jun 2013 1981 mpduff Set user's id in OUPRequest as it is now a protected operation.
* </pre>
*
* @author lvenable
@ -120,15 +122,15 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
private String productText;
private ProductEditorComp parentEditor;
private final ProductEditorComp parentEditor;
/**
* Product transmission callback to report the state of transmitting a
* product.
*/
private ITransmissionState transmissionCB;
private final ITransmissionState transmissionCB;
private String pid;
private final String pid;
/**
* Constructor.
@ -427,7 +429,9 @@ public class StoreTransmitDlg extends CaveSWTDialog implements
oup.setNeedsWmoHeader(false);
oup.setSource("GFE");
((OUPRequest) req).setProduct(oup);
((OUPRequest) req).setUser(UserController.getUserObject());
}
try {
Object response = ThriftClient.sendRequest(req);
// TODO need a response on the other one? it's going

View file

@ -30,7 +30,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.viz.ui.personalities.awips;bundle-version="1.12.1174",
com.raytheon.uf.viz.application;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin.shef;bundle-version="1.12.1174",
com.raytheon.viz.pointdata;bundle-version="1.12.1174"
com.raytheon.viz.pointdata;bundle-version="1.12.1174",
com.raytheon.uf.common.auth;bundle-version="1.12.1174"
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.hydro,
com.raytheon.viz.hydro.perspective,

View file

@ -77,6 +77,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.SimulatedTime;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.hydro.timeseries.table.DataRecord;
@ -126,6 +127,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Feb 05,2013 1578 rferrel Changes for non-blocking singleton TimeSeriesDlg.
* Code clean up for non-blocking dialog.
* Feb 27,2013 1790 rferrel Bug fix for non-blocking dialogs.
* Jun 07, 2013 1981 mpduff Set user's id on the OUPRequest as it is now protected.
*
* </pre>
*
@ -188,19 +190,21 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
/**
* Simple date formatter.
*/
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private final SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm");
/**
* Simple date formatter for the forecast basis time.
*/
private SimpleDateFormat prodBasisFmt = new SimpleDateFormat(
private final SimpleDateFormat prodBasisFmt = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
/** Date format for shef information. */
private SimpleDateFormat shefDateFormat = new SimpleDateFormat("yyyyMMdd");
private final SimpleDateFormat shefDateFormat = new SimpleDateFormat(
"yyyyMMdd");
/** Time format for shef information. */
private SimpleDateFormat shefTimeFormat = new SimpleDateFormat("HHmm");
private final SimpleDateFormat shefTimeFormat = new SimpleDateFormat("HHmm");
/**
* Date & Time label.
@ -210,12 +214,12 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
/**
* Beginning time.
*/
private Date beginningTime;
private final Date beginningTime;
/**
* Ending time.
*/
private Date endingTime;
private final Date endingTime;
/**
* List all forecasts check box.
@ -394,7 +398,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
private String siteLabel = null;
/** The list of data for the bottom data display list */
private ArrayList<String> modifiedTSList = new ArrayList<String>();
private final ArrayList<String> modifiedTSList = new ArrayList<String>();
/** The parent dialog */
private TimeSeriesDlg parentDialog = null;
@ -3067,6 +3071,7 @@ public class TabularTimeSeriesDlg extends CaveSWTDialog implements
oup.setNeedsWmoHeader(true);
oup.setFilename(SHEF_FILE_NAME + "." + getPid());
oup.setProductText(text);
req.setUser(UserController.getUserObject());
req.setCheckBBB(true);
req.setProduct(oup);

View file

@ -24,7 +24,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.site;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin.radar;bundle-version="1.0.0",
org.apache.commons.logging,
com.raytheon.uf.viz.localization
com.raytheon.uf.viz.localization,
com.raytheon.uf.common.auth;bundle-version="1.12.1174"
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.texteditor,
com.raytheon.viz.texteditor.alarmalert.dialogs,

View file

@ -142,6 +142,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
import com.raytheon.uf.edex.services.textdbsrv.IQueryTransport;
import com.raytheon.uf.edex.wmo.message.WMOHeader;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.notification.INotificationObserver;
import com.raytheon.uf.viz.core.notification.NotificationException;
@ -320,6 +321,7 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox;
* 31JAN2013 1563 rferrel Force location of airport tooltip.
* 31JAN2013 1568 rferrel Spell checker now tied to this dialog instead of parent.
* 26Apr2013 16123 snaples Removed setFocus to TextEditor in postExecute method.
* 07Jun2013 1981 mpduff Add user id to OUPRequest as it is now protected.
* </pre>
*
* @author lvenable
@ -4491,7 +4493,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
String tmpText = textEditor.getText();
Point point = textEditor.getSelection();
FontData fontData = textEditor.getFont().getFontData()[0];
PrintDisplay.print(textEditor.getSelectionText(), fontData,
PrintDisplay.print(textEditor.getSelectionText(), fontData,
statusHandler);
textEditor.setText(tmpText);
textEditor.setSelection(point);
@ -4936,6 +4938,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
req.setCheckBBB(true);
req.setProduct(oup);
req.setUser(UserController.getUserObject());
// Code in Run statement goes here!
new Thread(new ThriftClientRunnable(req)).start();
@ -5522,29 +5525,27 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
int numberOfLinesOfHeaderText = 2;
int afosNnnLimit = 2; // first three characters is AFOS NNN
int afosXxxLimit = 5; // second three characters is AFOS XXX
/*
* DR15610 - Make sure that if the first line of the
* text product is not a WMO heading it is treated as
* part of the text body.
* DR15610 - Make sure that if the first line of the text product is not
* a WMO heading it is treated as part of the text body.
*/
String[] pieces = textEditor.getText().split("\r*\n", 2);
if (pieces.length > 1) {
pieces[0] += "\n"; // WMOHeader expects this
}
WMOHeader header = new WMOHeader(pieces[0].getBytes(), null);
if ( !header.isValid() ) {
headerTF.setText("");
try {
textEditor.setText(originalText);
textEditor.setEditable(true);
textEditor.setEditable(false);
} catch (IllegalArgumentException e) {
// There is no text product body, so set it to the empty string.
textEditor.setText("");
}
}
else {
if (!header.isValid()) {
headerTF.setText("");
try {
textEditor.setText(originalText);
textEditor.setEditable(true);
textEditor.setEditable(false);
} catch (IllegalArgumentException e) {
// There is no text product body, so set it to the empty string.
textEditor.setText("");
}
} else {
// TODO FIX PARSING
// First, set the current header by assuming that it usually
@ -5552,7 +5553,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// though there will be exceptions to that "rule" as handled below.
// So, obtain the AFOS NNNxxx. If it's where it is supposed to be
// in the new format, then the existing header is already an AWIPS
// text product identifier. Otherwise it is a legacy AFOS identifier.
// text product identifier. Otherwise it is a legacy AFOS
// identifier.
if (TextDisplayModel.getInstance().hasStdTextProduct(token)) {
StdTextProduct textProd = TextDisplayModel.getInstance()
.getStdTextProduct(token);
@ -5562,14 +5564,16 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
start = textEditor.getOffsetAtLine(thisLine + 1);
if ((textEditor.getText(start, start + afosNnnLimit)
.equals(prodId.getNnnid()))
&& (textEditor.getText(start + afosNnnLimit + 1, start
+ afosXxxLimit).equals(prodId.getXxxid()))) {
&& (textEditor.getText(start + afosNnnLimit + 1,
start + afosXxxLimit).equals(prodId
.getXxxid()))) {
// Text matches the products nnnid and xxxid
numberOfLinesOfHeaderText = 2;
} else if (textEditor.getText(start, start + afosNnnLimit + 2)
.equals(AFOSParser.DRAFT_PIL)
|| textEditor.getText(start, start + afosNnnLimit + 2)
.equals("TTAA0")) {
} else if (textEditor.getText(start,
start + afosNnnLimit + 2).equals(
AFOSParser.DRAFT_PIL)
|| textEditor.getText(start,
start + afosNnnLimit + 2).equals("TTAA0")) {
// Text matches temporary WRKWG#
numberOfLinesOfHeaderText = 2;
} else {
@ -5592,7 +5596,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
finish = textEditor.getCharCount() - 1;
}
// Set the content of the header block to consist of just the header of
// Set the content of the header block to consist of just the header
// of
// the text product... it will get reunited with the body when it is
// saved.
if (finish > start) {
@ -5609,8 +5614,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
String line = null;
do {
numberOfBlankLines++;
line = textEditor.getLine(thisLine + numberOfLinesOfHeaderText
+ numberOfBlankLines);
line = textEditor.getLine(thisLine
+ numberOfLinesOfHeaderText + numberOfBlankLines);
} while (line.length() == 0 || line.equals(""));
// Note: 'st' is a reference to 'textEditor'...
// delelete the header from the text in 'textEditor'
@ -5915,7 +5920,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
if ("MTR".equals(stdProdId.getNnnid())
&& (commandText.startsWith("ALL:")
|| commandText.startsWith("A:") || commandText
.endsWith("000"))) {
.endsWith("000"))) {
stripWMOHeaders(prod);
}
@ -7008,7 +7013,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|| line.endsWith("ADVISORY")
|| line.endsWith("ADVISORY...TEST")
|| line.endsWith("ADVISORY...CORRECTED") || line
.endsWith("ADVISORY...CORRECTED...TEST"))) {
.endsWith("ADVISORY...CORRECTED...TEST"))) {
line += "...RESENT";
updatedMND = true;
}

View file

@ -8,4 +8,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
Import-Package: com.raytheon.uf.common.serialization.comm
Export-Package: com.raytheon.uf.common.dissemination
Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.11.17"
Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.11.17",
com.raytheon.uf.common.auth;bundle-version="1.12.1174"

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.common.dissemination;
import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
@ -32,6 +34,7 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 29, 2009 njensen Initial creation
* Jun 07, 2013 1981 mpduff This is now a privileged request.
*
* </pre>
*
@ -39,7 +42,10 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
* @version 1.0
*/
@DynamicSerialize
public class OUPRequest implements IServerRequest {
public class OUPRequest extends AbstractPrivilegedRequest implements
IServerRequest {
/** Edex origination constant */
public static transient final String EDEX_ORIGINATION = "edex_origination";
@DynamicSerializeElement
private OfficialUserProduct product;
@ -47,6 +53,20 @@ public class OUPRequest implements IServerRequest {
@DynamicSerializeElement
private boolean checkBBB = false;
/** User object */
@DynamicSerializeElement
private IUser user;
/** A not authorized message */
@DynamicSerializeElement
private String NotAuthorizedMessage = "Not Authorized to Send Official User Products";
/**
* OUP Request permission. This should not be changed.
*/
@DynamicSerializeElement
private String roleId = "awips.oup";
public OfficialUserProduct getProduct() {
return product;
}
@ -63,4 +83,50 @@ public class OUPRequest implements IServerRequest {
this.checkBBB = checkBBB;
}
/**
* @return the user
*/
@Override
public IUser getUser() {
return user;
}
/**
* @param user
* the user to set
*/
@Override
public void setUser(IUser user) {
this.user = user;
}
/**
* @return the roleId
*/
public String getRoleId() {
return roleId;
}
/**
* @param roleId
* the roleId to set
*/
public void setRoleId(String roleId) {
this.roleId = roleId;
}
/**
* @return the notAuthorizedMessage
*/
public String getNotAuthorizedMessage() {
return NotAuthorizedMessage;
}
/**
* @param notAuthorizedMessage
* the notAuthorizedMessage to set
*/
public void setNotAuthorizedMessage(String notAuthorizedMessage) {
NotAuthorizedMessage = notAuthorizedMessage;
}
}

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nwsRoleData xmlns:ns2="group">
<!-- AWIPS 2 User Admin Roles/Permissions file -->
<application>Official User Product</application>
<permission id="awips.oup">
<description>
This permission allows the user to send Official User Products
</description>
</permission>
<user userId="ALL">
<userPermission>awips.oup</userPermission>
</user>
</nwsRoleData>

View file

@ -9,7 +9,8 @@ Require-Bundle: com.raytheon.edex.common;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
javax.persistence;bundle-version="1.0.0",
org.apache.commons.lang;bundle-version="2.3.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.auth;bundle-version="1.12.1174"
Export-Package: com.raytheon.uf.common.tafqueue
Import-Package: com.raytheon.uf.common.localization,
org.apache.commons.configuration

View file

@ -22,6 +22,8 @@ package com.raytheon.uf.common.tafqueue;
import java.util.Date;
import java.util.List;
import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
@ -35,7 +37,8 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 3, 2012 14715 rferrel Initial creation
* May 3, 2012 14715 rferrel Initial creation
* Jun 07, 2013 1981 mpduff This is now an AbstractPrivilegedRequest
*
* </pre>
*
@ -43,7 +46,8 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
* @version 1.0
*/
@DynamicSerialize
public class TafQueueRequest implements IServerRequest {
public class TafQueueRequest extends AbstractPrivilegedRequest implements
IServerRequest {
public enum Type {
UNKNOWN, CREATE, GET_LIST, GET_LOG, GET_TAFS, REMOVE_SELECTED, RETRANSMIT
@ -64,6 +68,20 @@ public class TafQueueRequest implements IServerRequest {
@DynamicSerializeElement
private Date xmitTime;
/** User object */
@DynamicSerializeElement
private IUser user;
/** A not authorized message */
@DynamicSerializeElement
private final String NotAuthorizedMessage = "Not Authorized to Send Official User Products";
/**
* OUP Request permission. This should not be changed.
*/
@DynamicSerializeElement
private final String roleId = "awips.oup";
public TafQueueRequest() {
this.type = Type.UNKNOWN;
}
@ -107,4 +125,35 @@ public class TafQueueRequest implements IServerRequest {
public void setXmitTime(Date xmitTime) {
this.xmitTime = xmitTime;
}
/**
* @return the user
*/
@Override
public IUser getUser() {
return user;
}
/**
* @param user
* the user to set
*/
@Override
public void setUser(IUser user) {
this.user = user;
}
/**
* @return the notAuthorizedMessage
*/
public String getNotAuthorizedMessage() {
return NotAuthorizedMessage;
}
/**
* @return the roleId
*/
public String getRoleId() {
return roleId;
}
}

View file

@ -23,4 +23,6 @@ Require-Bundle: org.jep;bundle-version="1.0.0",
com.raytheon.edex.plugin.text,
com.raytheon.uf.common.site;bundle-version="1.12.1174",
org.springframework;bundle-version="2.5.6",
com.raytheon.uf.edex.database
com.raytheon.uf.edex.database,
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.edex.auth;bundle-version="1.12.1174"

View file

@ -25,6 +25,8 @@ import java.util.Map;
import jep.JepException;
import com.raytheon.uf.common.auth.exception.AuthorizationException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.dissemination.OUPRequest;
import com.raytheon.uf.common.dissemination.OUPResponse;
import com.raytheon.uf.common.dissemination.OfficialUserProduct;
@ -35,12 +37,15 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonScript;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.edex.auth.AuthManager;
import com.raytheon.uf.edex.auth.AuthManagerFactory;
import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler;
import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
import com.raytheon.uf.edex.auth.roles.IRoleStorage;
import com.raytheon.uf.edex.dissemination.transmitted.TransProdHeader;
import com.raytheon.uf.edex.dissemination.transmitted.TransmittedProductList;
/**
* IRequestHandler for OUPRequests
@ -52,6 +57,7 @@ import com.raytheon.uf.edex.dissemination.transmitted.TransmittedProductList;
* ------------ ---------- ----------- --------------------------
* Oct 22, 2009 njensen Initial creation
* Oct 12, 2012 DR 15418 D. Friedman Use clustered TransmittedProductList
* Jun 07, 2013 1981 mpduff This is now a priviledged request handler.
*
* </pre>
*
@ -59,10 +65,13 @@ import com.raytheon.uf.edex.dissemination.transmitted.TransmittedProductList;
* @version 1.0
*/
public class OUPHandler implements IRequestHandler<OUPRequest> {
private static final transient IUFStatusHandler statusHandler = UFStatus
public class OUPHandler extends AbstractPrivilegedRequestHandler<OUPRequest> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(OUPHandler.class);
/** The application for authentication */
private static final String APPLICATION = "Official User Product";
private OUPAckManager ackManager;
@Override
@ -98,7 +107,7 @@ public class OUPHandler implements IRequestHandler<OUPRequest> {
resp.setAttempted(true);
py.execute("process", args);
} catch (JepException e) {
resp.setMessage("Error executing handleOUP python");
resp.setMessage("Error executing handleOUP python");
statusHandler.handle(Priority.SIGNIFICANT,
"Error executing handleOUP python", e);
} finally {
@ -106,8 +115,9 @@ public class OUPHandler implements IRequestHandler<OUPRequest> {
py.dispose();
}
}
/* TODO: Should be updating TransmittedProductList here, after
* success has been confirmed.
/*
* TODO: Should be updating TransmittedProductList here, after
* success has been confirmed.
*/
} catch (OUPHeaderException e) {
resp.setAttempted(false);
@ -160,12 +170,38 @@ public class OUPHandler implements IRequestHandler<OUPRequest> {
return python;
}
public OUPAckManager getAckManager() {
return ackManager;
}
public OUPAckManager getAckManager() {
return ackManager;
}
public void setAckManager(OUPAckManager ackManager) {
this.ackManager = ackManager;
}
public void setAckManager(OUPAckManager ackManager) {
this.ackManager = ackManager;
}
/**
* {@inheritDoc}
*/
@Override
public AuthorizationResponse authorized(IUser user, OUPRequest request)
throws AuthorizationException {
boolean authorized = false;
if (request.getUser().uniqueId().toString()
.equals(OUPRequest.EDEX_ORIGINATION)) {
authorized = true;
} else {
AuthManager manager = AuthManagerFactory.getInstance().getManager();
IRoleStorage roleStorage = manager.getRoleStorage();
authorized = roleStorage.isAuthorized((request).getRoleId(), user
.uniqueId().toString(), APPLICATION);
}
if (authorized) {
return new AuthorizationResponse(authorized);
} else {
return new AuthorizationResponse(
(request).getNotAuthorizedMessage());
}
}
}

View file

@ -11,7 +11,10 @@ Require-Bundle: com.raytheon.edex.common;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174",
javax.persistence;bundle-version="1.0.0",
org.apache.commons.lang;bundle-version="2.3.0"
org.apache.commons.lang;bundle-version="2.3.0",
com.raytheon.uf.common.auth;bundle-version="1.12.1174",
com.raytheon.uf.edex.auth;bundle-version="1.12.1174",
com.raytheon.uf.common.plugin.nwsauth;bundle-version="1.12.1174"
Import-Package: com.raytheon.uf.common.localization,
org.apache.commons.configuration
Export-Package: com.raytheon.uf.edex.tafqueue

View file

@ -29,6 +29,7 @@ import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dissemination.OUPRequest;
import com.raytheon.uf.common.dissemination.OUPResponse;
import com.raytheon.uf.common.dissemination.OfficialUserProduct;
import com.raytheon.uf.common.plugin.nwsauth.user.User;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -49,6 +50,7 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
* ------------ ---------- ----------- --------------------------
* May 10, 2012 14715 rferrel Initial creation
* Mar 21, 2013 15375 zhao Modified to also handle AvnFPS VFT product
* Jun 07, 2013 1981 mpduff Add user to OUPRequest.
*
* </pre>
*
@ -183,6 +185,7 @@ public class TafQueueManager implements Runnable {
}
OUPRequest req = new OUPRequest();
req.setUser(new User(OUPRequest.EDEX_ORIGINATION));
req.setProduct(oup);
OUPResponse resp;
boolean success = false;
@ -241,16 +244,16 @@ public class TafQueueManager implements Runnable {
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
Date nextPurgeTime = cal.getTime();
/**
* (for DR15375)
*/
TafQueueVFTMgr vftMgr = TafQueueVFTMgr.getInstance();
TafQueueVFTMgr vftMgr = TafQueueVFTMgr.getInstance();
Date nextVftTime = null;
while (true) {
try {
processList = dao.getRecordsToSend();
if (processList.size() > 0) {
@ -258,15 +261,15 @@ public class TafQueueManager implements Runnable {
// more PENDING may have been added while sending
continue;
}
/**
* (for DR15375)
*/
nextVftTime = vftMgr.getNextVftTime();
if ( nextVftTime.compareTo(Calendar.getInstance().getTime()) <= 0 ) {
vftMgr.makeVftProduct();
// transmit immediately
continue;
nextVftTime = vftMgr.getNextVftTime();
if (nextVftTime.compareTo(Calendar.getInstance().getTime()) <= 0) {
vftMgr.makeVftProduct();
// transmit immediately
continue;
}
if (nextPurgeTime.compareTo(Calendar.getInstance().getTime()) <= 0) {
@ -284,17 +287,18 @@ public class TafQueueManager implements Runnable {
nextProccessTime = nextPurgeTime;
} else if (nextProccessTime.compareTo(nextPurgeTime) > 0) {
nextProccessTime = nextPurgeTime;
} else if (nextProccessTime.compareTo(Calendar.getInstance().getTime()) <= 0) {
} else if (nextProccessTime.compareTo(Calendar.getInstance()
.getTime()) <= 0) {
// immediate transmit placed on queue while processing.
continue;
}
/**
* (DR15375)
*/
nextVftTime = vftMgr.getNextVftTime();
if ( nextVftTime.compareTo(nextProccessTime) < 0 ) {
nextProccessTime = nextVftTime;
if (nextVftTime.compareTo(nextProccessTime) < 0) {
nextProccessTime = nextVftTime;
}
synchronized (this) {

View file

@ -23,14 +23,20 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
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.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.tafqueue.ServerResponse;
import com.raytheon.uf.common.tafqueue.TafQueueRecord;
import com.raytheon.uf.common.tafqueue.TafQueueRecord.TafQueueState;
import com.raytheon.uf.common.tafqueue.TafQueueRequest;
import com.raytheon.uf.common.tafqueue.TafQueueRequest.Type;
import com.raytheon.uf.edex.auth.AuthManager;
import com.raytheon.uf.edex.auth.AuthManagerFactory;
import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler;
import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
import com.raytheon.uf.edex.auth.roles.IRoleStorage;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.core.EdexException;
import com.raytheon.uf.edex.database.DataAccessLayerException;
@ -46,12 +52,16 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
* ------------ ---------- ----------- --------------------------
* May 1, 2012 14715 rferrel Initial creation
* May 08, 2013 1814 rjpeter Added time to live to topic
* Jun 07, 2013 1981 mpduff TafQueueRequest is now protected.
* </pre>
*
* @author rferrel
* @version 1.0
*/
public class TafQueueRequestHandler implements IRequestHandler<TafQueueRequest> {
public class TafQueueRequestHandler extends
AbstractPrivilegedRequestHandler<TafQueueRequest> {
/** The application for authentication */
private static final String APPLICATION = "Official User Product";
/*
* (non-Javadoc)
@ -194,4 +204,24 @@ public class TafQueueRequestHandler implements IRequestHandler<TafQueueRequest>
EDEXUtil.getMessageProducer().sendAsyncUri(
"jms-generic:topic:tafQueueChanged?timeToLive=60000", message);
}
/**
* {@inheritDoc}
*/
@Override
public AuthorizationResponse authorized(IUser user, TafQueueRequest request)
throws AuthorizationException {
AuthManager manager = AuthManagerFactory.getInstance().getManager();
IRoleStorage roleStorage = manager.getRoleStorage();
boolean authorized = roleStorage.isAuthorized((request).getRoleId(),
user.uniqueId().toString(), APPLICATION);
if (authorized) {
return new AuthorizationResponse(authorized);
} else {
return new AuthorizationResponse(
(request).getNotAuthorizedMessage());
}
}
}

View file

@ -94,6 +94,11 @@ public class TestUserManagerLoader implements IUserManagerLoader {
public List<IRole> getRoles(String application) {
return Collections.emptyList();
}
@Override
public void updateUserObject(String userId, IAuthenticationData authData) {
// Currently unused
}
}
private static final TestUserManager USER_MANAGER = new TestUserManager();