├── saserverlibrary └── src │ ├── main │ ├── sass │ │ ├── .gitignore │ │ ├── sass │ │ │ ├── print.scss │ │ │ ├── ie.scss │ │ │ ├── _forms.scss │ │ │ ├── _commonSettings.scss │ │ │ └── _header.scss │ │ └── config.rb │ ├── resources │ │ ├── css │ │ │ ├── README.txt │ │ │ ├── print.css │ │ │ └── ie.css │ │ ├── images │ │ │ ├── attLogo.gif │ │ │ ├── dimmer.png │ │ │ ├── dimmer.xcf │ │ │ └── att_vt_1cp_grd_rev.gif │ │ ├── templates │ │ │ ├── main.html │ │ │ ├── error.html │ │ │ ├── footer.html │ │ │ ├── older │ │ │ │ ├── cg.html │ │ │ │ ├── topo.html │ │ │ │ ├── activeAlarm.html │ │ │ │ ├── injector.html │ │ │ │ ├── activeCg.html │ │ │ │ ├── corrEvent.html │ │ │ │ ├── wm.html │ │ │ │ ├── corr.html │ │ │ │ ├── _cgListing.html │ │ │ │ ├── traverse.html │ │ │ │ └── cons.html │ │ │ ├── metrics.html │ │ │ └── header.html │ │ ├── font-awesome │ │ │ ├── fonts │ │ │ │ ├── FontAwesome.otf │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ └── fontawesome-webfont.woff │ │ │ ├── less │ │ │ │ ├── fixed-width.less │ │ │ │ ├── core.less │ │ │ │ ├── bordered-pulled.less │ │ │ │ ├── rotated-flipped.less │ │ │ │ ├── larger.less │ │ │ │ ├── list.less │ │ │ │ ├── font-awesome.less │ │ │ │ ├── stacked.less │ │ │ │ ├── path.less │ │ │ │ ├── mixins.less │ │ │ │ └── spinning.less │ │ │ └── scss │ │ │ │ ├── _fixed-width.scss │ │ │ │ ├── _core.scss │ │ │ │ ├── _bordered-pulled.scss │ │ │ │ ├── _larger.scss │ │ │ │ ├── _rotated-flipped.scss │ │ │ │ ├── _list.scss │ │ │ │ ├── font-awesome.scss │ │ │ │ ├── _stacked.scss │ │ │ │ ├── _path.scss │ │ │ │ ├── _mixins.scss │ │ │ │ └── _spinning.scss │ │ ├── iamRoutes.conf │ │ └── uiRoutes.conf │ └── java │ │ └── com │ │ └── att │ │ └── nsa │ │ ├── drumlin │ │ ├── README.txt │ │ ├── app │ │ │ ├── userAgents │ │ │ │ ├── browsers │ │ │ │ │ ├── browser.java │ │ │ │ │ ├── chromeBrowser.java │ │ │ │ │ ├── safariBrowser.java │ │ │ │ │ ├── firefoxBrowser.java │ │ │ │ │ └── genericBrowser.java │ │ │ │ ├── devices │ │ │ │ │ ├── ios │ │ │ │ │ │ ├── iPhone3.java │ │ │ │ │ │ ├── iPhone4.java │ │ │ │ │ │ ├── iPhone5.java │ │ │ │ │ │ └── iPhone.java │ │ │ │ │ ├── device.java │ │ │ │ │ ├── unknownFixedScreen.java │ │ │ │ │ ├── android │ │ │ │ │ │ └── androidDevice.java │ │ │ │ │ ├── screenInfo.java │ │ │ │ │ ├── computers │ │ │ │ │ │ └── macintosh.java │ │ │ │ │ └── genericDevice.java │ │ │ │ ├── userAgent.java │ │ │ │ ├── userAgentFeature.java │ │ │ │ └── genericAgent.java │ │ │ └── htmlForms │ │ │ │ ├── mime │ │ │ │ ├── DrumlinMimePartFactory.java │ │ │ │ └── DrumlinMimePart.java │ │ │ │ └── DrumlinFormValidationStep.java │ │ ├── till │ │ │ ├── console │ │ │ │ ├── shell │ │ │ │ │ ├── commandList.java │ │ │ │ │ ├── command.java │ │ │ │ │ └── simpleCommand.java │ │ │ │ ├── consoleLineReader.java │ │ │ │ └── cmdLinePrefs.java │ │ │ ├── nv │ │ │ │ ├── rrNvWriteable.java │ │ │ │ ├── impl │ │ │ │ │ ├── nvJvmSettings.java │ │ │ │ │ ├── nvBaseWriteable.java │ │ │ │ │ ├── nvWriteableTable.java │ │ │ │ │ ├── nvReadableTable.java │ │ │ │ │ └── nvReadableStack.java │ │ │ │ └── rrNvReadable.java │ │ │ ├── data │ │ │ │ ├── base64 │ │ │ │ │ ├── rrcBase64Constants.java │ │ │ │ │ └── rrcBase64OutputStream.java │ │ │ │ ├── sha1HmacSigner.java │ │ │ │ ├── uniqueStringGenerator.java │ │ │ │ └── oneWayHasher.java │ │ │ ├── time │ │ │ │ └── clock.java │ │ │ └── store │ │ │ │ └── rrJsonObjectFile.java │ │ ├── service │ │ │ ├── framework │ │ │ │ ├── DrumlinErrorHandler.java │ │ │ │ ├── rendering │ │ │ │ │ ├── vtlTools │ │ │ │ │ │ └── DrumlinVtlHelper.java │ │ │ │ │ └── DrumlinRenderContext.java │ │ │ │ ├── DrumlinConnectionContext.java │ │ │ │ ├── routing │ │ │ │ │ ├── playish │ │ │ │ │ │ ├── DrumlinPlayishRouteHandler.java │ │ │ │ │ │ ├── RedirectHandler.java │ │ │ │ │ │ ├── TemplateDirHandler.java │ │ │ │ │ │ └── StaticFileHandler.java │ │ │ │ │ ├── DrumlinSimpleRouteHandler.java │ │ │ │ │ ├── DrumlinRouteInvocation.java │ │ │ │ │ └── DrumlinRouteSource.java │ │ │ │ ├── DrumlinServletSettings.java │ │ │ │ ├── DrumlinConnection.java │ │ │ │ ├── DrumlinRuntimeControls.java │ │ │ │ └── context │ │ │ │ │ ├── DrumlinResponse.java │ │ │ │ │ └── stdRenderer.java │ │ │ └── standards │ │ │ │ ├── HttpMethods.java │ │ │ │ ├── MimeTypes.java │ │ │ │ └── HttpStatusCodes.java │ │ └── util │ │ │ ├── JsonBodyWriter.java │ │ │ ├── VeloJsonObject.java │ │ │ └── rrVeloLogBridge.java │ │ ├── apiServer │ │ ├── Settings.java │ │ ├── util │ │ │ ├── NsaJvmClock.java │ │ │ ├── NsaClock.java │ │ │ └── NsaTestClock.java │ │ └── NsaAppException.java │ │ ├── ui │ │ ├── endpoints │ │ │ └── UiMain.java │ │ ├── UiPlugin.java │ │ ├── velocity │ │ │ └── UiVelocityEventHandler.java │ │ ├── UiSession.java │ │ └── UiTomcatServer.java │ │ ├── security │ │ ├── NsaSecurityManagerException.java │ │ ├── db │ │ │ ├── ResourceExistsException.java │ │ │ ├── NsaApiKeyFactory.java │ │ │ ├── AuthorizationServiceUnavailableException.java │ │ │ ├── simple │ │ │ │ ├── NsaSimpleApiKeyFactory.java │ │ │ │ └── NsaSimpleRemoteApiKey.java │ │ │ ├── NsaAuthDb.java │ │ │ ├── EncryptingApiDbImpl.java │ │ │ └── NsaApiDb.java │ │ ├── NsaAuthenticator.java │ │ ├── authenticators │ │ │ ├── MechIdAuthenticator.java │ │ │ └── SimpleAuthenticator.java │ │ ├── NsaApiKey.java │ │ ├── NsaAuthenticatorService.java │ │ ├── NsaAuthorizationService.java │ │ └── ReadWriteSecuredResource.java │ │ └── cmdLine │ │ └── NsaCommandLineUtil.java │ └── test │ ├── resources │ └── keystore.dummy │ └── java │ └── com │ └── att │ └── nsa │ ├── security │ ├── NsaAclUtilsTest.java │ ├── NsaAclTest.java │ ├── NsaApiDbTest.java │ ├── NsaApiOnZkDbTest.java │ └── authenticators │ │ └── OriginalUebAuthenticatorTest.java │ ├── drumlin │ └── till │ │ └── nv │ │ └── impl │ │ └── nvInstallTypeWrapperTest.java │ ├── configs │ └── confimpl │ │ ├── SimplePathTest.java │ │ └── MemConfigDbTest.java │ ├── timedata │ └── impl │ │ └── mem │ │ └── MemTsDbTest.java │ └── apiServer │ └── ApiServerTest.java ├── README.md ├── Jenkinsfile ├── Contributing.txt └── LICENSE /saserverlibrary/src/main/sass/.gitignore: -------------------------------------------------------------------------------- 1 | .sass-cache 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NSASERVER 2 | Network Service Assurance Server Library 3 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/css/README.txt: -------------------------------------------------------------------------------- 1 | Note that the css files here should be built via Sass, but that's not in the POM yet. 2 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/resources/keystore.dummy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att/NSASERVER/master/saserverlibrary/src/test/resources/keystore.dummy -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/images/attLogo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att/NSASERVER/master/saserverlibrary/src/main/resources/images/attLogo.gif -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/images/dimmer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att/NSASERVER/master/saserverlibrary/src/main/resources/images/dimmer.png -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/images/dimmer.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att/NSASERVER/master/saserverlibrary/src/main/resources/images/dimmer.xcf -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/images/att_vt_1cp_grd_rev.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att/NSASERVER/master/saserverlibrary/src/main/resources/images/att_vt_1cp_grd_rev.gif -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/main.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |

Choose a menu item above.

5 | 6 | #parse ( "footer.html" ) 7 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att/NSASERVER/master/saserverlibrary/src/main/resources/font-awesome/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att/NSASERVER/master/saserverlibrary/src/main/resources/font-awesome/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att/NSASERVER/master/saserverlibrary/src/main/resources/font-awesome/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/att/NSASERVER/master/saserverlibrary/src/main/resources/font-awesome/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/fixed-width.less: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .@{fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_fixed-width.scss: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .#{$fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/README.txt: -------------------------------------------------------------------------------- 1 | The code in the Drumlin package comes from my Apache licensed Drumlin 2 | project, available in full at https://github.com/drumlin. 3 | 4 | -Peter Cardona / peter@rathravane.com / pc569h@att.com 5 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/css/print.css: -------------------------------------------------------------------------------- 1 | /* Welcome to Compass. Use this file to define print styles. 2 | * Import this file using the following HTML or equivalent: 3 | * */ 4 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/sass/sass/print.scss: -------------------------------------------------------------------------------- 1 | /* Welcome to Compass. Use this file to define print styles. 2 | * Import this file using the following HTML or equivalent: 3 | * */ 4 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | #if ( $msg ) 6 | $msg 7 | #else 8 | An error occurred; no further information is available. 9 | #end 10 |
11 | 12 | 13 | #parse ( "footer.html" ) 14 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | #foreach ( $script in $footerScripts ) 8 | 9 | #end 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/sass/sass/ie.scss: -------------------------------------------------------------------------------- 1 | /* Welcome to Compass. Use this file to write IE specific override styles. 2 | * Import this file using the following HTML or equivalent: 3 | * */ 6 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/css/ie.css: -------------------------------------------------------------------------------- 1 | /* Welcome to Compass. Use this file to write IE specific override styles. 2 | * Import this file using the following HTML or equivalent: 3 | * */ 6 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/cg.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 |
Correlation Group Detail
11 | 12 | #parse("_cgListing.html") 13 | 14 |
15 | 16 | #parse ( "footer.html" ) 17 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/core.less: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix} { 5 | display: inline-block; 6 | font-family: FontAwesome; 7 | font-style: normal; 8 | font-weight: normal; 9 | line-height: 1; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | } 13 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_core.scss: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix} { 5 | display: inline-block; 6 | font-family: FontAwesome; 7 | font-style: normal; 8 | font-weight: normal; 9 | line-height: 1; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | } 13 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/bordered-pulled.less: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em @fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .pull-right { float: right; } 11 | .pull-left { float: left; } 12 | 13 | .@{fa-css-prefix} { 14 | &.pull-left { margin-right: .3em; } 15 | &.pull-right { margin-left: .3em; } 16 | } 17 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/rotated-flipped.less: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-rotate-90 { .fa-icon-rotate(90deg, 1); } 5 | .@{fa-css-prefix}-rotate-180 { .fa-icon-rotate(180deg, 2); } 6 | .@{fa-css-prefix}-rotate-270 { .fa-icon-rotate(270deg, 3); } 7 | 8 | .@{fa-css-prefix}-flip-horizontal { .fa-icon-flip(-1, 1, 0); } 9 | .@{fa-css-prefix}-flip-vertical { .fa-icon-flip(1, -1, 2); } 10 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_bordered-pulled.scss: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em $fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .pull-right { float: right; } 11 | .pull-left { float: left; } 12 | 13 | .#{$fa-css-prefix} { 14 | &.pull-left { margin-right: .3em; } 15 | &.pull-right { margin-left: .3em; } 16 | } 17 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/browsers/browser.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.app.userAgents.browsers; 5 | 6 | public interface browser 7 | { 8 | String getName (); 9 | String getVersion (); 10 | } 11 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/larger.less: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .@{fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .@{fa-css-prefix}-2x { font-size: 2em; } 11 | .@{fa-css-prefix}-3x { font-size: 3em; } 12 | .@{fa-css-prefix}-4x { font-size: 4em; } 13 | .@{fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_larger.scss: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .#{$fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .#{$fa-css-prefix}-2x { font-size: 2em; } 11 | .#{$fa-css-prefix}-3x { font-size: 3em; } 12 | .#{$fa-css-prefix}-4x { font-size: 4em; } 13 | .#{$fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/topo.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 |
Alarms on $topoKey
11 | 12 |
13 | #foreach ( $alarm in $alarms ) 14 |
$alarm.eventId
15 | #end 16 |
17 | 18 |
19 | 20 | #parse ( "footer.html" ) 21 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/list.less: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: @fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .@{fa-css-prefix}-li { 11 | position: absolute; 12 | left: -@fa-li-width; 13 | width: @fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.@{fa-css-prefix}-lg { 17 | left: -@fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_rotated-flipped.scss: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-rotate-90 { @include fa-icon-rotate(90deg, 1); } 5 | .#{$fa-css-prefix}-rotate-180 { @include fa-icon-rotate(180deg, 2); } 6 | .#{$fa-css-prefix}-rotate-270 { @include fa-icon-rotate(270deg, 3); } 7 | 8 | .#{$fa-css-prefix}-flip-horizontal { @include fa-icon-flip(-1, 1, 0); } 9 | .#{$fa-css-prefix}-flip-vertical { @include fa-icon-flip(1, -1, 2); } 10 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_list.scss: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: $fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .#{$fa-css-prefix}-li { 11 | position: absolute; 12 | left: -$fa-li-width; 13 | width: $fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.#{$fa-css-prefix}-lg { 17 | left: -$fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/iamRoutes.conf: -------------------------------------------------------------------------------- 1 | # 2 | # API Keys 3 | # 4 | GET /v1/apiKeys com.att.nsa.apiServer.endpoints.NsaApiKeyEndpoint.getAllApiKeys 5 | POST /v1/apiKeys/create com.att.nsa.apiServer.endpoints.NsaApiKeyEndpoint.createApiKey 6 | GET /v1/apiKeys/{apiKey} com.att.nsa.apiServer.endpoints.NsaApiKeyEndpoint.getApiKey 7 | PATCH /v1/apiKeys/{apiKey} com.att.nsa.apiServer.endpoints.NsaApiKeyEndpoint.updateApiKey 8 | DELETE /v1/apiKeys/{apiKey} com.att.nsa.apiServer.endpoints.NsaApiKeyEndpoint.deleteApiKey 9 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/browsers/chromeBrowser.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.browsers; 6 | 7 | public class chromeBrowser extends genericBrowser 8 | { 9 | public chromeBrowser () 10 | { 11 | super ( "Chrome", "" ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/browsers/safariBrowser.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.browsers; 6 | 7 | public class safariBrowser extends genericBrowser 8 | { 9 | public safariBrowser () 10 | { 11 | super ( "Safari", "" ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/sass/sass/_forms.scss: -------------------------------------------------------------------------------- 1 | 2 | #injectForm 3 | { 4 | margin-top: 2em; 5 | width: 100%; 6 | position: relative; 7 | } 8 | 9 | .injectLabel 10 | { 11 | display: inline-block; 12 | width: 6em; 13 | 14 | text-align: right; 15 | padding-right: 1em; 16 | 17 | vertical-align: top; 18 | } 19 | 20 | #alarmData 21 | { 22 | wrap: off; 23 | 24 | width: 600px; 25 | height: 120px; 26 | border: 3px solid #cccccc; 27 | 28 | padding: 0.25em; 29 | } 30 | 31 | .injectError 32 | { 33 | color: #ff0000; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/browsers/firefoxBrowser.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.browsers; 6 | 7 | public class firefoxBrowser extends genericBrowser 8 | { 9 | public firefoxBrowser () 10 | { 11 | super ( "Firefox", "" ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/font-awesome.scss: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.1.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables"; 7 | @import "mixins"; 8 | @import "path"; 9 | @import "core"; 10 | @import "larger"; 11 | @import "fixed-width"; 12 | @import "list"; 13 | @import "bordered-pulled"; 14 | @import "spinning"; 15 | @import "rotated-flipped"; 16 | @import "stacked"; 17 | @import "icons"; 18 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/apiServer/Settings.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.apiServer; 5 | 6 | import com.att.nsa.drumlin.till.nv.rrNvReadable; 7 | 8 | /** 9 | * A general purpose settings class. 10 | * @author peter 11 | * 12 | */ 13 | public interface Settings extends rrNvReadable 14 | { 15 | } 16 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/apiServer/util/NsaJvmClock.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.apiServer.util; 5 | 6 | public class NsaJvmClock extends NsaClock 7 | { 8 | @Override 9 | public long getCurrentMs () { return jvmNow (); } 10 | 11 | public static long jvmNow () { return System.currentTimeMillis (); } 12 | } 13 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/font-awesome.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.1.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "variables.less"; 7 | @import "mixins.less"; 8 | @import "path.less"; 9 | @import "core.less"; 10 | @import "larger.less"; 11 | @import "fixed-width.less"; 12 | @import "list.less"; 13 | @import "bordered-pulled.less"; 14 | @import "spinning.less"; 15 | @import "rotated-flipped.less"; 16 | @import "stacked.less"; 17 | @import "icons.less"; 18 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/ios/iPhone3.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices.ios; 6 | 7 | import com.att.nsa.drumlin.app.userAgents.devices.screenInfo; 8 | 9 | public class iPhone3 extends iPhone 10 | { 11 | public iPhone3 () 12 | { 13 | super ( new screenInfo ( 320, 480, 163 ) ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/ios/iPhone4.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices.ios; 6 | 7 | import com.att.nsa.drumlin.app.userAgents.devices.screenInfo; 8 | 9 | public class iPhone4 extends iPhone 10 | { 11 | public iPhone4 () 12 | { 13 | super ( new screenInfo ( 640, 960, 326 ) ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/ios/iPhone5.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices.ios; 6 | 7 | import com.att.nsa.drumlin.app.userAgents.devices.screenInfo; 8 | 9 | public class iPhone5 extends iPhone 10 | { 11 | public iPhone5 () 12 | { 13 | super ( new screenInfo ( 640, 1136, 326 ) ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/ui/endpoints/UiMain.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.ui.endpoints; 5 | 6 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 7 | 8 | public class UiMain 9 | { 10 | public static void getMain ( DrumlinRequestContext ctx ) 11 | { 12 | ctx.renderer ().renderTemplate ( "/templates/main.html" ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/device.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices; 6 | 7 | public interface device 8 | { 9 | String getName (); 10 | String getVersion (); 11 | 12 | screenInfo getScreenInfo (); 13 | 14 | String getOsName (); 15 | String getOsVersion (); 16 | 17 | boolean isMobile (); 18 | } 19 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/unknownFixedScreen.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices; 6 | 7 | public class unknownFixedScreen extends screenInfo 8 | { 9 | public unknownFixedScreen () 10 | { 11 | super ( -1, -1, -1 ); 12 | } 13 | 14 | @Override 15 | public boolean isFixedSize () { return true; }; 16 | } 17 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/stacked.less: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .@{fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .@{fa-css-prefix}-stack-1x, .@{fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .@{fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .@{fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .@{fa-css-prefix}-inverse { color: @fa-inverse; } 21 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/console/shell/commandList.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.console.shell; 6 | 7 | public interface commandList 8 | { 9 | /** 10 | * return the command for a text command, or null 11 | * @param cmd 12 | * @return information about the command, or null 13 | */ 14 | command getCommandFor ( String cmd ); 15 | } 16 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_stacked.scss: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .#{$fa-css-prefix}-stack-1x, .#{$fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .#{$fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .#{$fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .#{$fa-css-prefix}-inverse { color: $fa-inverse; } 21 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | node { 2 | // Get the maven tool. 3 | // ** NOTE: This 'M3' maven tool must be configured 4 | // ** in the Jenkins global configuration. 5 | def mvnHome = tool 'M3' 6 | sh "echo ${mvnHome}" 7 | 8 | 9 | // Mark the code checkout 'stage'.... 10 | stage 'Checkout' 11 | // Get some code from a GitHub repository 12 | checkout scm 13 | 14 | // Mark the code build 'stage'.... 15 | stage 'Build ajsc5' 16 | // Run the maven build 17 | //sh for unix bat for windows 18 | 19 | sh "${mvnHome}/bin/mvn -f saserverlibrary/pom.xml clean deploy" 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/NsaSecurityManagerException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | public class NsaSecurityManagerException extends Exception { 7 | 8 | public NsaSecurityManagerException(String msg) { super(msg); } 9 | public NsaSecurityManagerException(Throwable t) { super(t); } 10 | public NsaSecurityManagerException(String msg, Throwable t) { super(msg,t); } 11 | private static final long serialVersionUID = 1L; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/userAgent.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents; 6 | 7 | public interface userAgent 8 | { 9 | String getDeviceName (); 10 | String getOsName (); 11 | String getOsVersion (); 12 | 13 | String getBrowserCanonicalName (); 14 | String getBrowserCanonicalVersion (); 15 | 16 | boolean getIsMobile (); 17 | 18 | boolean getIsFixedScreenSize (); 19 | int getScreenWidth (); 20 | int getScreenHeight (); 21 | int getScreenDpi (); 22 | } 23 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/db/ResourceExistsException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.db; 5 | 6 | public class ResourceExistsException extends Exception { 7 | private static final long serialVersionUID = 1L; 8 | 9 | public ResourceExistsException() { super(); } 10 | public ResourceExistsException(String message) { super(message); } 11 | public ResourceExistsException(Throwable t) { super(t); } 12 | public ResourceExistsException(String message, Throwable t) { super(message, t); } 13 | } 14 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/security/NsaAclUtilsTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | import junit.framework.TestCase; 7 | 8 | import org.junit.Test; 9 | 10 | import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException; 11 | 12 | public class NsaAclUtilsTest extends TestCase 13 | { 14 | @Test 15 | public void testDefaultHandling () throws AccessDeniedException 16 | { 17 | final NsaAcl empty = new NsaAcl (); 18 | NsaAclUtils.checkUserAccess ( "", empty, null ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/metrics.html: -------------------------------------------------------------------------------- 1 | 2 | #set( $tab = "metrics" ) 3 | #parse ( "header.html" ) 4 | 5 | 6 | 7 |
8 | 9 | #if ( $errorMsg ) 10 |
$errorMsg
11 | #end 12 | 13 |
14 | #foreach ( $entry in $metricEntries ) 15 |
16 | 17 | #if ( $entry.hasValue() ) 18 | $entry.localName: $entry.value.summarize() 19 | #end 20 | 21 |
22 | #end 23 |
24 |
25 | reset metrics 26 |
27 |
28 | 29 | #parse ( "footer.html" ) 30 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/DrumlinErrorHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework; 6 | 7 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 8 | 9 | /** 10 | * You can register an error handler with the request router. 11 | */ 12 | public interface DrumlinErrorHandler 13 | { 14 | /** 15 | * Handle the error. Do not throw out of this method! 16 | * @param ctx 17 | * @param cause 18 | */ 19 | void handle ( DrumlinRequestContext ctx, Throwable cause ); 20 | } 21 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/path.less: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: ~"url('@{fa-font-path}/fontawesome-webfont.eot?v=@{fa-version}')"; 7 | src: ~"url('@{fa-font-path}/fontawesome-webfont.eot?#iefix&v=@{fa-version}') format('embedded-opentype')", 8 | ~"url('@{fa-font-path}/fontawesome-webfont.woff?v=@{fa-version}') format('woff')", 9 | ~"url('@{fa-font-path}/fontawesome-webfont.ttf?v=@{fa-version}') format('truetype')", 10 | ~"url('@{fa-font-path}/fontawesome-webfont.svg?v=@{fa-version}#fontawesomeregular') format('svg')"; 11 | // src: url('@{fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 12 | font-weight: normal; 13 | font-style: normal; 14 | } 15 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_path.scss: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); 7 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), 8 | url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), 9 | url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), 10 | url('#{$fa-font-path}/fontawesome-webfont.svg?v=#{$fa-version}#fontawesomeregular') format('svg'); 11 | //src: url('#{$fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 12 | font-weight: normal; 13 | font-style: normal; 14 | } 15 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | .fa-icon-rotate(@degrees, @rotation) { 5 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation); 6 | -webkit-transform: rotate(@degrees); 7 | -moz-transform: rotate(@degrees); 8 | -ms-transform: rotate(@degrees); 9 | -o-transform: rotate(@degrees); 10 | transform: rotate(@degrees); 11 | } 12 | 13 | .fa-icon-flip(@horiz, @vert, @rotation) { 14 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation, mirror=1); 15 | -webkit-transform: scale(@horiz, @vert); 16 | -moz-transform: scale(@horiz, @vert); 17 | -ms-transform: scale(@horiz, @vert); 18 | -o-transform: scale(@horiz, @vert); 19 | transform: scale(@horiz, @vert); 20 | } 21 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_mixins.scss: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | @mixin fa-icon-rotate($degrees, $rotation) { 5 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 6 | -webkit-transform: rotate($degrees); 7 | -moz-transform: rotate($degrees); 8 | -ms-transform: rotate($degrees); 9 | -o-transform: rotate($degrees); 10 | transform: rotate($degrees); 11 | } 12 | 13 | @mixin fa-icon-flip($horiz, $vert, $rotation) { 14 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 15 | -webkit-transform: scale($horiz, $vert); 16 | -moz-transform: scale($horiz, $vert); 17 | -ms-transform: scale($horiz, $vert); 18 | -o-transform: scale($horiz, $vert); 19 | transform: scale($horiz, $vert); 20 | } 21 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/db/NsaApiKeyFactory.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.db; 5 | 6 | import com.att.nsa.security.NsaApiKey; 7 | 8 | public interface NsaApiKeyFactory 9 | { 10 | /** 11 | * Create a key using a key and secret 12 | * @param key 13 | * @param sharedSecret 14 | * @return the key instance 15 | */ 16 | K makeNewKey ( String key, String sharedSecret ); 17 | 18 | /** 19 | * Create a key from its serialized form 20 | * @param serializedForm 21 | * @return the key instance 22 | */ 23 | K makeNewKey ( String serializedForm ); 24 | } 25 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/db/AuthorizationServiceUnavailableException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.db; 5 | 6 | public class AuthorizationServiceUnavailableException extends Exception { 7 | 8 | private static final long serialVersionUID = 1L; 9 | 10 | public AuthorizationServiceUnavailableException() { super(); } 11 | public AuthorizationServiceUnavailableException(String message) { super(message); } 12 | public AuthorizationServiceUnavailableException(Throwable t) { super(t); }; 13 | public AuthorizationServiceUnavailableException(String message, Throwable t) { super(message, t); } 14 | } -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/rendering/vtlTools/DrumlinVtlHelper.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework.rendering.vtlTools; 6 | 7 | import com.att.nsa.drumlin.till.data.rrConvertor; 8 | 9 | public class DrumlinVtlHelper 10 | { 11 | public String noBreakingSpace ( String e ) 12 | { 13 | return replace ( e, " ", " " ); 14 | } 15 | 16 | public String replace ( String e, String from, String to ) 17 | { 18 | return e.replace ( from, to ); 19 | } 20 | 21 | public String encode ( String e ) 22 | { 23 | return rrConvertor.urlEncode ( e ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/drumlin/till/nv/impl/nvInstallTypeWrapperTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.till.nv.impl; 5 | 6 | import junit.framework.TestCase; 7 | 8 | import org.junit.Test; 9 | 10 | public class nvInstallTypeWrapperTest extends TestCase 11 | { 12 | @Test 13 | public void testParsing () 14 | { 15 | assertEquals ( "foo", nvInstallTypeWrapper.parse ( "foo" ) ); 16 | assertEquals ( "foo", nvInstallTypeWrapper.parse ( "foo[sys]" ) ); 17 | assertEquals ( "foo", nvInstallTypeWrapper.parse ( "foo[sys@user]" ) ); 18 | assertEquals ( "foo", nvInstallTypeWrapper.parse ( "foo[@user]" ) ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/DrumlinConnectionContext.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework; 6 | 7 | import java.util.concurrent.TimeUnit; 8 | 9 | /** 10 | * Context provided to a DrumlinConnection when the servlet associates a client call. 11 | * 12 | * @author peter@rathravane.com 13 | */ 14 | public interface DrumlinConnectionContext 15 | { 16 | /** 17 | * If the connection should timeout after inactivity, call setInactiveExpiration on 18 | * the connection after it's setup. 19 | * @param units 20 | * @param tu 21 | */ 22 | void setInactiveExpiration ( long units, TimeUnit tu ); 23 | } 24 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/browsers/genericBrowser.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.browsers; 6 | 7 | public class genericBrowser implements browser 8 | { 9 | public genericBrowser () 10 | { 11 | this ( "generic", "" ); 12 | } 13 | 14 | public genericBrowser ( String name, String version ) 15 | { 16 | fName = name; 17 | fVersion = version; 18 | } 19 | 20 | @Override 21 | public String getName () 22 | { 23 | return fName; 24 | } 25 | 26 | @Override 27 | public String getVersion () 28 | { 29 | return fVersion; 30 | } 31 | 32 | private final String fName; 33 | private final String fVersion; 34 | } 35 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/activeAlarm.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 | #if ( $alarm ) 11 | 12 |
Alarm: $alarm.identifier
13 | 14 | #if ( $correlation ) 15 |
Correlated in $correlation.id
16 | #end 17 |
Clear this alarm
18 | 19 | 20 | #foreach ( $field in $fields ) 21 | 22 | #end 23 |
$field$alarm.getValueViaSchema($field,"")
24 | #else 25 |
Alarm
26 |
The alarm was not found. (Did it clear?).
27 | #end 28 | 29 |
30 | 31 | #parse ( "footer.html" ) 32 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/less/spinning.less: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .@{fa-css-prefix}-spin { 5 | -webkit-animation: spin 2s infinite linear; 6 | -moz-animation: spin 2s infinite linear; 7 | -o-animation: spin 2s infinite linear; 8 | animation: spin 2s infinite linear; 9 | } 10 | 11 | @-moz-keyframes spin { 12 | 0% { -moz-transform: rotate(0deg); } 13 | 100% { -moz-transform: rotate(359deg); } 14 | } 15 | @-webkit-keyframes spin { 16 | 0% { -webkit-transform: rotate(0deg); } 17 | 100% { -webkit-transform: rotate(359deg); } 18 | } 19 | @-o-keyframes spin { 20 | 0% { -o-transform: rotate(0deg); } 21 | 100% { -o-transform: rotate(359deg); } 22 | } 23 | @keyframes spin { 24 | 0% { 25 | -webkit-transform: rotate(0deg); 26 | transform: rotate(0deg); 27 | } 28 | 100% { 29 | -webkit-transform: rotate(359deg); 30 | transform: rotate(359deg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/font-awesome/scss/_spinning.scss: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .#{$fa-css-prefix}-spin { 5 | -webkit-animation: spin 2s infinite linear; 6 | -moz-animation: spin 2s infinite linear; 7 | -o-animation: spin 2s infinite linear; 8 | animation: spin 2s infinite linear; 9 | } 10 | 11 | @-moz-keyframes spin { 12 | 0% { -moz-transform: rotate(0deg); } 13 | 100% { -moz-transform: rotate(359deg); } 14 | } 15 | @-webkit-keyframes spin { 16 | 0% { -webkit-transform: rotate(0deg); } 17 | 100% { -webkit-transform: rotate(359deg); } 18 | } 19 | @-o-keyframes spin { 20 | 0% { -o-transform: rotate(0deg); } 21 | 100% { -o-transform: rotate(359deg); } 22 | } 23 | @keyframes spin { 24 | 0% { 25 | -webkit-transform: rotate(0deg); 26 | transform: rotate(0deg); 27 | } 28 | 100% { 29 | -webkit-transform: rotate(359deg); 30 | transform: rotate(359deg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/android/androidDevice.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices.android; 6 | 7 | import com.att.nsa.drumlin.app.userAgents.devices.genericDevice; 8 | import com.att.nsa.drumlin.app.userAgents.devices.screenInfo; 9 | import com.att.nsa.drumlin.app.userAgents.devices.unknownFixedScreen; 10 | 11 | public class androidDevice extends genericDevice 12 | { 13 | public androidDevice () 14 | { 15 | super ( new unknownFixedScreen (), true ); 16 | } 17 | 18 | public androidDevice ( screenInfo si ) 19 | { 20 | super ( si, true ); 21 | } 22 | 23 | @Override 24 | public String getOsName () 25 | { 26 | return "Android"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/screenInfo.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices; 6 | 7 | public class screenInfo 8 | { 9 | public screenInfo () 10 | { 11 | this ( -1, -1, -1 ); 12 | } 13 | 14 | public screenInfo ( int width, int height, int dpi ) 15 | { 16 | fWidth = width; 17 | fHeight = height; 18 | fDpi = dpi; 19 | } 20 | 21 | public boolean isFixedSize () { return fWidth != -1 || fHeight != -1; }; 22 | public int getWidth () { return fWidth; } 23 | public int getHeight () { return fHeight; } 24 | public int getDpi () { return fDpi; } 25 | 26 | private final int fWidth; 27 | private final int fHeight; 28 | private final int fDpi; 29 | } 30 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/sass/sass/_commonSettings.scss: -------------------------------------------------------------------------------- 1 | 2 | // from the official AT&T palette 2014 3 | $colorAttOrange: #EF6F00; 4 | $colorAttBlue: #067AB4; 5 | $colorAttGreenHighlight: #C4D82D; 6 | $colorAttGreen: #4CA90C; 7 | $colorAttBlueHighlight: #44C8F5; 8 | $colorAttBurgundy: #B30A3C; 9 | $colorAttMagenta: #DA0081; 10 | $colorAttOrangeHighlight: #FCB314; 11 | $colorAttDarkBlue: #0C2577; 12 | $colorAttPurple: #81017E; 13 | $colorAttGray: #666666; 14 | 15 | $colorWhite: #fff; 16 | $colorBlack: #000; 17 | 18 | //$totalWidth: 1080px; 19 | $totalWidth: 960px; 20 | $totalHeight: 30em; 21 | 22 | $linkColor: #448; 23 | 24 | $linkHiliteColor: #6FBAF7; 25 | 26 | $topBarColor: $colorWhite; 27 | $topBarTextColor: $colorAttGray; 28 | $topBarActiveTextColor: $colorAttBlue; 29 | $topBarLinkHiliteColor: $colorAttBlueHighlight; 30 | 31 | $bodyColor: #fff; 32 | 33 | $footerColor: #fff; 34 | $footerTextColor: #333; 35 | 36 | $bodyTextColor: #222; 37 | $labelGray: #444; 38 | 39 | 40 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/standards/HttpMethods.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.service.standards; 5 | 6 | /** 7 | * HTTP methods as used in Drumlin. They're plain strings (rather than an 8 | * enumeration). The HTTP spec allows for extension, so Drumlin does too. 9 | */ 10 | public class HttpMethods 11 | { 12 | public static final String OPTIONS = "OPTIONS"; 13 | public static final String GET = "GET"; 14 | public static final String HEAD = "HEAD"; 15 | public static final String POST = "POST"; 16 | public static final String PUT = "PUT"; 17 | public static final String DELETE = "DELETE"; 18 | public static final String TRACE = "TRACE"; 19 | public static final String CONNECT = "CONNECT"; 20 | } 21 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/security/NsaAclTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | import junit.framework.TestCase; 7 | 8 | import org.junit.Test; 9 | 10 | import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException; 11 | 12 | public class NsaAclTest extends TestCase 13 | { 14 | @Test 15 | public void testEmptyAndNull () throws AccessDeniedException 16 | { 17 | assertNull ( NsaAcl.fromJson ( (String)null, false ) ); 18 | 19 | NsaAcl acl = NsaAcl.fromJson ( (String)null, true ); 20 | assertNotNull ( acl ); 21 | assertEquals ( 0, acl.getUsers ().size() ); 22 | 23 | acl = NsaAcl.fromJson ( "", false ); 24 | assertNotNull ( acl ); 25 | assertEquals ( 0, acl.getUsers ().size() ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/sass/config.rb: -------------------------------------------------------------------------------- 1 | # Require any additional compass plugins here. 2 | 3 | # Set this to the root of your project when deployed: 4 | http_path = "/" 5 | css_dir = "../resources/css" 6 | sass_dir = "sass" 7 | images_dir = "images" 8 | javascripts_dir = "javascripts" 9 | 10 | # You can select your preferred output style here (can be overridden via the command line): 11 | # output_style = :expanded or :nested or :compact or :compressed 12 | 13 | # To enable relative paths to assets via compass helper functions. Uncomment: 14 | # relative_assets = true 15 | 16 | # To disable debugging comments that display the original location of your selectors. Uncomment: 17 | # line_comments = false 18 | 19 | 20 | # If you prefer the indented syntax, you might want to regenerate this 21 | # project again passing --syntax sass, or you can uncomment this: 22 | # preferred_syntax = :sass 23 | # and then run: 24 | # sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass 25 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/routing/playish/DrumlinPlayishRouteHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.service.framework.routing.playish; 5 | 6 | import java.io.IOException; 7 | import java.lang.reflect.InvocationTargetException; 8 | import java.util.List; 9 | 10 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 11 | 12 | /** 13 | * A route handler handles a request, given a context. 14 | * @author peter 15 | */ 16 | public interface DrumlinPlayishRouteHandler 17 | { 18 | void handle ( DrumlinRequestContext context, List args ) throws IOException, IllegalArgumentException, IllegalAccessException, InvocationTargetException; 19 | boolean actionMatches ( String fullPath ); 20 | } 21 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/db/simple/NsaSimpleApiKeyFactory.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.db.simple; 5 | 6 | import org.json.JSONObject; 7 | 8 | import com.att.nsa.security.db.NsaApiKeyFactory; 9 | 10 | /** 11 | * A factory for the simple API key implementation 12 | * @author peter 13 | * 14 | */ 15 | public class NsaSimpleApiKeyFactory implements NsaApiKeyFactory 16 | { 17 | @Override 18 | public NsaSimpleApiKey makeNewKey ( String key, String sharedSecret ) 19 | { 20 | return new NsaSimpleApiKey ( key, sharedSecret ); 21 | } 22 | 23 | @Override 24 | public NsaSimpleApiKey makeNewKey ( String serializedForm ) 25 | { 26 | return new NsaSimpleApiKey ( new JSONObject ( serializedForm ) ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/ios/iPhone.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices.ios; 6 | 7 | import com.att.nsa.drumlin.app.userAgents.devices.genericDevice; 8 | import com.att.nsa.drumlin.app.userAgents.devices.screenInfo; 9 | import com.att.nsa.drumlin.app.userAgents.devices.unknownFixedScreen; 10 | 11 | public class iPhone extends genericDevice 12 | { 13 | public iPhone () 14 | { 15 | super ( new unknownFixedScreen (), true ); 16 | } 17 | 18 | public iPhone ( screenInfo si ) 19 | { 20 | super ( si, true ); 21 | } 22 | 23 | @Override 24 | public String getName () 25 | { 26 | return "iPhone"; 27 | } 28 | 29 | @Override 30 | public String getOsName () 31 | { 32 | return "iOS"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/computers/macintosh.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices.computers; 6 | 7 | import com.att.nsa.drumlin.app.userAgents.devices.genericDevice; 8 | import com.att.nsa.drumlin.app.userAgents.devices.screenInfo; 9 | import com.att.nsa.drumlin.app.userAgents.devices.unknownFixedScreen; 10 | 11 | public class macintosh extends genericDevice 12 | { 13 | public macintosh () 14 | { 15 | super ( new unknownFixedScreen (), false ); 16 | } 17 | 18 | public macintosh ( screenInfo si ) 19 | { 20 | super ( si, false ); 21 | } 22 | 23 | @Override 24 | public String getName () 25 | { 26 | return "Apple Macintosh"; 27 | } 28 | 29 | @Override 30 | public String getOsName () 31 | { 32 | return "OS X"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/nv/rrNvWriteable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.nv; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * Write interface for a name/value pair container. 11 | * 12 | * @author peter@rathravane.com 13 | */ 14 | public interface rrNvWriteable extends rrNvReadable 15 | { 16 | void clear (); 17 | void unset ( String key ); 18 | 19 | void set ( String key, String value ); 20 | void set ( String key, char value ); 21 | void set ( String key, boolean value ); 22 | void set ( String key, int value ); 23 | void set ( String key, long value ); 24 | void set ( String key, double value ); 25 | void set ( String key, byte[] value ); 26 | void set ( String key, byte[] value, int offset, int length ); 27 | void set ( String key, String[] value ); 28 | void set ( Map map ); 29 | } 30 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/routing/playish/RedirectHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.service.framework.routing.playish; 5 | 6 | import java.util.List; 7 | 8 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 9 | 10 | public class RedirectHandler implements DrumlinPlayishRouteHandler 11 | { 12 | public static final String kMaxAge = "drumlin.staticDir.cache.maxAgeSeconds"; 13 | 14 | public RedirectHandler ( String loc ) 15 | { 16 | fTargetLocation = loc; 17 | } 18 | 19 | @Override 20 | public void handle ( DrumlinRequestContext context, List args ) 21 | { 22 | context.response ().redirect ( fTargetLocation ); 23 | } 24 | 25 | private final String fTargetLocation; 26 | 27 | @Override 28 | public boolean actionMatches(String fullPath) 29 | { 30 | return false; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/NsaAuthenticator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequest; 7 | 8 | /** 9 | * An interface for authenticating an inbound request. 10 | * @author peter 11 | */ 12 | public interface NsaAuthenticator 13 | { 14 | /** 15 | * Qualify a request as possibly using the authentication method that this class implements. 16 | * @param req 17 | * @return true if the request might be authenticated by this class 18 | */ 19 | boolean qualify ( DrumlinRequest req ); 20 | 21 | /** 22 | * Check for a request being authentic. If it is, return the API key. If not, return null. 23 | * @param req An inbound web request 24 | * @return the API key for an authentic request, or null 25 | */ 26 | K isAuthentic ( DrumlinRequest req ); 27 | } 28 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/userAgentFeature.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents; 6 | 7 | public class userAgentFeature 8 | { 9 | public String getName () { return fName; } 10 | public String getVersion () { return fVersion; } 11 | public String getComment () { return fComment; } 12 | 13 | private final String fName; 14 | private final String fVersion; 15 | private final String fComment; 16 | 17 | userAgentFeature ( String name ) 18 | { 19 | this ( name, "", "" ); 20 | } 21 | 22 | userAgentFeature ( String name, String version ) 23 | { 24 | this ( name, version, "" ); 25 | } 26 | 27 | userAgentFeature ( String name, String version, String comment ) 28 | { 29 | fName = name == null ? "" : name; 30 | fVersion = version == null ? "" : version; 31 | fComment = comment == null ? "" : comment; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/htmlForms/mime/DrumlinMimePartFactory.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.app.htmlForms.mime; 5 | 6 | import java.io.IOException; 7 | 8 | import com.att.nsa.drumlin.till.collections.rrMultiMap; 9 | 10 | /** 11 | * A MIME part factory. The factory is provided to the multipart MIME reader to 12 | * allow an application to create parts. For example, a web app receiving a file 13 | * input may want to store that file on AWS S3 rather than in a local tmp file. 14 | * 15 | * @author peter@rathravane.com 16 | * 17 | */ 18 | public interface DrumlinMimePartFactory 19 | { 20 | /** 21 | * Create a MIME part given header values for the part section. 22 | * @param partHeaders 23 | * @return a new MIME part 24 | * @throws IOException 25 | */ 26 | DrumlinMimePart createPart ( rrMultiMap partHeaders ) throws IOException; 27 | } 28 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/injector.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 |
Alarm Injection
11 |
12 | You can inject alarms into the correlation system. Alarms will be marked as a test 13 | alarms, so they will not be published by the UCA value pack. 14 |
15 |
16 |
17 |
$!alarmDataInvalid
18 |
19 |
20 |
21 |
22 |
23 | 24 |
25 | 26 | #parse ( "footer.html" ) 27 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/routing/DrumlinSimpleRouteHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework.routing; 6 | 7 | import java.io.IOException; 8 | import java.util.Map; 9 | 10 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 11 | 12 | /** 13 | * A basic route handler provided for convenience in creating simple handlers. 14 | * 15 | * @author peter@rathravane.com 16 | */ 17 | public abstract class DrumlinSimpleRouteHandler implements DrumlinRouteSource, DrumlinRouteInvocation 18 | { 19 | public DrumlinRouteInvocation getRouteFor ( String verb, String path ) 20 | { 21 | return this; 22 | } 23 | 24 | public String getRouteTo ( Class c, String staticMethodName, Map args ) 25 | { 26 | return null; 27 | } 28 | 29 | public abstract void run ( DrumlinRequestContext ctx ) throws IOException; 30 | } 31 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/activeCg.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 |
Active Correlation
11 | 12 | #if ( $activeCg ) 13 | 14 | 15 | 16 | 17 |
Secondaries:
18 | #foreach ( $secondary in $activeCg.secondaries ) 19 | 20 | #end 21 | #else 22 |
The correlation was not found. It may have cleared or been subsumed by another correlation.
23 | #end 24 | 25 |
26 | 27 | #parse ( "footer.html" ) 28 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/db/simple/NsaSimpleRemoteApiKey.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.db.simple; 5 | 6 | import org.json.JSONObject; 7 | 8 | public class NsaSimpleRemoteApiKey extends NsaSimpleApiKey 9 | { 10 | public NsaSimpleRemoteApiKey ( JSONObject data ) 11 | { 12 | super ( data ); 13 | } 14 | 15 | @Override 16 | public String getSecret () 17 | { 18 | throw new IllegalStateException ( "This is a read-only API key that does not carry a secret." ); 19 | } 20 | 21 | @Override 22 | public void enable () 23 | { 24 | throw new IllegalStateException ( "This is a read-only API key." ); 25 | } 26 | 27 | @Override 28 | public void disable () 29 | { 30 | throw new IllegalStateException ( "This is a read-only API key." ); 31 | } 32 | 33 | @Override 34 | public void set ( String key, String val ) 35 | { 36 | throw new IllegalStateException ( "This is a read-only API key." ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/data/base64/rrcBase64Constants.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.data.base64; 6 | 7 | public class rrcBase64Constants 8 | { 9 | public static final char kNewline = 10; 10 | 11 | public static char[] nibblesToB64 = new char [64]; 12 | public static byte[] b64ToNibbles = new byte [128]; 13 | 14 | static 15 | { 16 | int j = 0; 17 | for ( char c = 'A'; c <= 'Z'; c++ ) 18 | { 19 | nibblesToB64[j++] = c; 20 | } 21 | for ( char c = 'a'; c <= 'z'; c++ ) 22 | { 23 | nibblesToB64[j++] = c; 24 | } 25 | for ( char c = '0'; c <= '9'; c++ ) 26 | { 27 | nibblesToB64[j++] = c; 28 | } 29 | nibblesToB64[j++] = '+'; 30 | nibblesToB64[j++] = '/'; 31 | 32 | for ( int i = 0; i < b64ToNibbles.length; i++ ) 33 | { 34 | b64ToNibbles[i] = -1; 35 | } 36 | for ( int i = 0; i < 64; i++ ) 37 | { 38 | b64ToNibbles[nibblesToB64[i]] = (byte) i; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/corrEvent.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 |
Event $event.identifier
11 | 12 |
13 |
$event.eventId
14 |
$event.topoKey
15 | 16 | #if ( $activeCg ) 17 | #if ( $activeCg.primary == $event ) 18 | 19 |
20 |
Secondaries
21 | #foreach ( $secondary in $activeCg.secondaries ) 22 | 23 | #end 24 |
25 | #else 26 | 27 | 28 | #end 29 | #end 30 |
31 | 32 |
33 | 34 | #parse ( "footer.html" ) 35 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/DrumlinServletSettings.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.service.framework; 5 | 6 | import java.util.Enumeration; 7 | import java.util.HashMap; 8 | 9 | import javax.servlet.ServletConfig; 10 | 11 | import com.att.nsa.drumlin.till.nv.impl.nvReadableTable; 12 | 13 | /** 14 | * Wraps a ServletConfig in the settings class used throughout the Drumlin 15 | * framework. 16 | */ 17 | public class DrumlinServletSettings extends nvReadableTable 18 | { 19 | public DrumlinServletSettings ( ServletConfig sc ) 20 | { 21 | super (); 22 | 23 | final HashMap loaded = new HashMap (); 24 | 25 | final Enumeration e = sc.getInitParameterNames (); 26 | while ( e.hasMoreElements () ) 27 | { 28 | final String name = e.nextElement (); 29 | final String val = sc.getInitParameter ( name ); 30 | loaded.put ( name, val ); 31 | } 32 | 33 | set ( loaded ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/apiServer/util/NsaClock.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.apiServer.util; 5 | 6 | public abstract class NsaClock 7 | { 8 | /** 9 | * Get the current time from the system clock. 10 | * @return the current time in milliseconds. (Normally equivalent to System.currentTimeMillis()) 11 | */ 12 | public static long now () 13 | { 14 | return getSystemClock().getCurrentMs (); 15 | } 16 | 17 | public synchronized static void setSystemClock ( NsaClock clock ) 18 | { 19 | if ( sfClock != null ) throw new IllegalStateException ( "The clock was already set." ); 20 | sfClock = clock; 21 | } 22 | 23 | public static NsaClock getSystemClock () 24 | { 25 | if ( sfClock == null ) 26 | { 27 | synchronized ( NsaClock.class ) 28 | { 29 | if ( sfClock == null ) // post synch lock, check again. thread may have been behind. 30 | { 31 | sfClock = new NsaJvmClock (); 32 | } 33 | } 34 | } 35 | return sfClock; 36 | } 37 | 38 | public abstract long getCurrentMs (); 39 | 40 | private static NsaClock sfClock = null; 41 | } 42 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/routing/DrumlinRouteInvocation.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework.routing; 6 | 7 | import java.io.IOException; 8 | import java.lang.reflect.InvocationTargetException; 9 | 10 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 11 | 12 | /** 13 | * A route invocation is returned by a route source as a match for an incoming route. It's then run() 14 | * to execute the request handling. 15 | * 16 | * @author peter@rathravane.com 17 | * 18 | */ 19 | public interface DrumlinRouteInvocation 20 | { 21 | /** 22 | * Get the route's name 23 | * @return the route name 24 | */ 25 | String getName (); 26 | 27 | /** 28 | * Run the request 29 | * @param ctx 30 | * @throws IOException 31 | * @throws IllegalArgumentException 32 | * @throws IllegalAccessException 33 | * @throws InvocationTargetException 34 | */ 35 | void run ( DrumlinRequestContext ctx ) throws IOException, IllegalArgumentException, IllegalAccessException, InvocationTargetException; 36 | } 37 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/console/shell/command.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.console.shell; 6 | 7 | import java.io.PrintStream; 8 | import java.util.HashMap; 9 | 10 | import com.att.nsa.drumlin.till.console.rrConsole.usageException; 11 | import com.att.nsa.drumlin.till.nv.rrNvReadable; 12 | 13 | public interface command 14 | { 15 | String getCommand (); 16 | 17 | /** 18 | * check the arguments provided 19 | * @param args 20 | */ 21 | void checkArgs ( rrNvReadable p, String[] args ) throws usageException; 22 | 23 | /** 24 | * @return a string used for the help command to show simple usage 25 | */ 26 | String getUsage (); 27 | 28 | /** 29 | * @return a string used for the help command to show detail info 30 | */ 31 | String getHelp (); 32 | 33 | /** 34 | * @param outTo 35 | * @return true to continue, false to exit 36 | * @throws com.rathravane.rrConsole.ui.console2.console.usageException 37 | */ 38 | consoleLooper.inResult execute ( HashMap workspace, PrintStream outTo ) throws usageException; 39 | } 40 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/htmlForms/DrumlinFormValidationStep.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.app.htmlForms; 5 | 6 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 7 | 8 | /** 9 | * A form validation step. 10 | * @author peter@rathravane.com 11 | * 12 | */ 13 | public interface DrumlinFormValidationStep 14 | { 15 | /** 16 | *

Given a context, form, and field information, decide if the value is valid. If it is not, 17 | * add an error listing for the field to the supplied validation error. (Once all 18 | * validation steps are complete, if the error object contains any errors, it's thrown as 19 | * an exception, indicating a problem with the form submission.)

20 | * 21 | *

For form-level validation, the field argument is null.

22 | * 23 | * @param context 24 | * @param form 25 | * @param field Field info, or null for form-level validation. 26 | * @param err 27 | */ 28 | void validate ( DrumlinRequestContext context, DrumlinFormPostWrapper form, DrumlinFormFieldInfo field, DrumlinInvalidFormException err ); 29 | } 30 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/wm.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 | #if ( $alarm ) 11 | #* display a single alarm *# 12 |
Alarm Inspection: $alarm.identifier
13 | 14 | #foreach ( $field in $fields ) 15 | 16 | #end 17 |
$field$alarm.getValueViaSchema($field,"")
18 | #elseif ( $alarms ) 19 | #* display all alarms *# 20 |
Alarms in UCA's Working Memory
21 |
Note that LTE does not keep alarms in UCA's Working Memory.
22 | 23 | #foreach ( $alarm in $alarms ) 24 | 25 | #end 26 |
$alarm.identifier$alarm.getValueViaSchema("AlarmID","???") on $alarm.getValueViaSchema("ManagedObjectInstance","(no topo)")
27 | #else 28 |
Alarms Inspection
29 |
Alarm(s) not found
30 | #end 31 | 32 | 33 | 34 |
35 | 36 | #parse ( "footer.html" ) 37 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/DrumlinConnection.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework; 6 | 7 | import java.util.HashMap; 8 | 9 | import javax.servlet.ServletException; 10 | 11 | /** 12 | * The DrumlinConnection represents a session between a client system and the server. 13 | * 14 | * @author peter@rathravane.com 15 | */ 16 | public interface DrumlinConnection 17 | { 18 | /** 19 | * Called when the servlet associates this connection to a client system. 20 | * @param ws 21 | * @param dcc 22 | * @throws ServletException 23 | */ 24 | void onSessionCreate ( DrumlinServlet ws, DrumlinConnectionContext dcc ) throws ServletException; 25 | 26 | /** 27 | * Called when the connection is closing. 28 | */ 29 | void onSessionClose (); 30 | 31 | /** 32 | * Called when the session receives client activity. 33 | */ 34 | void noteActivity (); 35 | 36 | /** 37 | * Called when the servlet requires the connection to build a context for use by 38 | * the Velocity renderer. 39 | * @param context 40 | */ 41 | void buildTemplateContext ( HashMap context ); 42 | } 43 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/devices/genericDevice.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents.devices; 6 | 7 | public class genericDevice implements device 8 | { 9 | public genericDevice () 10 | { 11 | this ( false ); 12 | } 13 | 14 | public genericDevice ( boolean isMobile ) 15 | { 16 | this ( new screenInfo (), isMobile ); 17 | } 18 | 19 | public genericDevice ( screenInfo si, boolean isMobile ) 20 | { 21 | fScreen = si; 22 | fIsMobile = isMobile; 23 | } 24 | 25 | @Override 26 | public String getName () 27 | { 28 | return "generic"; 29 | } 30 | 31 | @Override 32 | public String getVersion () 33 | { 34 | return ""; 35 | } 36 | 37 | @Override 38 | public screenInfo getScreenInfo () 39 | { 40 | return fScreen; 41 | } 42 | 43 | @Override 44 | public String getOsName () 45 | { 46 | return "generic"; 47 | } 48 | 49 | @Override 50 | public String getOsVersion () 51 | { 52 | return ""; 53 | } 54 | 55 | @Override 56 | public boolean isMobile () 57 | { 58 | return fIsMobile; 59 | } 60 | 61 | private final screenInfo fScreen; 62 | private final boolean fIsMobile; 63 | } 64 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/util/JsonBodyWriter.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.util; 6 | 7 | import java.io.IOException; 8 | import java.util.List; 9 | 10 | import org.json.JSONArray; 11 | import org.json.JSONObject; 12 | 13 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 14 | import com.att.nsa.drumlin.service.standards.HttpStatusCodes; 15 | import com.att.nsa.drumlin.service.standards.MimeTypes; 16 | 17 | /** 18 | * Write JSON objects to a Drumlin response. 19 | * @author peter@rathravane.com 20 | */ 21 | public class JsonBodyWriter 22 | { 23 | /** 24 | * Write a list of JSON objects to the response stream in the given context, with a 25 | * 200 status code. 26 | * 27 | * @param context 28 | * @param objects 29 | * @throws IOException 30 | */ 31 | public static void writeObjectList ( DrumlinRequestContext context, List objects ) throws IOException 32 | { 33 | final JSONArray out = new JSONArray ( objects ); 34 | context.response (). 35 | setStatus ( HttpStatusCodes.k200_ok ). 36 | setContentType ( MimeTypes.kAppJson ). 37 | send ( out.toString () + "\n" ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/routing/playish/TemplateDirHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework.routing.playish; 6 | 7 | import java.io.IOException; 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.util.List; 10 | 11 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 12 | 13 | public class TemplateDirHandler implements DrumlinPlayishRouteHandler 14 | { 15 | public TemplateDirHandler ( String dirInfo ) 16 | { 17 | } 18 | 19 | @Override 20 | public void handle ( DrumlinRequestContext context, List args ) 21 | throws IOException, 22 | IllegalArgumentException, 23 | IllegalAccessException, 24 | InvocationTargetException 25 | { 26 | final String path = context.request ().getPathInContext (); 27 | if ( path != null && path.length() > 0 ) 28 | { 29 | final String file = path.substring ( 1 ); 30 | context.renderer ().renderTemplate ( file ); 31 | } 32 | else 33 | { 34 | throw new IOException ( "Couldn't render path." ); 35 | } 36 | } 37 | 38 | @Override 39 | public boolean actionMatches ( String fullPath ) 40 | { 41 | return false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/apiServer/util/NsaTestClock.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.apiServer.util; 5 | 6 | public class NsaTestClock extends NsaClock 7 | { 8 | /** 9 | * Create a test clock starting time 1 and set as the system clock. 10 | */ 11 | public NsaTestClock () 12 | { 13 | this ( 1 ); 14 | } 15 | 16 | /** 17 | * Create a test clock starting at the given time and set as the system clock. 18 | * @param nowMs 19 | */ 20 | public NsaTestClock ( long nowMs ) 21 | { 22 | this ( nowMs, true ); 23 | } 24 | 25 | /** 26 | * Create a test clock starting time 1 and possibly set as the system clock. 27 | * @param nowMs 28 | * @param setAsSystemClock 29 | */ 30 | public NsaTestClock ( long nowMs, boolean setAsSystemClock ) 31 | { 32 | fNowMs = nowMs; 33 | if ( setAsSystemClock ) 34 | { 35 | NsaClock.setSystemClock ( this ); 36 | } 37 | } 38 | 39 | @Override 40 | public synchronized long getCurrentMs () 41 | { 42 | return fNowMs; 43 | } 44 | 45 | public void tick () 46 | { 47 | addMs ( 1 ); 48 | } 49 | 50 | public synchronized void setTo ( long ms ) 51 | { 52 | fNowMs = ms; 53 | } 54 | 55 | public synchronized void addMs ( long ms ) 56 | { 57 | fNowMs += ms; 58 | } 59 | 60 | private long fNowMs; 61 | } 62 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/security/NsaApiDbTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | import junit.framework.TestCase; 7 | 8 | import org.junit.Test; 9 | 10 | import com.att.nsa.configs.ConfigDbException; 11 | import com.att.nsa.configs.confimpl.MemConfigDb; 12 | import com.att.nsa.security.db.BaseNsaApiDbImpl; 13 | import com.att.nsa.security.db.NsaApiDb.KeyExistsException; 14 | import com.att.nsa.security.db.simple.NsaSimpleApiKey; 15 | import com.att.nsa.security.db.simple.NsaSimpleApiKeyFactory; 16 | 17 | public class NsaApiDbTest extends TestCase 18 | { 19 | @Test 20 | public void testDbStorage () throws KeyExistsException, ConfigDbException 21 | { 22 | final MemConfigDb cdb = new MemConfigDb (); 23 | final BaseNsaApiDbImpl apiDb = new BaseNsaApiDbImpl ( cdb, new NsaSimpleApiKeyFactory () ); 24 | 25 | { 26 | final NsaSimpleApiKey key = apiDb.createApiKey ( "123", "456" ); 27 | key.set ( "foo", "bar" ); 28 | apiDb.saveApiKey ( key ); 29 | } 30 | 31 | { 32 | final NsaApiKey key = apiDb.loadApiKey ( "123" ); 33 | assertEquals ( "bar", key.get ( "foo" ) ); 34 | } 35 | 36 | { 37 | apiDb.deleteApiKey ( "123" ); 38 | assertNull ( apiDb.loadApiKey ( "123" ) ); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/rendering/DrumlinRenderContext.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework.rendering; 6 | 7 | /** 8 | * An interface to the Velocity renderer. Get/put/remove objects 9 | * for use in VTL; Render templates to the response stream (provided 10 | * by the handlingContext where the renderContext was acquired). 11 | * 12 | * @author peter 13 | */ 14 | public interface DrumlinRenderContext 15 | { 16 | /** 17 | * Get an object in the context by name. 18 | * @param key 19 | * @return an object, or null. 20 | */ 21 | Object get ( String key ); 22 | 23 | /** 24 | * Put an object into the render context with a name. The name is available 25 | * in Velocity VTL. 26 | * 27 | * @param key 28 | * @param o 29 | */ 30 | void put ( String key, Object o ); 31 | 32 | /** 33 | * Remove an object given its name. 34 | * @param key 35 | */ 36 | void remove ( String key ); 37 | 38 | /** 39 | * Render the named template. 40 | * @param templateName 41 | */ 42 | void renderTemplate ( String templateName ); 43 | 44 | /** 45 | * Render the named template with the given content type in the HTTP header. 46 | * @param templateName 47 | * @param contentType 48 | */ 49 | void renderTemplate ( String templateName, String contentType ); 50 | } 51 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/util/VeloJsonObject.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.util; 6 | 7 | import java.util.Collection; 8 | 9 | import org.json.JSONException; 10 | import org.json.JSONObject; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | public class VeloJsonObject 15 | { 16 | public VeloJsonObject ( JSONObject o ) 17 | { 18 | fObject = o; 19 | } 20 | 21 | public Object get ( String key ) 22 | { 23 | try 24 | { 25 | final Object o = fObject.get ( key ); 26 | if ( o instanceof JSONObject ) 27 | { 28 | return new VeloJsonObject ( (JSONObject) o ); 29 | } 30 | else if ( o != null ) 31 | { 32 | return o.toString (); 33 | } 34 | } 35 | catch ( JSONException e ) 36 | { 37 | log.info ( e.getMessage(), e ); 38 | } 39 | return null; 40 | } 41 | 42 | public String getString ( String key, String defValue ) 43 | { 44 | return fObject.optString ( key, defValue ); 45 | } 46 | 47 | public boolean hasValueFor ( String key ) 48 | { 49 | return fObject.has ( key ); 50 | } 51 | 52 | @SuppressWarnings("unchecked") 53 | public Collection getAllKeys () 54 | { 55 | return fObject.keySet (); 56 | } 57 | 58 | private final JSONObject fObject; 59 | private static final Logger log = LoggerFactory.getLogger ( VeloJsonObject.class ); 60 | } 61 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/routing/DrumlinRouteSource.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework.routing; 6 | 7 | import java.util.Map; 8 | 9 | /** 10 | * A route source is a collection of routes that are requested by verb (e.g. GET) and 11 | * a path. A Drumlin app can have any number of route sources. During request handling, 12 | * each route source is tested in order via getRouteFor(). If the route source returns 13 | * a {@link DrumlinRouteInvocation}, it's used to handle the request. 14 | * 15 | * @author peter@rathravane.com 16 | * 17 | */ 18 | public interface DrumlinRouteSource 19 | { 20 | /** 21 | * Return the route handler for a given verb and path or null. 22 | * @param verb 23 | * @param path 24 | * @return 25 | */ 26 | DrumlinRouteInvocation getRouteFor ( String verb, String path ); 27 | 28 | /** 29 | * Code in this system can create a URL to get to a specific class + method by asking 30 | * the router to find a reverse-route. If this route source has routes that point to 31 | * static entry points, it should implement an override that returns the correct URL. 32 | * 33 | * @param c 34 | * @param staticMethodName 35 | * @param args 36 | * @return null, or a URL to get to the entry point 37 | */ 38 | String getRouteTo ( Class c, String staticMethodName, Map args ); 39 | } 40 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/apiServer/NsaAppException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.apiServer; 5 | 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | import org.json.JSONObject; 9 | 10 | import com.att.nsa.drumlin.service.standards.MimeTypes; 11 | 12 | public class NsaAppException extends Exception 13 | { 14 | public NsaAppException ( JSONObject jsonObject ) 15 | { 16 | this ( HttpServletResponse.SC_OK, jsonObject ); 17 | } 18 | 19 | public NsaAppException ( int status, String msg ) 20 | { 21 | this ( status, makeObject ( status, msg ) ); 22 | } 23 | 24 | public NsaAppException ( int status, JSONObject jsonObject ) 25 | { 26 | super ( "" + status + " " + jsonObject.toString () ); 27 | 28 | fStatus = status; 29 | fBody = jsonObject; 30 | fType = MimeTypes.kAppJson; 31 | } 32 | 33 | public int getStatus () 34 | { 35 | return fStatus; 36 | } 37 | 38 | public String getMediaType () 39 | { 40 | return fType; 41 | } 42 | 43 | public String getBody () 44 | { 45 | return fBody.toString (); 46 | } 47 | 48 | private static final long serialVersionUID = 1L; 49 | 50 | private static JSONObject makeObject ( int status, String msg ) 51 | { 52 | final JSONObject o = new JSONObject (); 53 | o.put ( "message", msg ); 54 | return o; 55 | } 56 | 57 | private final String fType; 58 | private final JSONObject fBody; 59 | private final int fStatus; 60 | } 61 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/sass/sass/_header.scss: -------------------------------------------------------------------------------- 1 | 2 | #topbar-wrap 3 | { 4 | width: 100%; 5 | background: $topBarColor; 6 | } 7 | 8 | #topbar 9 | { 10 | width: $totalWidth; 11 | margin: 0 auto; 12 | 13 | padding-top: 0.75em; 14 | padding-bottom: 0.5em; 15 | 16 | position: relative; /* for absolute positioning internally */ 17 | 18 | font-family: Courier, Arial; /* OmnesATT */ 19 | font-size: 1.0em; 20 | color: $topBarTextColor; 21 | 22 | a.selectedTab 23 | { 24 | text-decoration: none; 25 | color: $topBarActiveTextColor; 26 | &:hover 27 | { 28 | color: $topBarLinkHiliteColor; 29 | text-decoration: none; 30 | } 31 | } 32 | 33 | a.unselectedTab 34 | { 35 | text-decoration: none; 36 | color: $topBarTextColor; 37 | &:hover 38 | { 39 | color: $topBarLinkHiliteColor; 40 | text-decoration: none; 41 | } 42 | } 43 | 44 | ul 45 | { 46 | list-style: none; 47 | 48 | li 49 | { 50 | display: inline; 51 | margin: 0 0.5em 0 0; 52 | } 53 | } 54 | } 55 | 56 | #searchBarWrap 57 | { 58 | border: 2px #aaa solid; 59 | border-radius: 15px; 60 | background-color: lighten(#444,10%); 61 | 62 | padding-left: 0.75em; 63 | padding-right: 0.75em; 64 | 65 | input 66 | { 67 | border: none; 68 | 69 | padding-left: 0.5em; 70 | padding-right: 0.5em; 71 | 72 | color: #fff; 73 | background-color: lighten(#444,10%); 74 | 75 | &:focus 76 | { 77 | outline: none; 78 | } 79 | } 80 | } 81 | 82 | .dialog-info 83 | { 84 | display: none; 85 | 86 | padding-top: 1em; 87 | padding-bottom: 1em; 88 | 89 | color: #444; 90 | background-color: $linkHiliteColor; 91 | 92 | text-align: center; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/standards/MimeTypes.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.standards; 6 | 7 | /** 8 | * Various commonly used MIME type constants. 9 | * 10 | * @author peter@rathravane.com 11 | */ 12 | public class MimeTypes 13 | { 14 | public static final String kHtml = "text/html"; 15 | public static final String kCss = "text/css"; 16 | public static final String kPlainText = "text/plain"; 17 | public static final String kCsv = "text/csv"; 18 | 19 | public static final String kAppGenericBinary = "application/octet-stream"; 20 | public static final String kAppJavascript = "application/javascript"; 21 | public static final String kAppJson = "application/json"; 22 | public static final String kAppXml = "application/xml"; 23 | 24 | public static final String kFontEot = "application/vnd.ms-fontobject"; 25 | public static final String kFontWoff = "application/x-font-woff"; 26 | public static final String kFontTtf = "application/x-font-ttf"; 27 | public static final String kFontOtf = "application/font-otf"; // typical, but not standardized (2013-07-10) 28 | 29 | public static final String kSvg = "image/svg+xml"; 30 | public static final String kImagePng = "image/png"; 31 | public static final String kImageGif = "image/gif"; 32 | public static final String kImageJpg = "image/jpg"; 33 | public static final String kImageIco = "image/vnd.microsoft.icon"; 34 | } 35 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/authenticators/MechIdAuthenticator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.authenticators; 5 | 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequest; 10 | import com.att.nsa.security.NsaApiKey; 11 | import com.att.nsa.security.NsaAuthenticator; 12 | import com.att.nsa.security.db.NsaApiDb; 13 | 14 | /** 15 | * An authenticator for AT&T MechIds. 16 | * 17 | * @author peter 18 | * 19 | * @param 20 | */ 21 | public class MechIdAuthenticator implements NsaAuthenticator 22 | { 23 | public MechIdAuthenticator ( NsaApiDb db ) 24 | { 25 | // fDb = db; 26 | } 27 | 28 | @Override 29 | public boolean qualify ( DrumlinRequest req ) 30 | { 31 | // we haven't implemented anything here yet, so there's no qualifying request 32 | return false; 33 | } 34 | 35 | @Override 36 | public K isAuthentic ( DrumlinRequest req ) 37 | { 38 | final String remoteAddr = req.getRemoteAddress (); 39 | authLog ( "MechId auth is not yet implemented.", remoteAddr ); 40 | return null; 41 | } 42 | 43 | private static void authLog ( String msg, String remoteAddr ) 44 | { 45 | log.info ( "AUTH-LOG(" + remoteAddr + "): " + msg ); 46 | } 47 | 48 | // private final NsaApiDb fDb; 49 | private static final Logger log = LoggerFactory.getLogger ( MechIdAuthenticator.class ); 50 | } 51 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/ui/UiPlugin.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.ui; 5 | 6 | import java.util.List; 7 | 8 | import com.att.nsa.drumlin.service.framework.routing.DrumlinRequestRouter; 9 | import com.att.nsa.drumlin.till.nv.rrNvReadable; 10 | 11 | /** 12 | * A plug-in for the UI framework 13 | * @author peter 14 | */ 15 | public interface UiPlugin 16 | { 17 | /** 18 | * Get the name of this plugin 19 | * @return 20 | */ 21 | public String getUiName (); 22 | 23 | /** 24 | * Get the base location for this plugin 25 | * @return 26 | */ 27 | public String getUiLink (); 28 | 29 | /** 30 | * Get the CSS files for this plugin. The system's standard CSS path is applied, so these 31 | * would be relative to that path. 32 | * @return a list of 0 or more CSS files to load on every page 33 | */ 34 | public List getUiCssList (); 35 | 36 | /** 37 | * Configure this plugin with the given settings. 38 | * @param settings 39 | */ 40 | public void configure ( rrNvReadable settings ); 41 | 42 | /** 43 | * Setup routing into this plugin. Routing paths must start with 44 | * the location given by getUiLink() 45 | * @param router 46 | */ 47 | public void setupRouting ( DrumlinRequestRouter router ); 48 | 49 | /** 50 | * When the servlet engine creates a new session, this method is called on all plugins. 51 | * @param s 52 | */ 53 | public void onNewSession ( UiSession s ); 54 | } 55 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/data/sha1HmacSigner.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.data; 6 | 7 | import java.security.InvalidKeyException; 8 | import java.security.NoSuchAlgorithmException; 9 | 10 | import javax.crypto.Mac; 11 | import javax.crypto.SecretKey; 12 | import javax.crypto.spec.SecretKeySpec; 13 | 14 | public class sha1HmacSigner 15 | { 16 | private static final String kHmacSha1Algo = "HmacSHA1"; 17 | 18 | public static String sign ( String message, String key ) 19 | { 20 | try 21 | { 22 | final SecretKey secretKey = new SecretKeySpec ( key.getBytes (), kHmacSha1Algo ); 23 | final Mac mac = Mac.getInstance ( kHmacSha1Algo ); 24 | mac.init ( secretKey ); 25 | final byte[] rawHmac = mac.doFinal ( message.getBytes () ); 26 | return rrConvertor.base64Encode ( rawHmac ); 27 | } 28 | catch ( InvalidKeyException e ) 29 | { 30 | throw new RuntimeException ( e ); 31 | } 32 | catch ( NoSuchAlgorithmException e ) 33 | { 34 | throw new RuntimeException ( e ); 35 | } 36 | catch ( IllegalStateException e ) 37 | { 38 | throw new RuntimeException ( e ); 39 | } 40 | } 41 | 42 | static public void main ( String args[] ) 43 | { 44 | if ( args.length != 2 ) 45 | { 46 | System.err.println ( "usage: sha1HmacSigner " ); 47 | } 48 | else if ( args.length == 2 ) 49 | { 50 | System.out.println ( sign ( args[0], args[1] ) ); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/configs/confimpl/SimplePathTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.configs.confimpl; 5 | 6 | import junit.framework.TestCase; 7 | 8 | import org.junit.Test; 9 | 10 | public class SimplePathTest extends TestCase 11 | { 12 | @Test 13 | public void testParseSimple () 14 | { 15 | final SimplePath p = SimplePath.parse ( "/a/b/c" ); 16 | assertEquals ( "c", p.getName () ); 17 | assertEquals ( "b", p.getParent().getName () ); 18 | assertEquals ( "a", p.getParent ().getParent().getName () ); 19 | assertEquals ( "/a/b/c", p.toString () ); 20 | } 21 | 22 | @Test 23 | public void testRootName () 24 | { 25 | final SimplePath p = SimplePath.getRootPath (); 26 | assertEquals ( "/", p.toString () ); 27 | assertNull ( p.getParent () ); 28 | } 29 | 30 | @Test 31 | public void testNaming () 32 | { 33 | for ( String path : kPaths ) 34 | { 35 | final SimplePath p = SimplePath.parse ( path ); 36 | assertEquals ( path, p.toString () ); 37 | } 38 | } 39 | 40 | @Test 41 | public void testParseRootEquivalent () 42 | { 43 | final SimplePath p = SimplePath.parse ( "/" ); 44 | assertEquals ( p, SimplePath.getRootPath () ); 45 | } 46 | 47 | @Test 48 | public void testTrailingSlashTrim () 49 | { 50 | final SimplePath p = SimplePath.parse ( "/a/b/" ); 51 | assertEquals ( "/a/b", p.toString () ); 52 | } 53 | 54 | private static final String[] kPaths = 55 | { 56 | "/", 57 | "/a", 58 | "/a/b" 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/uiRoutes.conf: -------------------------------------------------------------------------------- 1 | 2 | package com.att.nsa.ui.endpoints 3 | 4 | # a simple entry point 5 | GET / UiMain.getMain 6 | GET /index redirect:/ 7 | GET /index.htm redirect:/ 8 | GET /index.html redirect:/ 9 | 10 | # typical static file paths 11 | GET /css/ staticDir:css 12 | GET /js/ staticDir:js 13 | GET /images/ staticDir:images 14 | GET /font/ staticDir:font 15 | GET /favicon.ico staticFile:images/attLogo.gif 16 | GET /font-awesome/ staticDir:font-awesome 17 | 18 | # icon handling 19 | GET /apple-touch-icon-114x114.png staticFile:icons/ 20 | GET /apple-touch-icon-120x120.png staticFile:icons/ 21 | GET /apple-touch-icon-144x144.png staticFile:icons/ 22 | GET /apple-touch-icon-152x152.png staticFile:icons/ 23 | GET /apple-touch-icon-57x57.png staticFile:icons/ 24 | GET /apple-touch-icon-60x60.png staticFile:icons/ 25 | GET /apple-touch-icon-72x72.png staticFile:icons/ 26 | GET /apple-touch-icon-76x76.png staticFile:icons/ 27 | GET /apple-touch-icon-precomposed.png staticFile:icons/ 28 | GET /apple-touch-icon.png staticFile:icons/ 29 | GET /browserconfig.xml staticFile:icons/ 30 | GET /favicon-160x160.png staticFile:icons/ 31 | GET /favicon-16x16.png staticFile:icons/ 32 | GET /favicon-196x196.png staticFile:icons/ 33 | GET /favicon-32x32.png staticFile:icons/ 34 | GET /favicon-96x96.png staticFile:icons/ 35 | GET /favicon.ico staticFile:icons/ 36 | GET /mstile-144x144.png staticFile:icons/ 37 | GET /mstile-150x150.png staticFile:icons/ 38 | GET /mstile-310x150.png staticFile:icons/ 39 | GET /mstile-310x310.png staticFile:icons/ 40 | GET /mstile-70x70.png staticFile:icons/ 41 | -------------------------------------------------------------------------------- /Contributing.txt: -------------------------------------------------------------------------------- 1 | This software is distributed under a permissive open source 2 | license to allow it to be used in any projects, whether open 3 | source or proprietary. Contributions to the project are welcome 4 | and it is important to maintain clear record of contributions 5 | and terms under which they are licensed. 6 | 7 | To indicate your acceptance of Developer's Certificate of Origin 1.1 8 | terms, please add the following line to the end of the commit message 9 | for each contribution you make to the project: 10 | 11 | Signed-off-by : Your Name 12 | 13 | Developer's Certificate of Origin 1.1 14 | 15 | By making a contribution to this project, I certify that: 16 | 17 | (a) The contribution was created in whole or inpart by me and I 18 | have the right to submit it under the open source license indicated 19 | in the file: or 20 | 21 | (b) The contribution is based upon previous work that, to the best 22 | of my knowledge, is covered under an appropriate open source license 23 | and I have the right under that license to submit that work with 24 | modifications, whether created in whole or part by me, under the same 25 | open source license (unless I am permitted to submit under a different 26 | license), as indicated in the file; or 27 | 28 | (c) The contribution was provided directly to me by some other person 29 | who certified (a), (b) or (c) I have not modified it. 30 | 31 | (d) I understand and agree that this project and the contribution are 32 | public and that a record of the contribution (including all personal 33 | information I submit with it, including my sign-off)is maintained 34 | indefinitely and may be redistributed consistent with this project or 35 | the open source license(s) involved. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | Copyright (c) <2016>, AT&T Intellectual Property. All other rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted 6 | provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions 9 | and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of 11 | conditions and the following disclaimer in the documentation and/or other materials provided 12 | with the distribution. 13 | 3. All advertising materials mentioning features or use of this software must display the 14 | following acknowledgement: This product includes software developed by the AT&T. 15 | 4. Neither the name of AT&T nor the names of its contributors may be used to endorse or 16 | promote products derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY AT&T INTELLECTUAL PROPERTY ''AS IS'' AND ANY EXPRESS OR 19 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 21 | SHALL AT&T INTELLECTUAL PROPERTY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 26 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 27 | DAMAGE. -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/nv/impl/nvJvmSettings.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.nv.impl; 6 | 7 | import java.util.Collection; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | import java.util.Map.Entry; 11 | import java.util.TreeSet; 12 | 13 | public class nvJvmSettings extends nvBaseReadable 14 | { 15 | public nvJvmSettings () 16 | { 17 | super (); 18 | } 19 | 20 | public String getString ( String key ) throws missingReqdSetting 21 | { 22 | final String result = System.getProperty ( key ); 23 | if ( result == null ) 24 | { 25 | throw new missingReqdSetting ( key ); 26 | } 27 | return result; 28 | } 29 | 30 | @Override 31 | public boolean hasValueFor ( String key ) 32 | { 33 | return System.getProperties ().containsKey ( key ); 34 | } 35 | 36 | @Override 37 | public int size () 38 | { 39 | return System.getProperties ().size (); 40 | } 41 | 42 | @Override 43 | public Collection getAllKeys () 44 | { 45 | final TreeSet list = new TreeSet (); 46 | for ( Object o : System.getProperties ().keySet () ) 47 | { 48 | list.add ( o.toString () ); 49 | } 50 | return list; 51 | } 52 | 53 | @Override 54 | public Map getCopyAsMap () 55 | { 56 | HashMap map = new HashMap (); 57 | for ( Entry e : System.getProperties ().entrySet () ) 58 | { 59 | map.put ( e.getKey().toString(), e.getValue().toString () ); 60 | } 61 | return map; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/DrumlinRuntimeControls.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework; 6 | 7 | import java.util.Collection; 8 | import java.util.Map; 9 | 10 | import com.att.nsa.drumlin.till.nv.impl.nvBaseReadable; 11 | import com.att.nsa.drumlin.till.nv.impl.nvWriteableTable; 12 | 13 | /** 14 | * The runtime controls are read like regular settings in the system, but are not 15 | * expected to be cached. 16 | * 17 | * @author peter 18 | * 19 | */ 20 | public class DrumlinRuntimeControls extends nvBaseReadable 21 | { 22 | public static final String kSetting_LogHeaders = "drumlin.logging.requestHeaders"; 23 | 24 | public DrumlinRuntimeControls () 25 | { 26 | fTable = new nvWriteableTable (); 27 | } 28 | 29 | public void setLogHeaders ( boolean b ) 30 | { 31 | fTable.set ( kSetting_LogHeaders, b ); 32 | } 33 | 34 | @Override 35 | public int size () 36 | { 37 | return fTable.size(); 38 | } 39 | 40 | @Override 41 | public Collection getAllKeys () 42 | { 43 | return fTable.getAllKeys(); 44 | } 45 | 46 | @Override 47 | public Map getCopyAsMap () 48 | { 49 | return fTable.getCopyAsMap(); 50 | } 51 | 52 | @Override 53 | public boolean hasValueFor ( String key ) 54 | { 55 | return fTable.hasValueFor( key ); 56 | } 57 | 58 | @Override 59 | public String getString ( String key ) 60 | throws missingReqdSetting 61 | { 62 | return fTable.getString ( key ); 63 | } 64 | 65 | private final nvWriteableTable fTable; 66 | } 67 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/nv/impl/nvBaseWriteable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.nv.impl; 6 | 7 | import com.att.nsa.drumlin.till.data.rrConvertor; 8 | import com.att.nsa.drumlin.till.nv.rrNvWriteable; 9 | 10 | public abstract class nvBaseWriteable extends nvBaseReadable implements rrNvWriteable 11 | { 12 | @Override 13 | public void set ( String key, char value ) 14 | { 15 | set ( key, "" + value ); 16 | } 17 | 18 | @Override 19 | public void set ( String key, boolean value ) 20 | { 21 | set ( key, new Boolean ( value ).toString () ); 22 | } 23 | 24 | @Override 25 | public void set ( String key, int value ) 26 | { 27 | set ( key, new Integer ( value ).toString () ); 28 | } 29 | 30 | @Override 31 | public void set ( String key, long value ) 32 | { 33 | set ( key, new Long ( value ).toString () ); 34 | } 35 | 36 | @Override 37 | public void set ( String key, double value ) 38 | { 39 | set ( key, new Double ( value ).toString () ); 40 | } 41 | 42 | @Override 43 | public void set ( String key, byte[] value ) 44 | { 45 | set ( key, rrConvertor.bytesToHex ( value ) ); 46 | } 47 | 48 | @Override 49 | public void set ( String key, byte[] value, int offset, int length ) 50 | { 51 | set ( key, rrConvertor.bytesToHex ( value, offset, length ) ); 52 | } 53 | 54 | @Override 55 | public void set ( String key, String[] values ) 56 | { 57 | final StringBuffer sb = new StringBuffer (); 58 | boolean some = false; 59 | for ( String val : values ) 60 | { 61 | if ( some ) sb.append ( "," ); 62 | sb.append ( val ); 63 | some = true; 64 | } 65 | set ( key, sb.toString () ); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/util/rrVeloLogBridge.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.util; 6 | 7 | import org.apache.velocity.runtime.RuntimeServices; 8 | import org.apache.velocity.runtime.log.LogChute; 9 | import org.slf4j.Logger; 10 | 11 | public class rrVeloLogBridge implements org.apache.velocity.runtime.log.LogChute 12 | { 13 | public rrVeloLogBridge ( Logger log ) 14 | { 15 | this.log = log; 16 | } 17 | 18 | @Override 19 | public void init ( RuntimeServices rs ) throws Exception 20 | { 21 | } 22 | 23 | @Override 24 | public void log ( int level, String message ) 25 | { 26 | log ( level, message, null ); 27 | } 28 | 29 | @Override 30 | public void log ( int level, String message, Throwable t ) 31 | { 32 | switch ( level ) 33 | { 34 | case LogChute.DEBUG_ID: { if ( t == null ) log.debug ( message ); else log.debug ( message, t ); } break; 35 | case LogChute.INFO_ID: { if ( t == null ) log.info ( message ); else log.info ( message, t ); } break; 36 | case LogChute.WARN_ID: { if ( t == null ) log.warn ( message ); else log.warn ( message, t ); } break; 37 | case LogChute.ERROR_ID: { if ( t == null ) log.error ( message ); else log.error ( message, t ); } break; 38 | } 39 | } 40 | 41 | @Override 42 | public boolean isLevelEnabled ( int level ) 43 | { 44 | switch ( level ) 45 | { 46 | case LogChute.DEBUG_ID: { return log.isDebugEnabled (); } 47 | case LogChute.INFO_ID: { return log.isInfoEnabled (); } 48 | case LogChute.WARN_ID: { return log.isWarnEnabled (); } 49 | case LogChute.ERROR_ID: { return log.isErrorEnabled (); } 50 | } 51 | return false; 52 | } 53 | 54 | private final Logger log; 55 | } 56 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/corr.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 |
Configurable Alarm Correlator
11 | 12 |
13 |
14 | 21 |
22 | 23 |
Active Correlations
24 |
25 |
26 | #foreach ( $c in $cce.alarmState.allCorrelations ) 27 | 28 | #end 29 |
30 |
31 | 32 |
Active Alarms
33 |
34 |
Active Alarms: $!cce.alarmState.size()
35 | #foreach ( $a in $cce.alarmState.allAlarms ) 36 |
37 | $a 38 | 39 |
40 | #end 41 |
42 | 43 |
Correlator Metrics
44 |
45 |
Total Events: $!cce.metrics.totalEvents ($!cce.metrics.alarmRate)
46 |
Onsets: $!cce.metrics.totalOnsets
47 |
Clears: $!cce.metrics.totalClears
48 |
Correlations: $!cce.metrics.totalCorrelations
49 |
50 |
51 | 52 |
53 | 54 | #parse ( "footer.html" ) 55 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/db/NsaAuthDb.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.db; 5 | 6 | import com.att.nsa.security.NsaApiKey; 7 | 8 | /** 9 | * 10 | * @param 11 | * @deprecated use ReadWriteSecuredResource 12 | */ 13 | @Deprecated 14 | public interface NsaAuthDb { 15 | 16 | 17 | /** 18 | * 19 | * @param owner 20 | * @param resource 21 | * @throws AuthorizationServiceUnavailableException 22 | */ 23 | void createResource(K owner, String resource) throws AuthorizationServiceUnavailableException, ResourceExistsException; 24 | 25 | /** 26 | * 27 | * @param key 28 | * @param resource 29 | */ 30 | void permit(K key, String resource) throws AuthorizationServiceUnavailableException; 31 | 32 | /** 33 | * 34 | * @param key 35 | * @param resource 36 | */ 37 | void deny(K key, String resource) throws AuthorizationServiceUnavailableException; 38 | 39 | /** 40 | * 41 | * @param resource 42 | */ 43 | void permitAll(String resource) throws AuthorizationServiceUnavailableException; 44 | 45 | /** 46 | * 47 | * @param resource 48 | */ 49 | void denyAll(String resource) throws AuthorizationServiceUnavailableException; 50 | 51 | /** 52 | * Determines whether the given key is authorized for the (resource, operation) pair. 53 | * @param key An API Key 54 | * @param resource The resource to grant authorization to 55 | * @param operation The operation for which the key is permitted to execute on the resource 56 | * @return true if the key is permitted to perform the operation on the resource, otherwise false 57 | */ 58 | public boolean isAuthorized(K key, String resource, String operation) throws AuthorizationServiceUnavailableException; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/_cgListing.html: -------------------------------------------------------------------------------- 1 | 2 | #if ( !$cg.alarmTraversalConsistent || !$cg.parentTraversalConsistent ) 3 | #set ( $inconsistent = true ) 4 | #else 5 | #set ( $inconsistent = false ) 6 | #end 7 | 8 |
#if ( $inconsistent ) #end $cg.name
9 |
10 |
11 |
Anchor:
12 | #if ( !$cg.alarmTraversalConsistent ) 13 |
The traversals for this alarm set are not consistent!
14 | #else 15 |
$cg.anchorTopologyType.simpleName
16 | #end 17 |
18 | 19 |
20 |
Trigger:
21 |
$cg.trigger.describe()
22 |
23 | 24 |
Alarms:
25 | #foreach ( $ar in $cg.alarmRecords ) 26 |
27 |
$ar.label
28 |
$ar.alarmSpecification
29 |
@ $ar.traverser.describeReverse()
30 |
31 | #end 32 | 33 | #if ( $cg.parentRecords.size() > 0 ) 34 | #set ( $bps = $cg.badParents ) 35 |
Secondary To:
36 | #foreach ( $parent in $cg.parentRecords ) 37 |
38 | 39 |
@ $parent.traverser.describeForward()
40 |
41 | #end 42 | #end 43 |
44 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/console/consoleLineReader.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.console; 6 | 7 | import java.io.BufferedReader; 8 | import java.io.IOException; 9 | import java.io.InputStreamReader; 10 | 11 | import org.slf4j.LoggerFactory; 12 | 13 | public class consoleLineReader 14 | { 15 | public static String getLine ( String prompt ) throws IOException 16 | { 17 | return sfReader.getLine ( prompt ); 18 | } 19 | 20 | private interface reader 21 | { 22 | String getLine ( String prompt ) throws IOException; 23 | } 24 | 25 | static 26 | { 27 | jline.console.ConsoleReader cr = null; 28 | if ( Boolean.parseBoolean ( System.getProperty ( "rrJline", "true" ) ) ) 29 | { 30 | try 31 | { 32 | cr = new jline.console.ConsoleReader (); 33 | } 34 | catch ( IOException e ) 35 | { 36 | LoggerFactory.getLogger ( consoleLineReader.class ).warn ( "IOException initializing JLine. Falling back to standard Java I/O." ); 37 | cr = null; 38 | } 39 | } 40 | 41 | if ( cr != null ) 42 | { 43 | final jline.console.ConsoleReader crf = cr; 44 | sfReader = new reader () 45 | { 46 | @Override 47 | public String getLine ( String prompt ) throws IOException 48 | { 49 | return crf.readLine ( prompt ); 50 | } 51 | }; 52 | } 53 | else 54 | { 55 | final BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) ); 56 | sfReader = new reader () 57 | { 58 | @Override 59 | public String getLine ( String prompt ) throws IOException 60 | { 61 | System.out.print ( prompt ); 62 | System.out.flush (); 63 | return br.readLine (); 64 | } 65 | }; 66 | } 67 | } 68 | 69 | private static final reader sfReader; 70 | } 71 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/console/cmdLinePrefs.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.console; 6 | 7 | import java.util.Vector; 8 | 9 | import com.att.nsa.drumlin.till.nv.impl.nvWriteableTable; 10 | 11 | public class cmdLinePrefs extends nvWriteableTable 12 | { 13 | public cmdLinePrefs ( rrCmdLineParser clp ) 14 | { 15 | super (); 16 | 17 | fParser = clp; 18 | fLeftovers = new Vector (); 19 | } 20 | 21 | /** 22 | * get remaining arguments after the options are read 23 | * @return a vector of args 24 | */ 25 | public Vector getFileArguments () 26 | { 27 | return fLeftovers; 28 | } 29 | 30 | public String getFileArgumentsAsString () 31 | { 32 | final StringBuffer sb = new StringBuffer (); 33 | for ( String s : fLeftovers ) 34 | { 35 | sb.append ( " " ); 36 | sb.append ( s ); 37 | } 38 | return sb.toString().trim (); 39 | } 40 | 41 | /** 42 | * find out if an option was explicitly set by the caller 43 | * @param optionWord 44 | * @return true or false 45 | */ 46 | public boolean wasExplicitlySet ( String optionWord ) 47 | { 48 | return super.hasValueFor ( optionWord ); 49 | } 50 | 51 | 52 | public String getString ( String key ) throws missingReqdSetting 53 | { 54 | String result = null; 55 | if ( wasExplicitlySet ( key ) ) 56 | { 57 | result = super.getString ( key ); 58 | } 59 | else 60 | { 61 | result = fParser.getArgFor ( key ); 62 | } 63 | 64 | if ( result == null ) 65 | { 66 | throw new missingReqdSetting ( key ); 67 | } 68 | return result; 69 | } 70 | 71 | private final rrCmdLineParser fParser; 72 | private final Vector fLeftovers; 73 | 74 | void addLeftover ( String val ) 75 | { 76 | fLeftovers.add ( val ); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/traverse.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 |
Tests
11 | 32 | 33 |
34 |
35 |
36 |
41 | 42 |
43 |
44 |
45 | 46 |
 
47 |
48 |
Results
49 | #foreach ( $r in $targets ) 50 |
$r
51 | #end 52 |
53 | 54 |
55 | 56 | #parse ( "footer.html" ) 57 | 58 | 61 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/NsaApiKey.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | /** 7 | * An API key record. Note that any changes to the record via set() or enable/disable must 8 | * be written back to the API key db explicitly. This class doesn't write to an underlying 9 | * store. 10 | * 11 | * @author peter 12 | */ 13 | public interface NsaApiKey 14 | { 15 | /** 16 | * Get the unique API key value 17 | * @return the API key 18 | */ 19 | String getKey (); 20 | 21 | /** 22 | * Get the shared secret used for signing requests. 23 | * @return the API secret for this key 24 | */ 25 | String getSecret (); 26 | 27 | /** 28 | * Return true if this key is currently enabled. 29 | * @return true if enabled 30 | */ 31 | boolean enabled (); 32 | 33 | /** 34 | * Enable this key. 35 | */ 36 | void enable (); 37 | 38 | /** 39 | * Disable this key. 40 | */ 41 | void disable (); 42 | 43 | /** 44 | * Set additional data on the key record. For example, a username or email, 45 | * or app-level capability information. 46 | * @param key 47 | * @param val 48 | */ 49 | void set ( String key, String val ); 50 | 51 | /** 52 | * Get data from the key record other than the key and shared secret 53 | * @param key 54 | * @return a value, or null if none was set 55 | */ 56 | String get ( String key ); 57 | 58 | /** 59 | * Get data from the key record other than the key and shared secret 60 | * @param key 61 | * @param defVal the value to use if none is present 62 | * @return the value, or the default 63 | */ 64 | String get ( String key, String defVal ); 65 | 66 | /** 67 | * serialize this key for the config db 68 | * @return a string form of the key (typically JSON) 69 | */ 70 | String serialize (); 71 | } 72 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/configs/confimpl/MemConfigDbTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.configs.confimpl; 5 | 6 | import java.util.Map; 7 | import java.util.Set; 8 | 9 | import junit.framework.TestCase; 10 | 11 | import org.junit.Test; 12 | 13 | import com.att.nsa.configs.ConfigPath; 14 | 15 | public class MemConfigDbTest extends TestCase 16 | { 17 | @Test 18 | public void testDbStorage () 19 | { 20 | final String data = "this is some data"; 21 | final MemConfigDb db = new MemConfigDb (); 22 | db.store ( SimplePath.parse("/a/b/c"), data ); 23 | final String readdata = db.load ( SimplePath.parse("/a/b/c/") ); 24 | assertEquals ( data, readdata ); 25 | 26 | final SimplePath path = SimplePath.parse ( "/a/b/c" ); 27 | db.clear ( path ); 28 | assertFalse ( db.exists ( path )); 29 | } 30 | 31 | @Test 32 | public void testChildLookup () 33 | { 34 | final MemConfigDb db = new MemConfigDb (); 35 | for ( int i=0; i<10; i++ ) 36 | { 37 | db.store ( SimplePath.parse("/a/b/c/" + i), "data-"+i ); 38 | db.store ( SimplePath.parse("/a/d/e/" + i), "data-"+(i*10) ); 39 | } 40 | 41 | final Set children = db.loadChildrenNames ( SimplePath.parse("/a/b/c") ); 42 | assertEquals ( 10, children.size () ); 43 | assertTrue ( children.contains ( SimplePath.parse ( "/a/b/c/3" ) ) ); 44 | 45 | final Map childData = db.loadChildrenOf ( SimplePath.parse("/a/b/c") ); 46 | assertEquals ( 10, childData.size () ); 47 | assertTrue ( childData.containsKey ( SimplePath.parse ( "/a/b/c/3" ) ) ); 48 | 49 | final Map bChildData = db.loadChildrenOf ( SimplePath.parse("/a/b/") ); 50 | assertEquals ( 1, bChildData.size () ); 51 | assertTrue ( bChildData.containsKey ( SimplePath.parse ( "/a/b/c" ) ) ); 52 | assertNull ( bChildData.get ( SimplePath.parse ( "/a/b/c" ) ) ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/time/clock.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.time; 6 | 7 | import java.util.concurrent.TimeUnit; 8 | 9 | /** 10 | * Basic clock service, replaces System.currentTimeMillis(), but with test access. 11 | * 12 | * @author peter 13 | */ 14 | public class clock 15 | { 16 | public static long now () 17 | { 18 | return holder.instance.nowMs (); 19 | } 20 | 21 | /** 22 | * Provided for testing only. 23 | * @param c 24 | */ 25 | public static void replaceClock ( clock c ) 26 | { 27 | holder.instance = c; 28 | } 29 | 30 | /** 31 | * Switch to a test clock and return that instance. Equivalent to instantiating 32 | * a clock.testClock and calling replaceClock() with it. 33 | * 34 | * @return a test clock. 35 | */ 36 | public static testClock useNewTestClock () 37 | { 38 | final testClock tc = new testClock (); 39 | replaceClock ( tc ); 40 | return tc; 41 | } 42 | 43 | protected long nowMs () 44 | { 45 | return System.currentTimeMillis (); 46 | } 47 | 48 | private static class holder 49 | { 50 | // volatile: harmless in normal runs, as this is a singleton constructed 51 | // once and shared among threads (all cache the same reference). For test 52 | // runs (e.g. from JUnit), it ensures that replaceClock() takes effect in 53 | // all threads immediately. 54 | static volatile clock instance = new clock (); 55 | } 56 | 57 | /** 58 | * A simple testing clock. 59 | * @author peter 60 | */ 61 | public static class testClock extends clock 62 | { 63 | @Override 64 | public long nowMs () { return nowMs; } 65 | 66 | public void set ( long ms ) { nowMs = ms; } 67 | public void add ( long ms ) { nowMs += ms; } 68 | public void add ( long val, TimeUnit tu ) 69 | { 70 | add ( TimeUnit.MILLISECONDS.convert ( val, tu ) ); 71 | } 72 | 73 | private long nowMs = 1; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/authenticators/SimpleAuthenticator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.authenticators; 5 | 6 | import java.util.HashMap; 7 | 8 | import org.apache.commons.codec.binary.Base64; 9 | 10 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequest; 11 | import com.att.nsa.security.NsaAuthenticator; 12 | import com.att.nsa.security.db.simple.NsaSimpleApiKey; 13 | import com.att.nsa.security.db.simple.NsaSimpleApiKeyFactory; 14 | 15 | /** 16 | * Authenticates an HTTP Basic auth request against explicitly added username/passwords. 17 | * @author peter 18 | * 19 | */ 20 | public class SimpleAuthenticator implements NsaAuthenticator 21 | { 22 | public SimpleAuthenticator add ( String user, String password ) 23 | { 24 | fCreds.put ( user, password ); 25 | return this; 26 | } 27 | 28 | @Override 29 | public boolean qualify ( DrumlinRequest req ) 30 | { 31 | final String auth = req.getFirstHeader ( "Authorization" ); 32 | return auth != null && auth.startsWith ( "Basic " ); 33 | } 34 | 35 | @Override 36 | public NsaSimpleApiKey isAuthentic ( DrumlinRequest req ) 37 | { 38 | final String auth = req.getFirstHeader ( "Authorization" ).substring ( "Basic ".length () ); 39 | final String decoded = new String ( Base64.decodeBase64 ( auth.getBytes () ) ); 40 | final int colon = decoded.indexOf ( ":" ); 41 | if ( colon > -1 ) 42 | { 43 | final String user = decoded.substring ( 0, colon ); 44 | final String password = decoded.substring ( colon + 1 ); 45 | final String lookup = fCreds.get ( user ); 46 | if ( lookup != null && lookup.equals ( password ) ) 47 | { 48 | final NsaSimpleApiKeyFactory f = new NsaSimpleApiKeyFactory (); 49 | return f.makeNewKey ( user, password ); 50 | } 51 | } 52 | return null; 53 | } 54 | 55 | private final HashMap fCreds = new HashMap (); 56 | } 57 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/htmlForms/mime/DrumlinMimePart.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.app.htmlForms.mime; 5 | 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | 9 | /** 10 | * A MIME part. These are created by the multipart MIME reader via the supplied 11 | * part factory. 12 | * 13 | * @author peter@rathravane.com 14 | * 15 | */ 16 | public interface DrumlinMimePart 17 | { 18 | /** 19 | * Get the content type for this part. 20 | * @return a type string 21 | */ 22 | String getContentType (); 23 | 24 | /** 25 | * Get the content disposition value for this part. 26 | * @return a content disposition string 27 | */ 28 | String getContentDisposition (); 29 | 30 | /** 31 | * Get the name for this part. 32 | * @return a name string 33 | */ 34 | String getName (); 35 | 36 | /** 37 | * Get the value associated with a given content disposition key. If the value doesn't 38 | * exist, null is returned. If the value is not provided, an empty string is returned. 39 | * @param key 40 | * @return a string or null if undefined 41 | */ 42 | String getContentDispositionValue ( String key ); 43 | 44 | /** 45 | * open a stream to read this part's data. 46 | * @return an input stream 47 | * @throws IOException 48 | */ 49 | InputStream openStream () throws IOException; 50 | 51 | /** 52 | * Get this part's data as a string. 53 | * @return the part data as a string 54 | */ 55 | String getAsString (); 56 | 57 | /** 58 | * Discard this part. 59 | */ 60 | void discard (); 61 | 62 | /** 63 | * Used by the MIME reader to write bytes to the part. 64 | * @param line 65 | * @param offset 66 | * @param length 67 | * @throws IOException 68 | */ 69 | void write ( byte[] line, int offset, int length ) throws IOException; 70 | 71 | /** 72 | * Used by the MIME reader to close the part during its creation. 73 | * @throws IOException 74 | */ 75 | void close () throws IOException; 76 | } 77 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/app/userAgents/genericAgent.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.app.userAgents; 6 | 7 | import com.att.nsa.drumlin.app.userAgents.browsers.browser; 8 | import com.att.nsa.drumlin.app.userAgents.browsers.genericBrowser; 9 | import com.att.nsa.drumlin.app.userAgents.devices.device; 10 | import com.att.nsa.drumlin.app.userAgents.devices.genericDevice; 11 | 12 | /** 13 | * Used when the user agent is a completely generic/unknown system. 14 | * @author peter 15 | */ 16 | public class genericAgent implements userAgent 17 | { 18 | public genericAgent () 19 | { 20 | this ( new genericDevice(), new genericBrowser () ); 21 | } 22 | 23 | public genericAgent ( device d, browser b ) 24 | { 25 | fDevice = d; 26 | fBrowser = b; 27 | } 28 | 29 | @Override 30 | public String getDeviceName () 31 | { 32 | return fDevice.getName (); 33 | } 34 | 35 | @Override 36 | public String getOsName () 37 | { 38 | return fDevice.getOsName (); 39 | } 40 | 41 | @Override 42 | public String getOsVersion () 43 | { 44 | return fDevice.getOsVersion (); 45 | } 46 | 47 | @Override 48 | public String getBrowserCanonicalName () 49 | { 50 | return fBrowser.getName (); 51 | } 52 | 53 | @Override 54 | public String getBrowserCanonicalVersion () 55 | { 56 | return fBrowser.getVersion (); 57 | } 58 | 59 | @Override 60 | public boolean getIsMobile () 61 | { 62 | return fDevice.isMobile (); 63 | } 64 | 65 | @Override 66 | public boolean getIsFixedScreenSize () 67 | { 68 | return fDevice.getScreenInfo ().isFixedSize (); 69 | } 70 | 71 | @Override 72 | public int getScreenWidth () 73 | { 74 | return fDevice.getScreenInfo ().getWidth (); 75 | } 76 | 77 | @Override 78 | public int getScreenHeight () 79 | { 80 | return fDevice.getScreenInfo ().getHeight (); 81 | } 82 | 83 | @Override 84 | public int getScreenDpi () 85 | { 86 | return fDevice.getScreenInfo ().getDpi (); 87 | } 88 | 89 | private final device fDevice; 90 | private final browser fBrowser; 91 | } 92 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/routing/playish/StaticFileHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework.routing.playish; 6 | 7 | import java.io.IOException; 8 | import java.net.URL; 9 | import java.util.List; 10 | 11 | import org.slf4j.LoggerFactory; 12 | 13 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 14 | import com.att.nsa.util.StreamTools; 15 | 16 | public class StaticFileHandler implements DrumlinPlayishRouteHandler 17 | { 18 | public static final String kMaxAge = "drumlin.staticFile.cache.maxAgeSeconds"; 19 | 20 | public StaticFileHandler ( String routedPath, String staticFile ) 21 | { 22 | String file = staticFile.endsWith ( "/" ) ? ( staticFile + routedPath ) : staticFile; 23 | file = file.replaceAll ( "//", "/" ); 24 | 25 | fFile = file; 26 | fContentType = StaticDirHandler.mapToContentType ( fFile ); 27 | } 28 | 29 | @Override 30 | public void handle ( DrumlinRequestContext context, List args ) throws IOException 31 | { 32 | // expiry. currently global. 33 | final int cacheMaxAge = context.systemSettings ().getInt ( kMaxAge, -1 ); 34 | if ( cacheMaxAge > 0 ) 35 | { 36 | context.response().writeHeader ( "Cache-Control", "max-age=" + cacheMaxAge, true ); 37 | } 38 | 39 | log.info ( "finding stream [" + fFile + "]" ); 40 | final URL f = context.getServlet ().findStream ( fFile ); 41 | if ( f == null ) 42 | { 43 | log.warn ( "404 [" + fFile + "] not found" ); 44 | context.response ().sendError ( 404, fFile + " was not found on this server." ); 45 | } 46 | else 47 | { 48 | StreamTools.copyStream ( 49 | f.openStream (), 50 | context.response ().getStreamForBinaryResponse ( fContentType ) 51 | ); 52 | } 53 | } 54 | 55 | @Override 56 | public boolean actionMatches(String fullPath) 57 | { 58 | return false; 59 | } 60 | 61 | private final String fFile; 62 | private final String fContentType; 63 | private static final org.slf4j.Logger log = LoggerFactory.getLogger ( StaticFileHandler.class ); 64 | } 65 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/timedata/impl/mem/MemTsDbTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.timedata.impl.mem; 5 | 6 | import java.util.Iterator; 7 | import java.util.List; 8 | 9 | import junit.framework.TestCase; 10 | 11 | import org.junit.Test; 12 | 13 | import com.att.nsa.timedata.TimeSeriesEntry; 14 | 15 | public class MemTsDbTest extends TestCase 16 | { 17 | @Test 18 | public void testBasicPutGet () 19 | { 20 | final MemTsDb db = new MemTsDb (); 21 | db.put ( "foo", 1, "1" ); 22 | db.put ( "foo", 2, "2" ); 23 | db.put ( "foo", 3, "3" ); 24 | final TimeSeriesEntry val = db.get ( "foo", 2 ); 25 | assertNotNull ( val ); 26 | assertEquals ( "2", val.getValue () ); 27 | } 28 | 29 | @Test 30 | public void testRangeGetWithExactMatches () 31 | { 32 | final MemTsDb db = new MemTsDb (); 33 | db.put ( "foo", 1, "1" ); 34 | db.put ( "foo", 2, "2" ); 35 | db.put ( "foo", 3, "3" ); 36 | db.put ( "foo", 5, "5" ); 37 | db.put ( "foo", 6, "6" ); 38 | db.put ( "foo", 8, "8" ); 39 | final List> range = db.get ( "foo", 2, 6 ); 40 | assertNotNull ( range ); 41 | assertEquals ( 4, range.size () ); 42 | } 43 | 44 | @Test 45 | public void testRangeGetWithoutMatches () 46 | { 47 | final MemTsDb db = new MemTsDb (); 48 | db.put ( "foo", 1, "1" ); 49 | db.put ( "foo", 2, "2" ); 50 | db.put ( "foo", 3, "3" ); 51 | db.put ( "foo", 5, "5" ); 52 | db.put ( "foo", 6, "6" ); 53 | db.put ( "foo", 8, "8" ); 54 | final List> range = db.get ( "foo", 4, 10 ); 55 | assertNotNull ( range ); 56 | assertEquals ( 3, range.size () ); 57 | final Iterator> it = range.iterator (); 58 | assertTrue ( it.hasNext () ); 59 | assertEquals ( "5", it.next ().getValue () ); 60 | assertTrue ( it.hasNext () ); 61 | assertEquals ( "6", it.next ().getValue () ); 62 | assertTrue ( it.hasNext () ); 63 | assertEquals ( "8", it.next ().getValue () ); 64 | assertFalse ( it.hasNext () ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/context/DrumlinResponse.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework.context; 6 | 7 | import java.io.IOException; 8 | import java.io.OutputStream; 9 | import java.io.PrintWriter; 10 | import java.util.Map; 11 | 12 | /** 13 | * A response to a DrumlinRequest. 14 | * 15 | * @author peter@rathravane.com 16 | * 17 | */ 18 | public interface DrumlinResponse 19 | { 20 | /** 21 | * send an error using the servlet container's error page system 22 | * 23 | * @param err 24 | * @param msg 25 | */ 26 | void sendError ( int err, String msg ); 27 | 28 | /** 29 | * set the status code for the reply 30 | * 31 | * @param code 32 | */ 33 | DrumlinResponse setStatus ( int code ); 34 | int getStatusCode (); 35 | 36 | DrumlinResponse setContentType ( String mimeType ); 37 | 38 | DrumlinResponse send ( String content ) throws IOException; 39 | 40 | /** 41 | * send an error response with the given body 42 | * 43 | * @param err 44 | * @param content 45 | * @param mimeType 46 | * @throws IOException 47 | */ 48 | void sendErrorAndBody ( int err, String content, String mimeType ); 49 | 50 | PrintWriter getStreamForTextResponse () 51 | throws IOException; 52 | 53 | PrintWriter getStreamForTextResponse ( String contentType ) 54 | throws IOException; 55 | 56 | OutputStream getStreamForBinaryResponse () 57 | throws IOException; 58 | 59 | OutputStream getStreamForBinaryResponse ( String contentType ) 60 | throws IOException; 61 | 62 | void writeHeader ( String headerName, String headerValue ); 63 | 64 | void writeHeader ( String headerName, String headerValue, boolean overwrite ); 65 | 66 | /** 67 | * redirect the to the app-relative url 68 | * 69 | * @param url 70 | */ 71 | void redirect ( String url ); 72 | 73 | void redirect ( Class cls, String method ); 74 | 75 | void redirect ( Class cls, String method, Map args ); 76 | 77 | /** 78 | * redirect to the exact url 79 | * 80 | * @param url 81 | */ 82 | void redirectExactly ( String url ); 83 | } 84 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/older/cons.html: -------------------------------------------------------------------------------- 1 | 2 | #parse ( "header.html" ) 3 | 4 |
5 | 6 | #if ( $errorMsg ) 7 |
$errorMsg
8 | #end 9 | 10 |
Consolidator
11 | 12 | 13 |
14 | #if ( $alarm ) 15 |
$alarm.identifier
16 | #if ( $cons.alarmDb.getImpactsFor($alarm.identifier).size()>0 ) 17 |
18 |
Alarms to re-consolidate if this alarm changes:
19 | #foreach ( $impact in $cons.alarmDb.getImpactsFor($alarm.identifier) ) 20 | 21 | #end 22 |
23 | #end 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | #foreach ( $field in $alarm.allFields ) 33 | #set ( $doneOne = false ) 34 | #set ( $oddRow = true ) 35 | #foreach ( $entry in $alarm.getAllOpinionsOn($field).entrySet() ) 36 | 37 | 38 | 39 | 40 | 41 | 42 | #set ( $doneOne = true ) 43 | #if ( $oddRow ) #set($oddRow=false) #else #set($oddRow=true) #end 44 | #end 45 | #end 46 |
fieldsourcevalueconsolidated
#if(!$doneOne)$field#else #end$entry.getKey()$!entry.getValue()#if(!$doneOne)$!consAlarm.getValue($field)#end
47 |
48 | #else 49 |
Alarm DB
50 |
51 |
52 | #foreach ( $c in $cons.alarmDb.allAlarms ) 53 |
54 | #if ( $c.hasConflicts() ) #end 55 | $c.identifier 56 |
57 | #end 58 |
59 |
60 | #end 61 |
62 | 63 |
64 | 65 | #parse ( "footer.html" ) 66 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/store/rrJsonObjectFile.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.store; 6 | 7 | import java.io.File; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.io.InputStreamReader; 11 | import java.nio.charset.Charset; 12 | 13 | import org.json.JSONException; 14 | import org.json.JSONObject; 15 | import org.json.JSONTokener; 16 | 17 | public class rrJsonObjectFile 18 | { 19 | public static void initialize ( File file, int blockSize ) throws IOException 20 | { 21 | rrBlockFile.initialize ( file, blockSize ); 22 | } 23 | 24 | public rrJsonObjectFile ( File f ) throws IOException 25 | { 26 | this ( f, true ); 27 | } 28 | 29 | public rrJsonObjectFile ( File f, boolean withWrite ) throws IOException 30 | { 31 | this ( f, withWrite, null ); 32 | } 33 | 34 | public rrJsonObjectFile ( File f, boolean withWrite, String passwd ) throws IOException 35 | { 36 | fFile = new rrBlockFile ( f, withWrite, passwd ); 37 | } 38 | 39 | public String getFilePath () 40 | { 41 | return fFile.getFilePath (); 42 | } 43 | 44 | public void close () throws IOException 45 | { 46 | fFile.close (); 47 | } 48 | 49 | public JSONObject read ( long address ) throws IOException 50 | { 51 | JSONObject o = null; 52 | final InputStream is = fFile.readToStream ( address ); 53 | try 54 | { 55 | o = new JSONObject ( new JSONTokener ( new InputStreamReader ( is ) ) ); 56 | } 57 | catch ( JSONException e ) 58 | { 59 | throw new IOException ( e ); 60 | } 61 | finally 62 | { 63 | is.close (); 64 | } 65 | return o; 66 | } 67 | 68 | public long write ( JSONObject o ) throws IOException 69 | { 70 | final byte[] b = o.toString ().getBytes ( Charset.forName ( "UTF-8" ) ); 71 | return fFile.create ( b ); 72 | } 73 | 74 | public void overwrite ( long address, JSONObject o ) throws IOException 75 | { 76 | final byte[] b = o.toString ().getBytes ( Charset.forName ( "UTF-8" ) ); 77 | fFile.overwrite ( address, b ); 78 | } 79 | 80 | public void delete ( long address ) throws IOException 81 | { 82 | fFile.delete ( address ); 83 | } 84 | 85 | public long indexToAddress ( long index ) 86 | { 87 | return fFile.indexToAddress ( index ); 88 | } 89 | 90 | private final rrBlockFile fFile; 91 | } 92 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/ui/velocity/UiVelocityEventHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.ui.velocity; 5 | 6 | import org.apache.velocity.app.event.IncludeEventHandler; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | public class UiVelocityEventHandler implements IncludeEventHandler 11 | { 12 | /** 13 | * Called when an include-type directive is encountered ( 14 | * #include or #parse). May modify the path 15 | * of the resource to be included or may block the include entirely. All the 16 | * registered IncludeEventHandlers are called unless null is returned. If 17 | * none are registered the template at the includeResourcePath is retrieved. 18 | * 19 | * @param includeResourcePath the path as given in the include directive. 20 | * @param currentResourcePath the path of the currently rendering template that includes the 21 | * include directive. 22 | * @param directiveName name of the directive used to include the resource. (With the 23 | * standard directives this is either "parse" or "include"). 24 | * 25 | * @return a new resource path for the directive, or null to block the 26 | * include from occurring. 27 | */ 28 | public String includeEvent ( String includeResourcePath, String currentResourcePath, String directiveName ) 29 | { 30 | // in this scheme, the system always sees the included path as relative, because 31 | // when current is prefixed with the app tag, it's not thought to be an absolute path. 32 | // So velocity will go to the last slash of current, then append include. If current doesn't 33 | // contain a slash, it'll use includeResourcePath 34 | 35 | String result = includeResourcePath; 36 | final String appId = UiVelocityResourceLoader.getAppPrefix ( currentResourcePath ); 37 | if ( appId != null && !currentResourcePath.contains ( "/" ) ) 38 | { 39 | result = UiVelocityResourceLoader.encodeTemplateName ( appId, includeResourcePath ); 40 | } 41 | 42 | log.info ( "UiVelocityEventHandler.includeEvent ( " + includeResourcePath + ", " + 43 | currentResourcePath + ", " + directiveName + " ) --> " + result ); 44 | return result; 45 | } 46 | 47 | private static final Logger log = LoggerFactory.getLogger ( UiVelocityEventHandler.class ); 48 | } 49 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/framework/context/stdRenderer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.service.framework.context; 6 | 7 | import java.io.PrintWriter; 8 | import java.io.StringWriter; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | import org.apache.velocity.exception.ResourceNotFoundException; 13 | import org.slf4j.LoggerFactory; 14 | 15 | import com.att.nsa.drumlin.service.framework.rendering.DrumlinRenderContext; 16 | import com.att.nsa.drumlin.service.standards.HttpStatusCodes; 17 | 18 | class StdRenderer implements DrumlinRenderContext 19 | { 20 | StdRenderer ( DrumlinRequestContext hc ) 21 | { 22 | fContext = hc; 23 | } 24 | 25 | @Override 26 | public Object get ( String key ) 27 | { 28 | return fContext.fLocalContext.get ( key ); 29 | } 30 | 31 | @Override 32 | public void put ( String key, Object o ) 33 | { 34 | fContext.fLocalContext.put ( key, o ); 35 | } 36 | 37 | @Override 38 | public void remove ( String key ) 39 | { 40 | fContext.fLocalContext.remove ( key ); 41 | } 42 | 43 | @Override 44 | public void renderTemplate ( String templateName ) 45 | { 46 | renderTemplate ( templateName, "text/html" ); 47 | } 48 | 49 | @Override 50 | public void renderTemplate ( String templateName, String contentType ) 51 | { 52 | try 53 | { 54 | if ( fContext.fSession != null ) 55 | { 56 | final HashMap context = new HashMap (); 57 | fContext.fSession.buildTemplateContext ( context ); 58 | for ( Map.Entry e : context.entrySet () ) 59 | { 60 | put ( e.getKey (), e.getValue () ); 61 | } 62 | } 63 | 64 | final PrintWriter out = fContext.response().getStreamForTextResponse ( contentType ); 65 | fContext.merge ( templateName, fContext.fLocalContext, out ); 66 | } 67 | catch ( ResourceNotFoundException e ) 68 | { 69 | fContext.response ().sendError ( HttpStatusCodes.k404_notFound, e.getMessage () ); 70 | } 71 | catch ( Exception e ) 72 | { 73 | fContext.response ().sendError ( HttpStatusCodes.k500_internalServerError, e.getMessage () ); 74 | 75 | final StringWriter sw = new StringWriter (); 76 | final PrintWriter pw = new PrintWriter ( sw ); 77 | e.printStackTrace ( pw ); 78 | pw.close (); 79 | log.error ( sw.toString () ); 80 | } 81 | } 82 | 83 | private final DrumlinRequestContext fContext; 84 | static org.slf4j.Logger log = LoggerFactory.getLogger ( StdRenderer.class ); 85 | } 86 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/nv/impl/nvWriteableTable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.nv.impl; 6 | 7 | import java.util.Map; 8 | 9 | import com.att.nsa.drumlin.till.data.rrConvertor; 10 | import com.att.nsa.drumlin.till.nv.rrNvReadable; 11 | import com.att.nsa.drumlin.till.nv.rrNvWriteable; 12 | 13 | public class nvWriteableTable extends nvReadableTable implements rrNvWriteable 14 | { 15 | public nvWriteableTable () 16 | { 17 | super (); 18 | } 19 | 20 | public nvWriteableTable ( rrNvReadable that ) 21 | { 22 | super ( that == null ? null : that.getCopyAsMap () ); 23 | if ( that != null ) 24 | { 25 | for ( String key : that.getAllKeys () ) 26 | { 27 | set ( key, that.getString ( key, null ) ); 28 | } 29 | } 30 | } 31 | 32 | @Override 33 | public synchronized void set ( String key, String value ) 34 | { 35 | super.set ( key, value ); 36 | } 37 | 38 | @Override 39 | public void set ( String key, char value ) 40 | { 41 | super.set ( key, "" + value ); 42 | } 43 | 44 | public synchronized void set ( String key, int value ) 45 | { 46 | set ( key, "" + value ); 47 | } 48 | 49 | public synchronized void set ( String key, long value ) 50 | { 51 | set ( key, "" + value ); 52 | } 53 | 54 | public synchronized void set ( String key, double value ) 55 | { 56 | set ( key, "" + value ); 57 | } 58 | 59 | public synchronized void set ( String key, boolean value ) 60 | { 61 | set ( key, "" + value ); 62 | } 63 | 64 | public synchronized void set ( Map map ) 65 | { 66 | super.set ( map ); 67 | } 68 | 69 | @Override 70 | public synchronized void unset ( String key ) 71 | { 72 | super.clear ( key ); 73 | } 74 | 75 | @Override 76 | public synchronized void set ( String key, byte[] value ) 77 | { 78 | set ( key, value, 0, value.length ); 79 | } 80 | 81 | @Override 82 | public synchronized void set ( String key, byte[] value, int offset, int length ) 83 | { 84 | set ( key, rrConvertor.bytesToHex ( value, offset, length ) ); 85 | } 86 | 87 | @Override 88 | public void set ( String key, String[] values ) 89 | { 90 | final StringBuffer sb = new StringBuffer (); 91 | boolean one = false; 92 | for ( String value : values ) 93 | { 94 | if ( one ) sb.append ( "," ); 95 | sb.append ( value ); 96 | one = true; 97 | } 98 | set ( key, sb.toString () ); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/db/EncryptingApiDbImpl.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.db; 5 | 6 | import java.security.Key; 7 | 8 | import com.att.nsa.configs.ConfigDb; 9 | import com.att.nsa.configs.ConfigDbException; 10 | import com.att.nsa.configs.confimpl.EncryptingLayer; 11 | import com.att.nsa.security.NsaApiKey; 12 | 13 | /** 14 | * An extension of the base API Key DB implementation that uses an encrypting layer above the 15 | * provided config db. The provided db can be any implementation, this layer just adds 16 | * encryption to the values. Note that keys are visible, just values are encrypted. 17 | * 18 | * @author peter 19 | * 20 | * @param 21 | */ 22 | public class EncryptingApiDbImpl extends BaseNsaApiDbImpl 23 | { 24 | public static final String kEncAlgo = "AES/CBC/PKCS5Padding"; 25 | 26 | /** 27 | * Construct an encrypting wrapper around a given config db. The app's secret key and 28 | * initialization vector must be consistent across instantiations. Loss of either will 29 | * prevent recovery of stored data. 30 | * 31 | * @param db 32 | * @param keyFactory 33 | * @param appSecretKey The secret key for this data. This must be an AES compatible key. 34 | * @param iv The initializaton vector for the Cipher used in this implementation. 35 | * @throws ConfigDbException 36 | */ 37 | public EncryptingApiDbImpl ( ConfigDb db, NsaApiKeyFactory keyFactory, Key appSecretKey, byte[] iv ) throws ConfigDbException 38 | { 39 | super ( wrap ( db, appSecretKey, iv ), keyFactory ); 40 | } 41 | 42 | /** 43 | * Construct an encrypting wrapper around a given config db. The app's secret key and 44 | * initialization vector must be consistent across instantiations. Loss of either will 45 | * prevent recovery of stored data. 46 | * 47 | * @param db 48 | * @param rootPath 49 | * @param keyFactory 50 | * @param appSecretKey The secret key for this data. This must be an AES compatible key. 51 | * @param iv The initializaton vector for the Cipher used in this implementation. 52 | * @throws ConfigDbException 53 | */ 54 | public EncryptingApiDbImpl ( ConfigDb db, String rootPath, NsaApiKeyFactory keyFactory, Key appSecretKey, byte[] iv ) throws ConfigDbException 55 | { 56 | super ( wrap ( db, appSecretKey, iv ), rootPath, keyFactory ); 57 | } 58 | 59 | private static ConfigDb wrap ( ConfigDb storage, Key key, byte[] iv ) 60 | { 61 | return new EncryptingLayer ( storage, kEncAlgo, key, iv ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/security/NsaApiOnZkDbTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | import java.security.Key; 7 | import java.security.NoSuchAlgorithmException; 8 | 9 | import junit.framework.TestCase; 10 | 11 | import org.junit.Ignore; 12 | import org.junit.Test; 13 | 14 | import com.att.nsa.configs.ConfigDbException; 15 | import com.att.nsa.configs.confimpl.EncryptingLayer; 16 | import com.att.nsa.configs.confimpl.ZkConfigDb; 17 | import com.att.nsa.security.db.BaseNsaApiDbImpl; 18 | import com.att.nsa.security.db.EncryptingApiDbImpl; 19 | import com.att.nsa.security.db.NsaApiDb.KeyExistsException; 20 | import com.att.nsa.security.db.simple.NsaSimpleApiKey; 21 | import com.att.nsa.security.db.simple.NsaSimpleApiKeyFactory; 22 | 23 | @Ignore 24 | public class NsaApiOnZkDbTest extends TestCase 25 | { 26 | @Test 27 | public void testDbStorage () throws KeyExistsException, ConfigDbException 28 | { 29 | final ZkConfigDb cdb = new ZkConfigDb ( "localhost", "/fe3c" ); 30 | final BaseNsaApiDbImpl apiDb = new BaseNsaApiDbImpl ( cdb, new NsaSimpleApiKeyFactory () ); 31 | 32 | { 33 | final NsaSimpleApiKey key = apiDb.createApiKey ( "123", "456" ); 34 | key.set ( "foo", "bar" ); 35 | apiDb.saveApiKey ( key ); 36 | } 37 | 38 | { 39 | final NsaSimpleApiKey key = apiDb.loadApiKey ( "123" ); 40 | assertEquals ( "bar", key.get ( "foo" ) ); 41 | } 42 | 43 | { 44 | apiDb.deleteApiKey ( "123" ); 45 | assertNull ( apiDb.loadApiKey ( "123" ) ); 46 | } 47 | } 48 | 49 | @Test 50 | public void testDbEncStorage () throws KeyExistsException, ConfigDbException, NoSuchAlgorithmException 51 | { 52 | final byte[] kIv = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; 53 | 54 | final String base64Key = EncryptingLayer.createSecretKey (); 55 | 56 | final ZkConfigDb cdb = new ZkConfigDb ( "localhost", "/fe3c" ); 57 | 58 | final Key dbkey = EncryptingLayer.readSecretKey ( base64Key ); 59 | final BaseNsaApiDbImpl apiDb = new EncryptingApiDbImpl ( cdb, new NsaSimpleApiKeyFactory (), dbkey, kIv ); 60 | 61 | { 62 | final NsaSimpleApiKey key = apiDb.createApiKey ( "123", "456" ); 63 | key.set ( "foo", "bar" ); 64 | apiDb.saveApiKey ( key ); 65 | } 66 | 67 | { 68 | final NsaSimpleApiKey key = apiDb.loadApiKey ( "123" ); 69 | assertEquals ( "bar", key.get ( "foo" ) ); 70 | } 71 | 72 | { 73 | apiDb.deleteApiKey ( "123" ); 74 | assertNull ( apiDb.loadApiKey ( "123" ) ); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/NsaAuthenticatorService.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | import java.util.LinkedList; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequest; 12 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 13 | 14 | /** 15 | * A service for authenticating inbound requests. 16 | * @author peter 17 | * 18 | * @param 19 | */ 20 | public class NsaAuthenticatorService 21 | { 22 | /** 23 | * Construct the security manager against an API key database with a specific request time window size 24 | * @param requireSecureChannel if true, requests must be over a secure HTTPS channel 25 | */ 26 | public NsaAuthenticatorService ( boolean requireSecureChannel ) 27 | { 28 | fAuthenticators = new LinkedList> (); 29 | fRequireSecureChannel = requireSecureChannel; 30 | } 31 | 32 | /** 33 | * Add an authenticator to this service. 34 | * @param a 35 | */ 36 | public void addAuthenticator ( NsaAuthenticator a ) 37 | { 38 | fAuthenticators.add ( a ); 39 | } 40 | 41 | /** 42 | * Authenticate a user's request. This method returns the API key if the user is authentic, null otherwise. 43 | * 44 | * @param ctx 45 | * @return an api key record, or null 46 | */ 47 | public K authenticate ( DrumlinRequestContext ctx ) 48 | { 49 | final DrumlinRequest req = ctx.request(); 50 | 51 | // NOTE: this is important... if a user attempts to authenticate over an insecure channel, 52 | // the authentication request can potentially be spied on and replayed. Therefore, every 53 | // authentication must come in over a secure channel. 54 | if ( fRequireSecureChannel && !req.isSecure () ) 55 | { 56 | log.debug ( "Authentication request over insecure channel automatically fails." ); 57 | return null; 58 | } 59 | 60 | for ( NsaAuthenticator a : fAuthenticators ) 61 | { 62 | if ( a.qualify ( req ) ) 63 | { 64 | final K k = a.isAuthentic ( req ); 65 | if ( k != null ) return k; 66 | } 67 | // else: this request doesn't look right to any authenticator 68 | } 69 | return null; 70 | } 71 | 72 | // ultimately, this can go away and always be considered 'true', but we need 73 | // some transition time on existing cambria systems 74 | private final boolean fRequireSecureChannel; 75 | private final LinkedList> fAuthenticators; 76 | 77 | private static final Logger log = LoggerFactory.getLogger ( NsaAuthenticatorService.class ); 78 | } 79 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/db/NsaApiDb.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.db; 5 | 6 | import java.util.Map; 7 | import java.util.Set; 8 | 9 | import com.att.nsa.configs.ConfigDbException; 10 | import com.att.nsa.security.NsaApiKey; 11 | import com.att.nsa.security.NsaSecurityManagerException; 12 | 13 | /** 14 | * Persistent storage for API keys and secrets built over an abstract config db. Instances 15 | * of this DB must support concurrent access. 16 | */ 17 | public interface NsaApiDb 18 | { 19 | /** 20 | * Load all keys known to this database. (This could be expensive.) 21 | * @return a set of all API keys 22 | * @throws ConfigDbException 23 | */ 24 | Set loadAllKeys () throws ConfigDbException; 25 | 26 | /** 27 | * Load all keys known to this database. (This could be expensive.) 28 | * @return a map of api key to the api key record 29 | * @throws ConfigDbException 30 | */ 31 | Map loadAllKeyRecords () throws ConfigDbException; 32 | 33 | /** 34 | * Load an API key record based on the API key value 35 | * @param apiKey 36 | * @return an API key record or null 37 | * @throws ConfigDbException 38 | */ 39 | K loadApiKey ( String apiKey ) throws ConfigDbException; 40 | 41 | /** 42 | * Save an API key record. This must be used after changing auxiliary data on the record. 43 | * Note that the key must exist (via createApiKey). 44 | * @param key 45 | * @throws ConfigDbException 46 | */ 47 | void saveApiKey ( K apiKey ) throws ConfigDbException; 48 | 49 | /** 50 | * Create a new API key. If one exists, 51 | * @param key 52 | * @param sharedSecret 53 | * @return the new API key record 54 | * @throws ConfigDbException 55 | */ 56 | K createApiKey ( String key, String sharedSecret ) throws KeyExistsException, ConfigDbException; 57 | 58 | /** 59 | * Delete an API key; equivalent to deleteApiKey ( key.getKey() ) 60 | * @param key 61 | * @return true if the key existed 62 | * @throws ConfigDbException 63 | */ 64 | boolean deleteApiKey ( K key ) throws ConfigDbException; 65 | 66 | /** 67 | * Delete an API key from storage. 68 | * @param key 69 | * @return true if the key existed 70 | * @throws ConfigDbException 71 | */ 72 | boolean deleteApiKey ( String key ) throws ConfigDbException; 73 | 74 | /** 75 | * An exception to signal a key already exists 76 | */ 77 | public static class KeyExistsException extends NsaSecurityManagerException 78 | { 79 | public KeyExistsException ( String key ) { super ( "API key " + key + " exists" ); } 80 | private static final long serialVersionUID = 1L; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/NsaAuthorizationService.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 7 | import com.att.nsa.security.db.AuthorizationServiceUnavailableException; 8 | import com.att.nsa.security.db.NsaAuthDb; 9 | 10 | /** 11 | * A service for authorizing inbound requests 12 | * @deprecated we don't want to authorize based on HTTP transaction 13 | */ 14 | @Deprecated 15 | public class NsaAuthorizationService { 16 | 17 | private final NsaAuthDb authDb; 18 | 19 | public NsaAuthorizationService(NsaAuthDb authDb) { 20 | this.authDb = authDb; 21 | } 22 | 23 | public void permitAll(K key, DrumlinRequestContext ctx) throws AuthorizationServiceUnavailableException { 24 | 25 | if (key == null) throw new IllegalArgumentException("Key cannot be null"); 26 | 27 | final String resource = ctx.request().getUrl(); 28 | // final String operation = ctx.request().getMethod(); 29 | 30 | getAuthDb().permitAll(resource); 31 | } 32 | 33 | public void permit(K key, DrumlinRequestContext ctx) throws AuthorizationServiceUnavailableException { 34 | 35 | if (key == null) throw new IllegalArgumentException("Key cannot be null"); 36 | 37 | final String resource = ctx.request().getUrl(); 38 | // final String operation = ctx.request().getMethod(); 39 | 40 | getAuthDb().permit(key, resource); 41 | } 42 | 43 | public void denyAll(K key, DrumlinRequestContext ctx) throws AuthorizationServiceUnavailableException { 44 | 45 | if (key == null) throw new IllegalArgumentException("Key cannot be null"); 46 | 47 | final String resource = ctx.request().getUrl(); 48 | // final String operation = ctx.request().getMethod(); 49 | 50 | getAuthDb().denyAll(resource); 51 | } 52 | 53 | public void deny(K key, DrumlinRequestContext ctx) throws AuthorizationServiceUnavailableException { 54 | 55 | if (key == null) throw new IllegalArgumentException("Key cannot be null"); 56 | 57 | final String resource = ctx.request().getUrl(); 58 | // final String operation = ctx.request().getMethod(); 59 | 60 | getAuthDb().deny(key, resource); 61 | } 62 | 63 | public boolean isAuthorized(K key, DrumlinRequestContext ctx) throws AuthorizationServiceUnavailableException { 64 | 65 | if (key == null) throw new IllegalArgumentException("Key cannot be null"); 66 | 67 | final String resource = ctx.request().getUrl(); 68 | final String operation = ctx.request().getMethod(); 69 | 70 | return getAuthDb().isAuthorized(key, resource, operation); 71 | } 72 | 73 | private NsaAuthDb getAuthDb() { 74 | return this.authDb; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/resources/templates/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AT&T 2020 Systems Control 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | #foreach ( $script in $headerScripts ) 17 | 18 | #end 19 | 20 | 21 | #foreach ( $plugin in $plugins ) 22 | 23 | #foreach ( $cssName in $plugin.getUiCssList() ) 24 | 25 | #end 26 | #end 27 | 28 | 29 | 30 | 31 | 57 | 58 | #if($preContainerParse) 59 | #parse($preContainerParse) 60 | #end 61 | 62 |
63 | 64 | #foreach ( $msg in $!messages ) 65 | 69 | #end 70 | 71 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/data/uniqueStringGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.data; 6 | 7 | import java.security.NoSuchAlgorithmException; 8 | import java.security.SecureRandom; 9 | 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | /** 14 | * create a string that's very unlikely to be guessed 15 | * @author peter 16 | */ 17 | public class uniqueStringGenerator 18 | { 19 | public static String create ( ) 20 | { 21 | final byte[] val = createValue ( 8 ); 22 | return rrConvertor.bytesToHexString ( val ); 23 | } 24 | 25 | public static String createKeyUsingAlphabet ( String alphabet ) 26 | { 27 | final int alphabetLength = alphabet.length (); 28 | final byte[] bytes = createValue ( 8 ); 29 | final StringBuffer sb = new StringBuffer (); 30 | for ( byte b : bytes ) 31 | { 32 | final int letterIndex = Math.abs ( b ) % alphabetLength; 33 | final char letter = alphabet.charAt ( letterIndex ); 34 | sb.append ( letter ); 35 | } 36 | return sb.toString (); 37 | } 38 | 39 | public static String createKeyUsingAlphabet ( String alphabet, int length ) 40 | { 41 | String result = createKeyUsingAlphabet ( alphabet ); 42 | while ( result.length () < length ) 43 | { 44 | result += createKeyUsingAlphabet ( alphabet ); 45 | } 46 | return result.substring ( 0, length ); 47 | } 48 | 49 | public static String createUrlKey () 50 | { 51 | return createKeyUsingAlphabet ( kUrlKeyAlphabet ); 52 | } 53 | 54 | public static String createMsStyleKeyString ( ) 55 | { 56 | final String original = createKeyUsingAlphabet ( kLicenseKeyAlphabet ); 57 | 58 | final StringBuffer sb = new StringBuffer (); 59 | int position = -1; 60 | for ( int i=0; i 0 && position % 5 == 0 ) 65 | { 66 | sb.append ( " " ); 67 | } 68 | sb.append ( letter ); 69 | } 70 | return sb.toString (); 71 | } 72 | 73 | private static final String kLicenseKeyAlphabet = "123456789BCDFGHJKLMNPQRTVWXYZ"; 74 | private static final String kUrlKeyAlphabet = "0123456789ABCDFGHJKLMNPQRTVWXYZabcdefhigjklmnopqrstuvwxyz"; 75 | 76 | public static byte[] createValue ( int size ) 77 | { 78 | try 79 | { 80 | final SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); 81 | byte[] salt = new byte[ size ]; 82 | random.nextBytes(salt); 83 | return salt; 84 | } 85 | catch ( NoSuchAlgorithmException e ) 86 | { 87 | log.error ( e.getMessage () ); 88 | throw new RuntimeException ( e ); 89 | } 90 | } 91 | 92 | private static final Logger log = LoggerFactory.getLogger ( uniqueStringGenerator.class ); 93 | } 94 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/service/standards/HttpStatusCodes.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.drumlin.service.standards; 5 | 6 | public class HttpStatusCodes 7 | { 8 | public static final int k100_continue = 100; 9 | public static final int k101_switchingProtocols = 101; 10 | 11 | public static final int k200_ok = 200; 12 | public static final int k201_created = 201; 13 | public static final int k202_accepted = 202; 14 | public static final int k203_nonAuthoritativeInformation = 203; 15 | public static final int k204_noContent = 204; // HTTP/1.1: "MUST NOT include a message-body" 16 | public static final int k205_resetContent = 205; // HTTP/1.1: "MUST NOT include an entity" 17 | public static final int k206_partialContent = 206; 18 | 19 | public static final int k300_multipleChoices = 300; 20 | public static final int k301_movedPermanently = 301; 21 | public static final int k302_found = 302; 22 | public static final int k303_seeOther = 303; 23 | public static final int k304_notModified = 304; 24 | public static final int k305_useProxy = 305; 25 | public static final int k307_temporaryRedirect = 307; 26 | 27 | public static final int k400_badRequest = 400; 28 | public static final int k401_unauthorized = 401; 29 | public static final int k402_paymentRequired = 402; 30 | public static final int k403_forbidden = 403; 31 | public static final int k404_notFound = 404; 32 | public static final int k405_methodNotAllowed = 405; 33 | public static final int k406_notAcceptable = 406; 34 | public static final int k407_proxyAuthReqd = 407; 35 | public static final int k408_requestTimeout = 408; 36 | public static final int k409_conflict = 409; 37 | public static final int k410_gone = 410; 38 | public static final int k411_lengthRequired = 411; 39 | public static final int k412_preconditionFailed = 412; 40 | public static final int k413_requestEntityTooLarge = 413; 41 | public static final int k414_requestUriTooLong = 414; 42 | public static final int k415_unsupportedMediaType = 415; 43 | public static final int k416_requestedRangeNotSatisfiable = 416; 44 | public static final int k417_expectationFailed = 417; 45 | public static final int k428_preconditionRequired = 428; 46 | public static final int k429_tooManyRequests = 429; 47 | public static final int k431_requestHeaderFieldsTooLarge = 431; 48 | 49 | public static final int k500_internalServerError = 500; 50 | public static final int k501_notImplemented = 501; 51 | public static final int k502_badGateway = 502; 52 | public static final int k503_serviceUnavailable = 503; 53 | public static final int k504_gatewayTimeout = 504; 54 | public static final int k505_httpVersionNotSupported = 505; 55 | public static final int k511_networkAuthenticationRequired = 511; 56 | } 57 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/nv/impl/nvReadableTable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.nv.impl; 6 | 7 | import java.util.Collection; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | import java.util.Map.Entry; 11 | import java.util.Properties; 12 | import java.util.TreeSet; 13 | 14 | import com.att.nsa.drumlin.till.nv.rrNvReadable; 15 | 16 | public class nvReadableTable extends nvBaseReadable implements rrNvReadable 17 | { 18 | public nvReadableTable () 19 | { 20 | this ( (Map)null ); 21 | } 22 | 23 | public nvReadableTable ( Map content ) 24 | { 25 | if ( content != null ) 26 | { 27 | fTable = content; 28 | } 29 | else 30 | { 31 | fTable = new HashMap (); 32 | } 33 | } 34 | 35 | public nvReadableTable ( Properties content ) 36 | { 37 | fTable = new HashMap (); 38 | for ( Entry e : content.entrySet () ) 39 | { 40 | fTable.put ( e.getKey().toString (), e.getValue ().toString () ); 41 | } 42 | } 43 | 44 | @Override 45 | public String toString () 46 | { 47 | return fTable.toString (); 48 | } 49 | 50 | public synchronized void clear ( String key ) 51 | { 52 | fTable.remove ( key ); 53 | } 54 | 55 | public synchronized void clear () 56 | { 57 | fTable.clear (); 58 | } 59 | 60 | public synchronized boolean hasValueFor ( String key ) 61 | { 62 | return fTable.containsKey ( key ); 63 | } 64 | 65 | public synchronized String getString ( String key ) throws missingReqdSetting 66 | { 67 | final String result = fTable.get ( key ); 68 | if ( result == null ) 69 | { 70 | throw new missingReqdSetting ( key ); 71 | } 72 | return result; 73 | } 74 | 75 | @Override 76 | public synchronized int size () 77 | { 78 | return fTable.size (); 79 | } 80 | 81 | @Override 82 | public synchronized Collection getAllKeys () 83 | { 84 | final TreeSet list = new TreeSet (); 85 | for ( Object o : fTable.keySet () ) 86 | { 87 | list.add ( o.toString () ); 88 | } 89 | return list; 90 | } 91 | 92 | @Override 93 | public synchronized Map getCopyAsMap () 94 | { 95 | HashMap map = new HashMap (); 96 | for ( Entry e : fTable.entrySet () ) 97 | { 98 | map.put ( e.getKey(), e.getValue() ); 99 | } 100 | return map; 101 | } 102 | 103 | protected synchronized void set ( String key, String val ) 104 | { 105 | fTable.put ( key, val ); 106 | } 107 | 108 | protected synchronized void set ( Map map ) 109 | { 110 | fTable.putAll ( map ); 111 | } 112 | 113 | private final Map fTable; 114 | } 115 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/ui/UiSession.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.ui; 5 | 6 | import java.util.HashMap; 7 | import java.util.LinkedList; 8 | import java.util.List; 9 | 10 | import javax.servlet.ServletException; 11 | 12 | import com.att.nsa.drumlin.service.framework.DrumlinConnection; 13 | import com.att.nsa.drumlin.service.framework.DrumlinConnectionContext; 14 | import com.att.nsa.drumlin.service.framework.DrumlinServlet; 15 | import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext; 16 | 17 | public class UiSession implements DrumlinConnection 18 | { 19 | public UiSession () 20 | { 21 | fMsgs = new LinkedList (); 22 | } 23 | 24 | public enum Level 25 | { 26 | INFO, 27 | WARNING 28 | } 29 | 30 | public static class Message 31 | { 32 | public Message ( Level level, String msg ) 33 | { 34 | fLevel = level; 35 | fMsg = msg; 36 | } 37 | public String getMessage () { return fMsg; } 38 | public Level getLevel () { return fLevel; } 39 | private final String fMsg; 40 | private final Level fLevel; 41 | } 42 | 43 | /** 44 | * Convenience method to downcast a session to a UiSession. 45 | * Will throw ClassCastExcpetion if the session is not the correct type. 46 | * @param ctx 47 | * @return 48 | */ 49 | public static UiSession getUiSession ( DrumlinRequestContext ctx ) 50 | { 51 | return (UiSession) ctx.session (); 52 | } 53 | 54 | public void setStatusMessage ( Message m ) 55 | { 56 | synchronized ( fMsgs ) 57 | { 58 | fMsgs.add ( m ); 59 | } 60 | } 61 | 62 | public List getMessages () 63 | { 64 | synchronized ( fMsgs ) 65 | { 66 | final LinkedList result = new LinkedList (); 67 | result.addAll ( fMsgs ); 68 | fMsgs.clear (); 69 | return result; 70 | } 71 | } 72 | 73 | @Override 74 | public void onSessionCreate ( DrumlinServlet ws, DrumlinConnectionContext dcc ) throws ServletException 75 | { 76 | } 77 | 78 | @Override 79 | public void onSessionClose () 80 | { 81 | } 82 | 83 | @Override 84 | public void noteActivity () 85 | { 86 | } 87 | 88 | @Override 89 | public void buildTemplateContext ( HashMap context ) 90 | { 91 | context.put ( "messages", getMessages() ); 92 | } 93 | 94 | public void put ( String key, Object obj ) 95 | { 96 | fObjects.put ( key, obj ); 97 | } 98 | 99 | public void clear ( String key ) 100 | { 101 | fObjects.remove ( key ); 102 | } 103 | 104 | public Object get ( String key ) 105 | { 106 | return fObjects.get ( key ); 107 | } 108 | 109 | private HashMap fObjects = new HashMap (); 110 | private LinkedList fMsgs = new LinkedList (); 111 | } 112 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/nv/impl/nvReadableStack.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.nv.impl; 6 | 7 | import java.util.Collection; 8 | import java.util.HashMap; 9 | import java.util.LinkedList; 10 | import java.util.Map; 11 | import java.util.TreeSet; 12 | 13 | import com.att.nsa.drumlin.till.nv.rrNvReadable; 14 | 15 | public class nvReadableStack extends nvBaseReadable implements rrNvReadable 16 | { 17 | public nvReadableStack () 18 | { 19 | super (); 20 | fStack = new LinkedList (); 21 | } 22 | 23 | @Override 24 | public String toString () 25 | { 26 | return getCopyAsMap().toString (); 27 | } 28 | 29 | public void push ( rrNvReadable p ) 30 | { 31 | fStack.addFirst ( p ); 32 | } 33 | 34 | public void pushBelow ( rrNvReadable below, rrNvReadable above ) 35 | { 36 | int i = fStack.indexOf ( above ); 37 | if ( i < 0 ) 38 | { 39 | push ( below ); 40 | } 41 | else 42 | { 43 | fStack.add ( i+1, below ); 44 | } 45 | } 46 | 47 | public String getString ( String key ) throws missingReqdSetting 48 | { 49 | String result = null; 50 | boolean found = false; 51 | for ( rrNvReadable p : fStack ) 52 | { 53 | if ( p.hasValueFor ( key ) ) 54 | { 55 | result = p.getString ( key ); 56 | found = true; 57 | break; 58 | } 59 | } 60 | 61 | if ( !found ) 62 | { 63 | throw new missingReqdSetting ( key ); 64 | } 65 | 66 | return result; 67 | } 68 | 69 | public boolean hasValueFor ( String key ) 70 | { 71 | boolean result = false; 72 | for ( rrNvReadable p : fStack ) 73 | { 74 | result = p.hasValueFor ( key ); 75 | if ( result ) break; 76 | } 77 | return result; 78 | } 79 | 80 | public void rescan () throws loadException 81 | { 82 | for ( rrNvReadable p : fStack ) 83 | { 84 | p.rescan (); 85 | } 86 | } 87 | 88 | private final LinkedList fStack; 89 | 90 | @Override 91 | public int size () 92 | { 93 | return getAllKeys().size (); 94 | } 95 | 96 | @Override 97 | public Collection getAllKeys () 98 | { 99 | final TreeSet set = new TreeSet (); 100 | for ( rrNvReadable r : fStack ) 101 | { 102 | set.addAll ( r.getAllKeys () ); 103 | } 104 | return set; 105 | } 106 | 107 | @Override 108 | public Map getCopyAsMap () 109 | { 110 | // this could be faster, but it's an easy way to get the correct values 111 | final HashMap map = new HashMap (); 112 | for ( String key : getAllKeys () ) 113 | { 114 | final String val = getString ( key, null ); 115 | if ( val != null ) 116 | { 117 | map.put ( key, val ); 118 | } 119 | } 120 | return map; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/security/authenticators/OriginalUebAuthenticatorTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security.authenticators; 5 | 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | 9 | import junit.framework.TestCase; 10 | 11 | import org.junit.Test; 12 | 13 | import com.att.nsa.configs.ConfigDbException; 14 | import com.att.nsa.configs.confimpl.MemConfigDb; 15 | import com.att.nsa.drumlin.till.data.sha1HmacSigner; 16 | import com.att.nsa.security.NsaApiKey; 17 | import com.att.nsa.security.db.BaseNsaApiDbImpl; 18 | import com.att.nsa.security.db.NsaApiDb.KeyExistsException; 19 | import com.att.nsa.security.db.simple.NsaSimpleApiKey; 20 | import com.att.nsa.security.db.simple.NsaSimpleApiKeyFactory; 21 | 22 | public class OriginalUebAuthenticatorTest extends TestCase 23 | { 24 | @Test 25 | public void testAuth () throws KeyExistsException, ConfigDbException 26 | { 27 | final MemConfigDb cdb = new MemConfigDb (); 28 | final BaseNsaApiDbImpl apiDb = new BaseNsaApiDbImpl ( cdb, new NsaSimpleApiKeyFactory () ); 29 | 30 | { 31 | final NsaSimpleApiKey key = apiDb.createApiKey ( "123", "456" ); 32 | apiDb.saveApiKey ( key ); 33 | } 34 | 35 | final OriginalUebAuthenticator mgr = new OriginalUebAuthenticator ( apiDb, 1000*60*10 ); 36 | 37 | NsaApiKey key = mgr.authenticate ( "localhost", null, "badXDate", "badDate", null ); 38 | assertNull ( "no xauth", key ); 39 | 40 | key = mgr.authenticate ( "localhost", "badXauth", "badXDate", "badDate", null ); 41 | assertNull ( "bad xauth", key ); 42 | 43 | key = mgr.authenticate ( "localhost", "nosuch:key", "badXDate", "badDate", null ); 44 | assertNull ( "bad date", key ); 45 | 46 | key = mgr.authenticate ( "localhost", "nosuch:key", sdf.format ( new Date() ), null, null ); 47 | assertNull ( "no api key", key ); 48 | 49 | key = mgr.authenticate ( "localhost", "123:xxx", sdf.format ( new Date() ), null, null ); 50 | assertNull ( "bad signature", key ); 51 | 52 | final String xDate = sdf.format(new Date()); 53 | final String sig = sha1HmacSigner.sign ( xDate, "456" ); 54 | key = mgr.authenticate ( "localhost", "123:" + sig, xDate, null, null ); 55 | assertNotNull ( key ); 56 | } 57 | 58 | @Test 59 | public void testDateParse () throws KeyExistsException, ConfigDbException 60 | { 61 | assertEquals ( 1434552360000L, parseDate ( "2015-06-17T10:46:00-0400" ) ); 62 | assertEquals ( 1434552360000L, parseDate ( "2015-06-17T10:46:00-04:00" ) ); 63 | } 64 | 65 | private long parseDate ( String s ) 66 | { 67 | final Date d = OriginalUebAuthenticator.getClientDate ( s ); 68 | return d == null ? -1 : d.getTime (); 69 | } 70 | 71 | private static final SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ssz" ); 72 | } 73 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/console/shell/simpleCommand.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.console.shell; 6 | 7 | import java.io.PrintStream; 8 | import java.util.HashMap; 9 | 10 | import com.att.nsa.drumlin.till.console.rrCmdLineParser; 11 | import com.att.nsa.drumlin.till.console.cmdLinePrefs; 12 | import com.att.nsa.drumlin.till.console.rrConsole.usageException; 13 | import com.att.nsa.drumlin.till.nv.rrNvReadable; 14 | 15 | public abstract class simpleCommand implements command 16 | { 17 | protected simpleCommand ( String cmd ) 18 | { 19 | this ( cmd, cmd, null ); 20 | } 21 | 22 | protected simpleCommand ( String cmd, String usage ) 23 | { 24 | this ( cmd, usage, null ); 25 | } 26 | 27 | protected simpleCommand ( String cmd, String usage, String help ) 28 | { 29 | fCmd = cmd; 30 | fUsage = usage; 31 | fHelp = help; 32 | fArgsParser = new rrCmdLineParser (); 33 | fPrefs = null; 34 | fEnabled = true; 35 | } 36 | 37 | public void enable ( boolean e ) 38 | { 39 | fEnabled = e; 40 | } 41 | 42 | public boolean enabled () 43 | { 44 | return fEnabled; 45 | } 46 | 47 | @Override 48 | public final void checkArgs ( rrNvReadable basePrefs, String[] args ) throws usageException 49 | { 50 | setupParser ( fArgsParser ); 51 | fPrefs = fArgsParser.processArgs ( args ); 52 | } 53 | 54 | @Override 55 | public String getCommand () { return fCmd; } 56 | 57 | @Override 58 | public String getUsage () { return fUsage; } 59 | 60 | @Override 61 | public String getHelp () { return fHelp; } 62 | 63 | @Override 64 | public final consoleLooper.inResult execute ( HashMap workspace, PrintStream outTo ) throws usageException 65 | { 66 | try 67 | { 68 | return execute ( workspace, fPrefs, outTo ); 69 | } 70 | catch ( rrNvReadable.missingReqdSetting e ) 71 | { 72 | throw new usageException ( e ); 73 | } 74 | } 75 | 76 | /** 77 | * Override this to run the command. 78 | * @param prefs 79 | * @param outTo 80 | * @return true to continue, false to exit 81 | * @throws com.rathravane.rrConsole.ui.console2.console.usageException 82 | * @throws missingReqdSetting 83 | */ 84 | protected abstract consoleLooper.inResult execute ( HashMap workspace, cmdLinePrefs p, PrintStream outTo ) throws usageException, rrNvReadable.missingReqdSetting; 85 | 86 | /** 87 | * override this to specify arguments for the command 88 | * @param clp 89 | */ 90 | protected void setupParser ( rrCmdLineParser clp ) {} 91 | 92 | private final String fCmd; 93 | private final String fUsage; 94 | private final String fHelp; 95 | 96 | private final rrCmdLineParser fArgsParser; 97 | private cmdLinePrefs fPrefs; 98 | private boolean fEnabled; 99 | } 100 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/data/base64/rrcBase64OutputStream.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.data.base64; 6 | 7 | import java.io.IOException; 8 | import java.io.OutputStream; 9 | import java.util.LinkedList; 10 | 11 | public class rrcBase64OutputStream 12 | extends OutputStream 13 | { 14 | public rrcBase64OutputStream ( OutputStream downstream ) 15 | { 16 | fDownstream = downstream; 17 | fPendings = new LinkedList (); 18 | fWrittenToLine = 0; 19 | } 20 | 21 | @Override 22 | public void write ( int b ) 23 | throws IOException 24 | { 25 | fPendings.add ( (byte) b ); 26 | writePendings ( false ); 27 | } 28 | 29 | @Override 30 | public void close () throws IOException 31 | { 32 | writePendings ( true ); 33 | fDownstream.close (); 34 | } 35 | 36 | private int writeNow () 37 | { 38 | int result = 0; 39 | int pending = fPendings.size (); 40 | if ( pending > kBufferSize ) 41 | { 42 | result = kBufferSize; 43 | } 44 | return result; 45 | } 46 | 47 | private void writePendings ( boolean pad ) throws IOException 48 | { 49 | int thisWrite = fPendings.size (); 50 | if ( !pad ) 51 | { 52 | thisWrite = writeNow (); 53 | } 54 | 55 | if ( thisWrite > 0 ) 56 | { 57 | byte[] bb = new byte [ thisWrite ]; 58 | for ( int i=0; i>> 2; 90 | int o1 = ( ( i0 & 3 ) << 4 ) | ( i1 >>> 4 ); 91 | int o2 = ( ( i1 & 0xf ) << 2 ) | ( i2 >>> 6 ); 92 | int o3 = i2 & 0x3F; 93 | out[op++] = rrcBase64Constants.nibblesToB64[o0]; 94 | out[op++] = rrcBase64Constants.nibblesToB64[o1]; 95 | out[op] = op < oDataLen ? rrcBase64Constants.nibblesToB64[o2] : '='; 96 | op++; 97 | out[op] = op < oDataLen ? rrcBase64Constants.nibblesToB64[o3] : '='; 98 | op++; 99 | } 100 | return out; 101 | } 102 | 103 | private static final int kMaxLine = 80; 104 | private static final int kBufferSize = 3*64; // multiple of 3 for no padding 105 | 106 | private OutputStream fDownstream; 107 | private int fWrittenToLine; 108 | private final LinkedList fPendings; 109 | } 110 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/security/ReadWriteSecuredResource.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.security; 5 | 6 | import java.util.Set; 7 | 8 | import com.att.nsa.configs.ConfigDbException; 9 | 10 | /** 11 | * An interface for resources that have read and write ACLs. 12 | * @author peter 13 | * 14 | */ 15 | public interface ReadWriteSecuredResource 16 | { 17 | /** 18 | * Access denied exception 19 | */ 20 | public class AccessDeniedException extends Exception 21 | { 22 | public AccessDeniedException () { super ( "Access denied." ); } 23 | public AccessDeniedException ( String user ) { super ( "Access denied for " + user ); } 24 | private static final long serialVersionUID = 1L; 25 | } 26 | 27 | /** 28 | * a name for this resource 29 | * @return a name 30 | */ 31 | String getName (); 32 | 33 | /** 34 | * Get the set of owner API keys for this resource. Do not return null. 35 | * @return a set of API keys 36 | */ 37 | Set getOwners (); 38 | 39 | /** 40 | * Get the ACL for reading on this topic. Can be null. 41 | * @return an ACL or null 42 | */ 43 | // FIXME: we may not want to dictate the use of separate reader/writer ACLs 44 | NsaAcl getReaderAcl (); 45 | 46 | /** 47 | * Get the ACL for writing on this topic. Can be null. 48 | * @return an ACL or null 49 | */ 50 | // FIXME: we may not want to dictate the use of separate reader/writer ACLs 51 | NsaAcl getWriterAcl (); 52 | 53 | /** 54 | * Check if this user can read the topic. Throw otherwise. Note that 55 | * user may be null. 56 | * @param user 57 | */ 58 | void checkUserRead ( NsaApiKey user ) throws AccessDeniedException; 59 | 60 | /** 61 | * Check if this user can write to the topic. Throw otherwise. Note 62 | * that user may be null. 63 | * @param user 64 | */ 65 | void checkUserWrite ( NsaApiKey user ) throws AccessDeniedException; 66 | 67 | /** 68 | * allow the given user to publish 69 | * @param apiKey 70 | * @param asUser the user making this change, who must be authorized to do so 71 | */ 72 | void permitWritesFromUser ( String apiKey, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException; 73 | 74 | /** 75 | * deny the given user from publishing 76 | * @param apiKey 77 | * @param asUser the user making this change, who must be authorized to do so 78 | */ 79 | void denyWritesFromUser ( String apiKey, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException; 80 | 81 | /** 82 | * allow the given user to read the topic 83 | * @param apiKey 84 | * @param asUser the user making this change, who must be authorized to do so 85 | */ 86 | void permitReadsByUser ( String apiKey, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException; 87 | 88 | /** 89 | * deny the given user from reading the topic 90 | * @param apiKey 91 | * @param asUser the user making this change, who must be authorized to do so 92 | * @throws ConfigDbException 93 | */ 94 | void denyReadsByUser ( String apiKey, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException; 95 | } 96 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/ui/UiTomcatServer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.ui; 6 | 7 | import java.io.File; 8 | import java.io.IOException; 9 | 10 | import org.apache.catalina.Context; 11 | import org.apache.catalina.LifecycleException; 12 | import org.apache.catalina.startup.Tomcat; 13 | 14 | import com.att.nsa.drumlin.till.nv.rrNvReadable.loadException; 15 | import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting; 16 | import com.att.nsa.drumlin.till.nv.impl.nvWriteableTable; 17 | 18 | public class UiTomcatServer 19 | { 20 | public UiTomcatServer () throws IOException 21 | { 22 | this ( 8080 ); 23 | } 24 | 25 | public UiTomcatServer ( int port ) throws IOException 26 | { 27 | // create a tomcat instance. Note that the base dir must be set before anything 28 | // else is done. 29 | fTomcat = new Tomcat (); 30 | fTomcat.setBaseDir ( makeTmpDir ( "tomcatBase" ).getAbsolutePath () ); 31 | 32 | fServlet = new UiServlet ( new nvWriteableTable () ); 33 | 34 | fPort = port; 35 | } 36 | 37 | public void addPlugin ( UiPlugin p ) 38 | { 39 | fServlet.register ( p ); 40 | } 41 | 42 | public void setPort ( int port ) 43 | { 44 | fPort = port; 45 | } 46 | 47 | public void start () throws IOException 48 | { 49 | // create a servlet and context 50 | final Context rootCtx = fTomcat.addContext ( "", makeTmpDir ( "uiContext" ).getAbsolutePath () ); 51 | Tomcat.addServlet ( rootCtx, kServletName, fServlet ); 52 | rootCtx.addServletMapping ( "/*", kServletName ); 53 | 54 | // determine the port 55 | fTomcat.setPort ( fPort ); 56 | 57 | try 58 | { 59 | fTomcat.start (); 60 | fTomcat.getServer().await (); 61 | } 62 | catch ( Exception e ) 63 | { 64 | throw new RuntimeException ( e ); 65 | } 66 | } 67 | 68 | public void stop () 69 | { 70 | try 71 | { 72 | fTomcat.stop (); 73 | } 74 | catch ( LifecycleException e ) 75 | { 76 | // ignore 77 | } 78 | } 79 | 80 | private final Tomcat fTomcat; 81 | private final UiServlet fServlet; 82 | private int fPort; 83 | 84 | private static final String kServletName = "UiServlet"; 85 | 86 | public static void main ( String[] args ) throws IOException, loadException, missingReqdSetting 87 | { 88 | int port = 8080; 89 | if ( args.length > 0 ) 90 | { 91 | port = Integer.parseInt ( args[0] ); 92 | } 93 | 94 | final UiTomcatServer t = new UiTomcatServer ( port ); 95 | t.start (); 96 | } 97 | 98 | private static File makeTmpDir ( String name ) throws IOException 99 | { 100 | final File temp = File.createTempFile ("nsaui." + name + ".", Long.toString ( System.nanoTime() ) ); 101 | if ( !temp.delete () ) 102 | { 103 | throw new IOException ( "Couldn't delete tmp file " + temp.getAbsolutePath () ); 104 | } 105 | if ( !temp.mkdir () ) 106 | { 107 | throw new IOException ( "Couldn't create tmp dir " + temp.getAbsolutePath () ); 108 | } 109 | temp.deleteOnExit (); 110 | return temp; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/cmdLine/NsaCommandLineUtil.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.cmdLine; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | public class NsaCommandLineUtil 10 | { 11 | /** 12 | * Read a simplified command line format into map. 13 | * @param args 14 | * @return 15 | */ 16 | public static Map processCmdLine ( String[] args ) 17 | { 18 | return processCmdLine ( args, false ); 19 | } 20 | 21 | /** 22 | * Read a simplified command line format into map. 23 | * @param args 24 | * @param stripDashes if true, the returned map for "-foo=bar" would have "foo"="bar" 25 | * @return 26 | */ 27 | public static Map processCmdLine ( String[] args, boolean stripDashes ) 28 | { 29 | final HashMap map = new HashMap (); 30 | 31 | String lastKey = null; 32 | for ( String arg : args ) 33 | { 34 | if ( arg.startsWith ( "-" ) ) 35 | { 36 | if ( lastKey != null ) 37 | { 38 | map.put ( stripDashes ? lastKey.substring(1) : lastKey, "" ); 39 | } 40 | lastKey = arg; 41 | } 42 | else 43 | { 44 | if ( lastKey != null ) 45 | { 46 | map.put ( stripDashes ? lastKey.substring(1) : lastKey, arg ); 47 | } 48 | lastKey = null; 49 | } 50 | } 51 | if ( lastKey != null ) 52 | { 53 | map.put ( stripDashes ? lastKey.substring(1) : lastKey, "" ); 54 | } 55 | return map; 56 | } 57 | 58 | /** 59 | * get a required setting. if not provided, throw IllegalArgumentException with the 'what' description, 60 | * preceded with "You must provide " 61 | * @param argMap 62 | * @param key 63 | * @param what 64 | * @return 65 | */ 66 | public static String getReqdSetting ( Map argMap, String key, String what ) 67 | { 68 | final String val = argMap.get ( key ); 69 | if ( val == null ) 70 | { 71 | throw new IllegalArgumentException ( "You must provide " + what ); 72 | } 73 | return val; 74 | } 75 | 76 | /** 77 | * Get a setting, or, if not provided, return the default value 78 | * @param argMap 79 | * @param key 80 | * @param defaultValue 81 | * @return 82 | */ 83 | public static String getSetting ( Map argMap, String key, String defaultValue ) 84 | { 85 | final String val = argMap.get ( key ); 86 | if ( val == null ) 87 | { 88 | return defaultValue; 89 | } 90 | return val; 91 | } 92 | 93 | /** 94 | * Get a setting, or, if not provided, return the default value 95 | * @param argMap 96 | * @param key 97 | * @param defaultValue 98 | * @return 99 | */ 100 | public static int getSetting ( Map argMap, String key, int defaultValue ) 101 | { 102 | final String s = getSetting ( argMap, key, "" + defaultValue ); 103 | if ( s != null ) 104 | { 105 | try 106 | { 107 | return Integer.parseInt ( s ); 108 | } 109 | catch ( NumberFormatException x ) 110 | { 111 | return defaultValue; 112 | } 113 | } 114 | return defaultValue; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/nv/rrNvReadable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.nv; 6 | 7 | import java.util.Collection; 8 | import java.util.Map; 9 | 10 | /** 11 | * A data supplier 12 | */ 13 | public interface rrNvReadable 14 | { 15 | class loadException extends Exception 16 | { 17 | public loadException ( Throwable cause ) { super(cause); } 18 | private static final long serialVersionUID = 1L; 19 | } 20 | 21 | class missingReqdSetting extends Exception 22 | { 23 | public missingReqdSetting ( String key ) { super("Missing required setting \"" + key + "\"" ); fKey = key; } 24 | public missingReqdSetting ( String key, Throwable cause ) { super("Missing required setting \"" + key + "\" because " + cause.getMessage (), cause ); fKey=key; } 25 | private static final long serialVersionUID = 1L; 26 | public final String fKey; 27 | } 28 | 29 | class invalidSettingValue extends Exception 30 | { 31 | public invalidSettingValue ( String key ) { super("Invalid setting for \"" + key + "\"" ); fKey=key; } 32 | public invalidSettingValue ( String key, Throwable cause ) { super("Invalid setting for \"" + key + "\" because " + cause.getMessage (), cause ); fKey=key; } 33 | public invalidSettingValue ( String key, String why ) { super("Invalid setting for \"" + key + "\" because " + why ); fKey=key; } 34 | public invalidSettingValue ( String key, Throwable cause, String why ) { super("Invalid setting for \"" + key + "\" because " + why, cause ); fKey=key; } 35 | private static final long serialVersionUID = 1L; 36 | public final String fKey; 37 | } 38 | 39 | String getString ( String key ) throws missingReqdSetting; 40 | String getString ( String key, String defValue ); 41 | 42 | char getCharacter ( String key ) throws missingReqdSetting; 43 | char getCharacter ( String key, char defValue ); 44 | 45 | boolean getBoolean ( String key ) throws missingReqdSetting; 46 | boolean getBoolean ( String key, boolean defValue ); 47 | 48 | int getInt ( String key ) throws missingReqdSetting; 49 | int getInt ( String key, int defValue ); 50 | 51 | long getLong ( String key ) throws missingReqdSetting; 52 | long getLong ( String key, long defValue ); 53 | 54 | double getDouble ( String key ) throws missingReqdSetting; 55 | double getDouble ( String key, double defValue ); 56 | 57 | byte[] getBytes ( String key ) throws missingReqdSetting, invalidSettingValue; 58 | byte[] getBytes ( String key, byte[] defValue ); 59 | 60 | /** 61 | * Get a set of strings given a key. Most implementations expect to use "getString()" and then 62 | * split the value by commas. 63 | * 64 | * @param key 65 | * @return a string array 66 | * @throws missingReqdSetting 67 | */ 68 | String[] getStrings ( String key ) throws missingReqdSetting; 69 | String[] getStrings ( String key, String[] defValue ); 70 | 71 | int size (); 72 | boolean hasValueFor ( String key ); 73 | Collection getAllKeys (); 74 | Map getCopyAsMap (); 75 | 76 | void copyInto ( rrNvWriteable writeable ); 77 | void copyInto ( Map writeable ); 78 | 79 | void rescan () throws loadException; 80 | } 81 | -------------------------------------------------------------------------------- /saserverlibrary/src/test/java/com/att/nsa/apiServer/ApiServerTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | package com.att.nsa.apiServer; 5 | 6 | import java.io.File; 7 | import java.io.FileOutputStream; 8 | import java.io.IOException; 9 | import java.io.InputStream; 10 | import java.util.Enumeration; 11 | 12 | import javax.servlet.Servlet; 13 | import javax.servlet.ServletConfig; 14 | import javax.servlet.ServletContext; 15 | import javax.servlet.ServletException; 16 | import javax.servlet.ServletRequest; 17 | import javax.servlet.ServletResponse; 18 | 19 | import junit.framework.TestCase; 20 | 21 | import org.apache.catalina.LifecycleException; 22 | import org.junit.Test; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | import com.att.nsa.util.StreamTools; 27 | 28 | public class ApiServerTest extends TestCase 29 | { 30 | @Test 31 | public void testHtpsOnly () throws IOException, LifecycleException 32 | { 33 | final File tmpFile = File.createTempFile ( "keyfile", "" ); 34 | try 35 | ( 36 | final InputStream is = ApiServerTest.class.getClassLoader().getResourceAsStream ( "keystore.dummy" ); 37 | final FileOutputStream os = new FileOutputStream ( tmpFile ); 38 | ) 39 | { 40 | StreamTools.copyStream ( is, os ); 41 | } 42 | 43 | final ApiServerConnector conn = new ApiServerConnector.Builder ( 7443 ) 44 | .secure ( true ) 45 | .keystoreFile ( tmpFile.getAbsolutePath () ) 46 | .keystorePassword ( "foobar" ) 47 | .keyAlias ( "tomcat" ) 48 | .build () 49 | ; 50 | 51 | final ApiServer server = new ApiServer.Builder ( new MyServlet () ) 52 | .withConnector ( conn ) 53 | .build () 54 | ; 55 | 56 | server.start (); 57 | 58 | server.stop (); 59 | tmpFile.delete (); 60 | } 61 | 62 | private class MyServlet implements Servlet 63 | { 64 | @Override 65 | public void init ( ServletConfig config ) throws ServletException {} 66 | 67 | @Override 68 | public ServletConfig getServletConfig () 69 | { 70 | return new ServletConfig () 71 | { 72 | @Override 73 | public String getServletName () 74 | { 75 | return "test"; 76 | } 77 | 78 | @Override 79 | public ServletContext getServletContext () 80 | { 81 | return null; 82 | } 83 | 84 | @Override 85 | public String getInitParameter ( String name ) 86 | { 87 | return null; 88 | } 89 | 90 | @Override 91 | public Enumeration getInitParameterNames () 92 | { 93 | return new Enumeration () 94 | { 95 | @Override 96 | public boolean hasMoreElements () { return false; } 97 | 98 | @Override 99 | public String nextElement () { return null; } 100 | }; 101 | } 102 | 103 | }; 104 | } 105 | 106 | @Override 107 | public void service ( ServletRequest req, ServletResponse res ) throws ServletException, IOException 108 | { 109 | log.info ( "service ... " ); 110 | } 111 | 112 | @Override 113 | public String getServletInfo () { return null; } 114 | 115 | @Override 116 | public void destroy () {} 117 | } 118 | 119 | private static final Logger log = LoggerFactory.getLogger ( ApiServerTest.class ); 120 | } 121 | -------------------------------------------------------------------------------- /saserverlibrary/src/main/java/com/att/nsa/drumlin/till/data/oneWayHasher.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved. 3 | *******************************************************************************/ 4 | 5 | package com.att.nsa.drumlin.till.data; 6 | 7 | import java.security.MessageDigest; 8 | import java.security.NoSuchAlgorithmException; 9 | import java.security.spec.InvalidKeySpecException; 10 | import java.security.spec.KeySpec; 11 | 12 | import javax.crypto.SecretKeyFactory; 13 | import javax.crypto.spec.PBEKeySpec; 14 | 15 | public class oneWayHasher 16 | { 17 | public static String digest ( String input ) 18 | { 19 | return hash ( input, "" ); 20 | } 21 | 22 | /** 23 | * return a 20 byte (160 bit) hash of the input string, using a salt, if provided. 24 | * @param input 25 | * @param moreSalt 26 | * @return 20 bytes 27 | */ 28 | @Deprecated 29 | public static byte[] hashToBytes ( String input, String moreSalt ) 30 | { 31 | try 32 | { 33 | final StringBuffer fullMsg = new StringBuffer (); 34 | fullMsg.append ( kPart1 ); 35 | fullMsg.append ( input ); 36 | fullMsg.append ( kPart2 ); 37 | if ( moreSalt != null ) 38 | { 39 | fullMsg.append ( moreSalt ); 40 | } 41 | 42 | final MessageDigest md = MessageDigest.getInstance ( "SHA-1" ); 43 | md.reset (); 44 | md.update ( fullMsg.toString().getBytes () ); 45 | return md.digest (); // 160 bits 46 | } 47 | catch ( NoSuchAlgorithmException e ) 48 | { 49 | throw new RuntimeException ( "MessageDigest can't find SHA-1 implementation." ); 50 | } 51 | } 52 | 53 | public static String pbkdf2HashToString ( String input, String salt ) 54 | { 55 | final byte[] bytes = pbkdf2Hash ( input, salt ); 56 | return rrConvertor.bytesToHexString ( bytes ); 57 | } 58 | 59 | public static byte[] pbkdf2Hash ( String input, String salt ) 60 | { 61 | try 62 | { 63 | final String algorithm = "PBKDF2WithHmacSHA1"; 64 | final int derivedKeyLength = 160; 65 | final int iterations = 20000; 66 | 67 | final KeySpec spec = new PBEKeySpec(input.toCharArray(), salt.getBytes (), iterations, derivedKeyLength); 68 | final SecretKeyFactory f = SecretKeyFactory.getInstance(algorithm); 69 | return f.generateSecret(spec).getEncoded(); 70 | } 71 | catch ( NoSuchAlgorithmException e ) 72 | { 73 | throw new RuntimeException ( e ); 74 | } 75 | catch ( InvalidKeySpecException e ) 76 | { 77 | throw new RuntimeException ( e ); 78 | } 79 | } 80 | 81 | @Deprecated 82 | public static String hash ( String input, String moreSalt ) 83 | { 84 | final byte[] outBytes = hashToBytes ( input, moreSalt ); 85 | return rrConvertor.bytesToHexString ( outBytes ); 86 | } 87 | 88 | static public void main ( String args[] ) 89 | { 90 | if ( args.length != 1 && args.length != 2 ) 91 | { 92 | System.err.println ( "usage: oneWayHasher []" ); 93 | } 94 | else if ( args.length == 1 ) 95 | { 96 | System.out.println ( hash ( args[0], "" ) ); 97 | } 98 | else if ( args.length == 2 ) 99 | { 100 | System.out.println ( hash ( args[0], args[1] ) ); 101 | } 102 | } 103 | 104 | static private final String kPart1 = "In the fields of Rathravane, yell '"; 105 | static private final String kPart2 = "!!!', and you'll find a rock thrown by a giant. "; 106 | } 107 | --------------------------------------------------------------------------------