├── .gitignore ├── LICENSE.txt ├── README.markdown ├── createGitIgnore ├── doc ├── README.txt └── setup │ ├── README.txt │ └── sql │ ├── 001_setup_db.sql │ ├── 002_create_schema_oracle.sql │ ├── 002_create_schema_postgres.sql │ ├── 003_update_schema_oracle.sql │ └── 003_update_schema_postgres.sql └── src ├── pom.xml ├── samples └── csv2geofence │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── geoserver │ │ │ └── csv2geofence │ │ │ ├── Cvs2Xml.java │ │ │ ├── Runner.java │ │ │ ├── config │ │ │ └── model │ │ │ │ ├── Configuration.java │ │ │ │ ├── GeofenceConfig.java │ │ │ │ ├── RuleFileConfig.java │ │ │ │ ├── UserFileConfig.java │ │ │ │ └── internal │ │ │ │ ├── OperationType.java │ │ │ │ ├── RuleOp.java │ │ │ │ ├── RunInfo.java │ │ │ │ └── UserOp.java │ │ │ └── impl │ │ │ ├── RuleFileLoader.java │ │ │ ├── RulesProcessor.java │ │ │ ├── UserFileLoader.java │ │ │ └── UsersProcessor.java │ └── resources │ │ └── log4j.properties │ └── test │ ├── java │ └── org │ │ └── geoserver │ │ └── csv2geofence │ │ ├── BaseTest.java │ │ ├── ConfigTest.java │ │ └── UserLoaderTest.java │ └── resources │ ├── config00.xml │ ├── ldif.csv │ ├── ldifexample.txt │ ├── log4j.properties │ └── rules.csv └── services ├── core ├── model-external │ └── pom.xml ├── model │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ └── core │ │ │ └── model │ │ │ ├── AdminRule.java │ │ │ ├── GFUser.java │ │ │ ├── GSInstance.java │ │ │ ├── GSUser.java │ │ │ ├── IPAddressRange.java │ │ │ ├── IPRangeProvider.java │ │ │ ├── Identifiable.java │ │ │ ├── LayerAttribute.java │ │ │ ├── LayerDetails.java │ │ │ ├── Prioritizable.java │ │ │ ├── Rule.java │ │ │ ├── RuleLimits.java │ │ │ ├── UserGroup.java │ │ │ ├── adapter │ │ │ ├── FK2UserAdapter.java │ │ │ ├── FK2UserGroupAdapter.java │ │ │ ├── FK2UserGroupSetAdapter.java │ │ │ ├── FK2UserGroupSetAdapter2.java │ │ │ ├── FKGSInstanceAdapter.java │ │ │ ├── FKUserAdapter.java │ │ │ ├── FKUserGroupAdapter.java │ │ │ ├── GeometryAdapter.java │ │ │ ├── IdentifiableAdapter.java │ │ │ ├── MapAdapter.java │ │ │ ├── MultiPolygonAdapter.java │ │ │ ├── PolygonAdapter.java │ │ │ ├── XMultiPolygonAdapter.java │ │ │ ├── dual │ │ │ │ ├── IdNameBundle.java │ │ │ │ ├── MapEntryType.java │ │ │ │ └── MapType.java │ │ │ └── package-info.java │ │ │ ├── enums │ │ │ ├── AccessType.java │ │ │ ├── AdminGrantType.java │ │ │ ├── CatalogMode.java │ │ │ ├── GrantType.java │ │ │ ├── InsertPosition.java │ │ │ ├── KnownServices.java │ │ │ ├── LayerType.java │ │ │ ├── SpatialFilterType.java │ │ │ ├── ValueType.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ └── util │ │ │ ├── EWKTParser.java │ │ │ ├── PwEncoder.java │ │ │ ├── SubnetV4Utils.java │ │ │ └── package-info.java │ │ └── test │ │ └── java │ │ └── org │ │ └── geoserver │ │ └── geofence │ │ └── core │ │ └── model │ │ ├── Base64EncodersTest.java │ │ ├── GSUserTest.java │ │ ├── IPAddressRangeTest.java │ │ └── util │ │ └── PwEncoderTest.java ├── persistence-pg-test │ ├── pom.xml │ └── src │ │ └── test │ │ └── resources │ │ ├── geofence-datasource-ovr.properties │ │ └── log4j.properties ├── persistence │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── geoserver │ │ │ │ └── geofence │ │ │ │ ├── SchemaExporter.java │ │ │ │ └── core │ │ │ │ └── dao │ │ │ │ ├── AdminRuleDAO.java │ │ │ │ ├── AllowedStylesProvider.java │ │ │ │ ├── DuplicateKeyException.java │ │ │ │ ├── GFUserDAO.java │ │ │ │ ├── GSInstanceDAO.java │ │ │ │ ├── GSUserDAO.java │ │ │ │ ├── LayerDetailsDAO.java │ │ │ │ ├── PrioritizableDAO.java │ │ │ │ ├── RegistrableDAO.java │ │ │ │ ├── RestrictedGenericDAO.java │ │ │ │ ├── RuleDAO.java │ │ │ │ ├── RuleLimitsDAO.java │ │ │ │ ├── SearchableDAO.java │ │ │ │ ├── UserGroupDAO.java │ │ │ │ ├── impl │ │ │ │ ├── AdminRuleDAOImpl.java │ │ │ │ ├── BaseDAO.java │ │ │ │ ├── GFUserDAOImpl.java │ │ │ │ ├── GSInstanceDAOImpl.java │ │ │ │ ├── GSUserDAOImpl.java │ │ │ │ ├── LayerDetailsDAOImpl.java │ │ │ │ ├── PrioritizableDAOImpl.java │ │ │ │ ├── RuleDAOImpl.java │ │ │ │ ├── RuleLimitsDAOImpl.java │ │ │ │ └── UserGroupDAOImpl.java │ │ │ │ ├── search │ │ │ │ ├── BaseSearch.java │ │ │ │ ├── LongSearch.java │ │ │ │ ├── Search.java │ │ │ │ └── SearchUtil.java │ │ │ │ └── util │ │ │ │ ├── GeofenceDaoRegistry.java │ │ │ │ └── PwEncoder.java │ │ └── resources │ │ │ ├── applicationContext-geofenceDatasource.xml │ │ │ ├── applicationContext.xml │ │ │ ├── geofence-ehcache.xml │ │ │ └── geofence-externalize-aux.properties │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ └── core │ │ │ └── dao │ │ │ ├── BaseDAOTest.java │ │ │ ├── GFUserDAOTest.java │ │ │ ├── RuleDAOTest.java │ │ │ ├── UserDAOTest.java │ │ │ ├── UserGroupDAOTest.java │ │ │ └── util │ │ │ ├── DaoRegistryTest.java │ │ │ └── PwEncoderTest.java │ │ └── resources │ │ ├── geofence-datasource-ovr.properties │ │ └── log4j2.xml ├── pom.xml ├── services-api │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ ├── services │ │ │ ├── AdminRuleAdminService.java │ │ │ ├── AuthorizationService.java │ │ │ ├── ConfigAdminService.java │ │ │ ├── GFUserAdminService.java │ │ │ ├── GetProviderService.java │ │ │ ├── InstanceAdminService.java │ │ │ ├── RuleAdminService.java │ │ │ ├── RuleReaderService.java │ │ │ ├── UserAdminService.java │ │ │ ├── UserGroupAdminService.java │ │ │ ├── dto │ │ │ │ ├── AccessInfo.java │ │ │ │ ├── AuthUser.java │ │ │ │ ├── CatalogModeDTO.java │ │ │ │ ├── RuleFilter.java │ │ │ │ ├── ShortAdminRule.java │ │ │ │ ├── ShortGroup.java │ │ │ │ ├── ShortInstance.java │ │ │ │ ├── ShortRule.java │ │ │ │ └── ShortUser.java │ │ │ ├── exception │ │ │ │ ├── BadRequestServiceEx.java │ │ │ │ ├── InternalErrorServiceEx.java │ │ │ │ ├── NotFoundServiceEx.java │ │ │ │ └── WebApplicationException.java │ │ │ └── util │ │ │ │ └── IPUtils.java │ │ │ └── spi │ │ │ └── UserResolver.java │ │ └── test │ │ └── java │ │ └── org │ │ └── geoserver │ │ └── geofence │ │ └── services │ │ └── util │ │ ├── IPUtilsTest.java │ │ └── RuleFilterTest.java ├── services-impl │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── geoserver │ │ │ │ └── geofence │ │ │ │ ├── services │ │ │ │ ├── AdminRuleAdminServiceImpl.java │ │ │ │ ├── AuthorizationServiceImpl.java │ │ │ │ ├── DefaultUserResolver.java │ │ │ │ ├── GFUserAdminServiceImpl.java │ │ │ │ ├── InstanceAdminServiceImpl.java │ │ │ │ ├── RuleAdminServiceImpl.java │ │ │ │ ├── RuleReaderServiceImpl.java │ │ │ │ ├── UserAdminServiceImpl.java │ │ │ │ ├── UserGroupAdminServiceImpl.java │ │ │ │ └── util │ │ │ │ │ ├── AccessInfoInternal.java │ │ │ │ │ └── FilterUtils.java │ │ │ │ └── util │ │ │ │ └── CategorizedCircularBuffer.java │ │ └── resources │ │ │ └── applicationContext.xml │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── geoserver │ │ │ ├── geofence │ │ │ ├── services │ │ │ │ ├── AdminRuleAdminServiceImplTest.java │ │ │ │ ├── GFUserAdminServiceImplTest.java │ │ │ │ ├── RuleAdminServiceImplTest.java │ │ │ │ ├── RuleReaderCatalogModeTest.java │ │ │ │ ├── RuleReaderServiceImplTest.java │ │ │ │ ├── RuleReaderServiceImpl_GeomTest.java │ │ │ │ ├── ServiceTestBase.java │ │ │ │ ├── UserAdminServiceImplTest.java │ │ │ │ └── UserGroupAdminServiceImplTest.java │ │ │ └── util │ │ │ │ └── CategorizedCircularBufferTest.java │ │ │ └── test │ │ │ └── AbstractSpringContextTest.java │ │ └── resources │ │ ├── geofence-datasource-ovr.properties │ │ └── log4j2.xml └── webtest │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── org │ │ └── geoserver │ │ └── geofence │ │ └── servicetest │ │ └── MainTest.java │ ├── resources │ ├── META-INF │ │ └── cxf │ │ │ └── org.apache.cxf.Logger │ ├── applicationContext.xml │ ├── geofence-datasource-ovr.properties │ ├── geofence-datasource.properties │ └── log4j2.xml │ └── webapp │ └── WEB-INF │ ├── remoting-servlet.xml │ └── web.xml ├── modules ├── generic-api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── org │ │ └── geoserver │ │ └── geofence │ │ └── api │ │ ├── AuthProvider.java │ │ ├── UserRegistry.java │ │ ├── dto │ │ ├── Authority.java │ │ ├── GrantedAuths.java │ │ └── RegisteredUser.java │ │ └── exception │ │ └── AuthException.java ├── ldap │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── geoserver │ │ │ │ └── geofence │ │ │ │ └── ldap │ │ │ │ ├── LdapAttributesMapper.java │ │ │ │ ├── dao │ │ │ │ └── impl │ │ │ │ │ ├── BaseAttributesMapper.java │ │ │ │ │ ├── GSUserAttributesMapper.java │ │ │ │ │ ├── GSUserDAOLdapImpl.java │ │ │ │ │ ├── LDAPBaseDAO.java │ │ │ │ │ ├── UserGroupAttributesMapper.java │ │ │ │ │ └── UserGroupDAOLdapImpl.java │ │ │ │ └── utils │ │ │ │ └── LdapUtils.java │ │ └── resources │ │ │ ├── applicationContext-geofence-ldap-datasource.xml │ │ │ └── applicationContext.xml │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ └── ldap │ │ │ └── dao │ │ │ └── impl │ │ │ ├── BaseDAOTest.java │ │ │ ├── GSUserDAOLdapImplTest.java │ │ │ └── UserGroupDAOLdapImplTest.java │ │ └── resources │ │ ├── data.ldif │ │ ├── geofence-datasource-ovr.properties │ │ └── log4j2.xml ├── login │ ├── api │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ └── login │ │ │ └── LoginService.java │ ├── impl │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── org │ │ │ │ │ └── geoserver │ │ │ │ │ └── geofence │ │ │ │ │ └── login │ │ │ │ │ ├── LoginServiceImpl.java │ │ │ │ │ ├── cxf │ │ │ │ │ └── BasicAuthInterceptor.java │ │ │ │ │ └── util │ │ │ │ │ ├── GrantAll.java │ │ │ │ │ ├── MD5Util.java │ │ │ │ │ ├── SessionManager.java │ │ │ │ │ └── TokenEncoder.java │ │ │ └── resources │ │ │ │ └── applicationContext.xml │ │ │ └── test │ │ │ ├── java │ │ │ └── org │ │ │ │ └── geoserver │ │ │ │ └── geofence │ │ │ │ └── login │ │ │ │ └── util │ │ │ │ └── MD5UtilTest.java │ │ │ └── resources │ │ │ └── applicationContext-test.xml │ └── pom.xml ├── pom.xml └── rest │ ├── api │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ └── services │ │ │ └── rest │ │ │ ├── RESTAdminRuleService.java │ │ │ ├── RESTBatchService.java │ │ │ ├── RESTConfigService.java │ │ │ ├── RESTGSInstanceService.java │ │ │ ├── RESTRuleService.java │ │ │ ├── RESTUserGroupService.java │ │ │ ├── RESTUserService.java │ │ │ ├── exception │ │ │ ├── BadRequestRestEx.java │ │ │ ├── ConflictRestEx.java │ │ │ ├── GeoFenceRestEx.java │ │ │ ├── InternalErrorRestEx.java │ │ │ └── NotFoundRestEx.java │ │ │ └── model │ │ │ ├── AbstractRESTPayload.java │ │ │ ├── RESTBatch.java │ │ │ ├── RESTBatchOperation.java │ │ │ ├── RESTInputAdminRule.java │ │ │ ├── RESTInputGroup.java │ │ │ ├── RESTInputInstance.java │ │ │ ├── RESTInputRule.java │ │ │ ├── RESTInputUser.java │ │ │ ├── RESTLayerConstraints.java │ │ │ ├── RESTOutputAdminRule.java │ │ │ ├── RESTOutputAdminRuleList.java │ │ │ ├── RESTOutputGroup.java │ │ │ ├── RESTOutputInstance.java │ │ │ ├── RESTOutputRule.java │ │ │ ├── RESTOutputRuleList.java │ │ │ ├── RESTOutputUser.java │ │ │ ├── RESTRulePosition.java │ │ │ ├── RESTShortInstanceList.java │ │ │ ├── RESTShortUser.java │ │ │ ├── RESTShortUserGroup.java │ │ │ ├── RESTShortUserGroupList.java │ │ │ ├── RESTShortUserList.java │ │ │ ├── config │ │ │ ├── RESTConfigurationRemapping.java │ │ │ ├── RESTFullConfiguration.java │ │ │ ├── RESTFullGRUserList.java │ │ │ ├── RESTFullGSInstanceList.java │ │ │ ├── RESTFullRuleList.java │ │ │ ├── RESTFullUserGroupList.java │ │ │ ├── RESTFullUserList.java │ │ │ └── adapter │ │ │ │ ├── MapType.java │ │ │ │ ├── RemappedType.java │ │ │ │ └── RemapperAdapter.java │ │ │ └── util │ │ │ ├── IdName.java │ │ │ ├── Identifier.java_ │ │ │ └── RESTBatchOperationFactory.java │ │ └── test │ │ └── java │ │ └── org │ │ └── geoserver │ │ └── geofence │ │ └── services │ │ └── rest │ │ └── model │ │ └── ModelPrintoutFakeTest.java │ ├── client │ ├── pom.xml │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ └── services │ │ │ └── rest │ │ │ ├── AdminRuleServiceHelper.java │ │ │ ├── GeoFenceClient.java │ │ │ └── RuleServiceHelper.java │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ └── services │ │ │ └── rest │ │ │ └── GeoFenceClientTest.java │ │ └── resources │ │ └── log4j2.xml │ ├── impl │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── geoserver │ │ │ │ └── geofence │ │ │ │ └── services │ │ │ │ └── rest │ │ │ │ ├── auth │ │ │ │ ├── AuthUser.java │ │ │ │ ├── AuthenticationHandler.java │ │ │ │ ├── AuthorizationHandler.java │ │ │ │ ├── GeofenceAuthenticationInterceptor.java │ │ │ │ ├── GeofencePrincipal.java │ │ │ │ └── GeofenceSecurityContext.java │ │ │ │ ├── impl │ │ │ │ ├── BaseRESTServiceImpl.java │ │ │ │ ├── RESTAdminRuleServiceImpl.java │ │ │ │ ├── RESTBatchServiceImpl.java │ │ │ │ ├── RESTConfigServiceImpl.java │ │ │ │ ├── RESTInstanceServiceImpl.java │ │ │ │ ├── RESTRuleServiceImpl.java │ │ │ │ ├── RESTUserGroupServiceImpl.java │ │ │ │ └── RESTUserServiceImpl.java │ │ │ │ └── utils │ │ │ │ └── InstanceCleaner.java │ │ └── resources │ │ │ └── applicationContext.xml │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ └── services │ │ │ └── rest │ │ │ ├── impl │ │ │ ├── RESTBaseTest.java │ │ │ ├── RESTRuleServiceImplTest.java │ │ │ ├── RESTUserGroupServiceImplTest.java │ │ │ └── RESTUserServiceImplTest.java │ │ │ └── model │ │ │ └── ModelPrintoutFakeTest.java │ │ └── resources │ │ ├── applicationContext.xml │ │ ├── geofence-datasource-ovr.properties │ │ ├── log4j2.xml │ │ └── xsl │ │ └── rules.xsl │ ├── pom.xml │ └── test │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── geoserver │ │ │ └── geofence │ │ │ └── services │ │ │ └── servicetest │ │ │ └── MainTest.java │ ├── resources │ │ ├── META-INF │ │ │ └── cxf │ │ │ │ └── org.apache.cxf.Logger │ │ ├── applicationContext.xml │ │ ├── geofence-datasource-ovr-pg.properties │ │ ├── geofence-datasource-ovr.properties │ │ └── log4j2.xml │ └── webapp │ │ └── WEB-INF │ │ └── web.xml │ └── test │ └── resources │ ├── batch01.xml │ ├── batch02.xml │ ├── batch_empty_payload.xml │ ├── group01.xml │ ├── instance01.xml │ ├── log4j2.xml │ ├── rule01.xml │ ├── user0101.xml │ └── user0_update.xml ├── pom.xml └── webapp ├── pom.xml └── src └── main ├── java └── org │ └── geoserver │ └── geofence │ └── web │ ├── AuthenticationFilter.java │ └── StartupService.java ├── resources ├── applicationContext.xml ├── geofence-datasource-ovr.properties ├── geofence-datasource-ovr.properties.sample ├── geofence-datasource.properties └── log4j2.xml └── webapp └── WEB-INF ├── dispatcher-servlet.xml ├── remoting-servlet.xml └── web.xml /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings 4 | target 5 | *iml 6 | *idea 7 | 8 | src/gui/core/plugin/mapsui/war/ 9 | src/gui/core/plugin/userui/war/ 10 | 11 | src/gui/web/war/WEB-INF/classes/ 12 | src/gui/web/war/WEB-INF/deploy/ 13 | src/gui/web/war/WEB-INF/spatial-lib/ 14 | src/gui/web/war/geofence/ 15 | 16 | **/gwt-unitCache/ 17 | **/geofence_db/ 18 | **/nbproject/ 19 | **/nb-configuration.xml 20 | -------------------------------------------------------------------------------- /createGitIgnore: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | OUTFILE=gitignore 4 | 5 | cat >$OUTFILE <>$OUTFILE 38 | done 39 | 40 | echo New file $OUTFILE has been created. You may now want to replace your original .gitignore file. 41 | echo mv $OUTFILE .gitignore 42 | echo 43 | -------------------------------------------------------------------------------- /doc/README.txt: -------------------------------------------------------------------------------- 1 | ============================= 2 | + DB Preparation 3 | ============================= 4 | 5 | Setup the DB schema by creating a PostGIS DB and creating the base schema using the SQL script. 6 | Refer to file setup/README.txt 7 | 8 | ============================= 9 | + DataSource Configuration 10 | ============================= 11 | 12 | Update configuration files accordingly to your DB connection parameters on 13 | 14 | gui/web/src/main/resources 15 | 16 | 17 | ============================= 18 | + GeoServer Instance Configuration 19 | ============================= 20 | 21 | Update GeoServer properties accordingly to your configuration by updating the file 22 | 23 | geoserverXXX/web-app/src/main/resources/geofence-geoserver.properties 24 | 25 | 26 | ============================= 27 | + Building WARs 28 | ============================= 29 | 30 | From root directory launch the command 31 | 32 | mvn clean install 33 | 34 | This will create 3 WARs: 35 | 36 | geoserver21x/web-app/target/geoserver.war 37 | geoserver22x/web-app/target/geoserver.war 38 | gui/web/target/geofence.war 39 | 40 | -------------------------------------------------------------------------------- /doc/setup/README.txt: -------------------------------------------------------------------------------- 1 | ================================================================================== 2 | ======= Installation Overview on PostGIS 3 | ================================================================================== 4 | 5 | Create DB as user postgres 6 | 7 | createdb geofence 8 | createlang plpgsql geofence 9 | psql -d geofence -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql 10 | psql -d geofence-f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql 11 | psql -d geofence -f /usr/share/postgresql/9.1/contrib/postgis_comments.sql 12 | 13 | Create users and schemas for test and production. 14 | - Run as user postgres the script 001_setup_db.sql 15 | psql -d geofence -f 001_setup_db.sql 16 | 17 | Create DB schema. 18 | - Run 002_create_schema_postgres.sql as the desired user: 19 | psql -U geofence -f 002_create_schema_postgres.sql 20 | psql -U geofence_test -f 002_create_schema_postgres.sql 21 | 22 | -------------------------------------------------------------------------------- /doc/setup/sql/001_setup_db.sql: -------------------------------------------------------------------------------- 1 | -- Run this script inside a connection to the existing "geofence" database. 2 | -- If geofence does not exist, this command will terminate the sql script evaluation 3 | 4 | \c geofence 5 | 6 | -- CREATE SCHEMA geofence 7 | CREATE user geofence LOGIN PASSWORD 'geofence' NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE; 8 | 9 | CREATE SCHEMA geofence; 10 | 11 | GRANT USAGE ON SCHEMA geofence TO geofence; 12 | GRANT ALL ON SCHEMA geofence TO geofence; 13 | 14 | GRANT SELECT ON public.spatial_ref_sys to geofence; 15 | GRANT SELECT,INSERT,DELETE ON public.geometry_columns to geofence; 16 | 17 | alter user geofence set search_path to geofence, public; 18 | 19 | -- CREATE SCHEMA geofence_test 20 | CREATE user geofence_test LOGIN PASSWORD 'geofence_test' NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE; 21 | 22 | CREATE SCHEMA geofence_test; 23 | 24 | GRANT USAGE ON SCHEMA geofence_test TO geofence_test; 25 | GRANT ALL ON SCHEMA geofence_test TO geofence_test; 26 | 27 | GRANT SELECT ON public.spatial_ref_sys to geofence_test; 28 | GRANT SELECT,INSERT,DELETE ON public.geometry_columns to geofence_test; 29 | 30 | alter user geofence_test set search_path to geofence_test, public; -------------------------------------------------------------------------------- /doc/setup/sql/003_update_schema_oracle.sql: -------------------------------------------------------------------------------- 1 | alter table gr_layer_details add ( 2 | spatial_filter_type varchar2(16 char) default 'INTERSECT' 3 | ); 4 | 5 | alter table gr_rule_limits add ( 6 | spatial_filter_type varchar2(16 char) default 'INTERSECT' 7 | ); 8 | -------------------------------------------------------------------------------- /doc/setup/sql/003_update_schema_postgres.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE gf_layer_details ADD COLUMN spatial_filter_type character varying(16) DEFAULT 'INTERSECT'; 2 | 3 | ALTER TABLE gf_rule_limits ADD COLUMN spatial_filter_type character varying(16) DEFAULT 'INTERSECT'; -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/main/java/org/geoserver/csv2geofence/config/model/Configuration.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.csv2geofence.config.model; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public class Configuration { 13 | 14 | private UserFileConfig userFileConfig; 15 | 16 | private GeofenceConfig geofenceConfig; 17 | 18 | private RuleFileConfig ruleFileConfig; 19 | 20 | public UserFileConfig getUserFileConfig() { 21 | return userFileConfig; 22 | } 23 | 24 | public void setUserFileConfig(UserFileConfig userFileConfig) { 25 | this.userFileConfig = userFileConfig; 26 | } 27 | 28 | public GeofenceConfig getGeofenceConfig() { 29 | return geofenceConfig; 30 | } 31 | 32 | public void setGeofenceConfig(GeofenceConfig geofenceConfig) { 33 | this.geofenceConfig = geofenceConfig; 34 | } 35 | 36 | public RuleFileConfig getRuleFileConfig() { 37 | return ruleFileConfig; 38 | } 39 | 40 | public void setRuleFileConfig(RuleFileConfig ruleFileConfig) { 41 | this.ruleFileConfig = ruleFileConfig; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/main/java/org/geoserver/csv2geofence/config/model/GeofenceConfig.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.csv2geofence.config.model; 7 | 8 | import javax.xml.bind.annotation.XmlType; 9 | 10 | /** 11 | * 12 | * @author ETj (etj at geo-solutions.it) 13 | */ 14 | @XmlType(propOrder={"restUrl","username","password"}) 15 | public class GeofenceConfig { 16 | private String restUrl; 17 | private String username; 18 | private String password; 19 | 20 | public String getRestUrl() { 21 | return restUrl; 22 | } 23 | 24 | public void setRestUrl(String restUrl) { 25 | this.restUrl = restUrl; 26 | } 27 | 28 | public String getUsername() { 29 | return username; 30 | } 31 | 32 | public void setUsername(String username) { 33 | this.username = username; 34 | } 35 | 36 | public String getPassword() { 37 | return password; 38 | } 39 | 40 | public void setPassword(String password) { 41 | this.password = password; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/main/java/org/geoserver/csv2geofence/config/model/internal/OperationType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.csv2geofence.config.model.internal; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public enum OperationType { 13 | INSERT,UPDATE,DELETE; 14 | } -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/main/java/org/geoserver/csv2geofence/config/model/internal/RuleOp.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.csv2geofence.config.model.internal; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public class RuleOp { 13 | 14 | String groupName; 15 | String layerName; 16 | String verb; 17 | 18 | public String getLayerName() { 19 | return layerName; 20 | } 21 | 22 | public void setLayerName(String layerName) { 23 | this.layerName = layerName; 24 | } 25 | 26 | /** 27 | * Case sensitive group name 28 | */ 29 | public String getGroupName() { 30 | return groupName; 31 | } 32 | 33 | public void setGroupName(String groupName) { 34 | this.groupName = groupName; 35 | } 36 | 37 | public String getVerb() { 38 | return verb; 39 | } 40 | 41 | public void setVerb(String verb) { 42 | this.verb = verb; 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return getClass().getSimpleName()+"[" 48 | +"group:" + groupName 49 | + " layer:" + layerName 50 | + " verb:" + verb+"]"; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/main/java/org/geoserver/csv2geofence/config/model/internal/UserOp.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.csv2geofence.config.model.internal; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Represent a line in the user CSV file 12 | * 13 | * @author ETj (etj at geo-solutions.it) 14 | */ 15 | public class UserOp { 16 | private OperationType type; 17 | String userName; 18 | String mailAddress; 19 | String fullName; 20 | 21 | List groups; 22 | 23 | public OperationType getType() { 24 | return type; 25 | } 26 | 27 | public void setType(OperationType type) { 28 | this.type = type; 29 | } 30 | 31 | public String getUserName() { 32 | return userName; 33 | } 34 | 35 | public void setUserName(String userName) { 36 | this.userName = userName; 37 | } 38 | 39 | public List getGroups() { 40 | return groups; 41 | } 42 | 43 | public void setGroups(List groups) { 44 | this.groups = groups; 45 | } 46 | 47 | public String getMailAddress() { 48 | return mailAddress; 49 | } 50 | 51 | public void setMailAddress(String mailAddress) { 52 | this.mailAddress = mailAddress; 53 | } 54 | 55 | public String getFullName() { 56 | return fullName; 57 | } 58 | 59 | public void setFullName(String fullName) { 60 | this.fullName = fullName; 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return getClass().getSimpleName()+"[" 66 | + type 67 | +" user " + userName 68 | + (fullName != null? " ("+fullName+") ":"") 69 | + (mailAddress != null? "<"+mailAddress+">":"") 70 | + " in groups " + groups+"]"; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | log4j.rootLogger=INFO, consoleAppender 7 | 8 | log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender 9 | log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout 10 | #log4j.appender.consoleAppender.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS} %c::%M - %m%n 11 | #log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss.SSS} %C{1}.%M(%L) - %m %n 12 | #log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss.SSS} %I - %m %n 13 | #log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss.SSS} %15c{1}::%-20M %3L %x - %m%n 14 | log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss.SSS} %-15c{1}::%-25M %3L %x - %m%n 15 | #log4j.appender.consoleAppender.layout.ConversionPattern=%m%n 16 | 17 | log4j.logger.org.geoserver.geofence.services.rest=DEBUG 18 | log4j.logger.org.springframework=WARN 19 | log4j.logger.org.apache.cxf=WARN -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/test/java/org/geoserver/csv2geofence/UserLoaderTest.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.csv2geofence; 7 | 8 | import org.geoserver.csv2geofence.impl.UserFileLoader; 9 | import org.geoserver.csv2geofence.config.model.Configuration; 10 | import java.io.File; 11 | import javax.xml.bind.JAXB; 12 | import org.junit.After; 13 | import org.junit.AfterClass; 14 | import org.junit.Before; 15 | import org.junit.BeforeClass; 16 | import org.junit.Test; 17 | import static org.junit.Assert.*; 18 | 19 | /** 20 | * 21 | * @author ETj (etj at geo-solutions.it) 22 | */ 23 | public class UserLoaderTest extends BaseTest { 24 | 25 | public UserLoaderTest() { 26 | } 27 | 28 | @BeforeClass 29 | public static void setUpClass() { 30 | } 31 | 32 | @AfterClass 33 | public static void tearDownClass() { 34 | } 35 | 36 | @Before 37 | public void setUp() { 38 | } 39 | 40 | @After 41 | public void tearDown() { 42 | } 43 | 44 | /** 45 | * Test of load method, of class UserFileLoader. 46 | */ 47 | @Test 48 | public void testLoad() throws Exception { 49 | System.out.println("load"); 50 | File cfgFile = loadFile("config00.xml"); 51 | Configuration cfg = JAXB.unmarshal(cfgFile, Configuration.class); 52 | 53 | UserFileLoader instance = new UserFileLoader(cfg.getUserFileConfig()); 54 | File userFile = loadFile("ldif.csv"); 55 | instance.load(userFile); 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/test/resources/ldifexample.txt: -------------------------------------------------------------------------------- 1 | cn,changetype,givenName,mpsPreferredName,sn,initials,mpsExtensionNumber,pager,telephoneNumber,mobile,facsimileTelephoneNumber,mpsDepartmentBorough,mpsBranchOCU,description,mpsEmployeeType,mail,postalAddress,postalCode,mpsAstriumGISLiveRole 2 | rnicoll,add,Richard,Richard,Nicoll,,,,,,,,,,,richard.nicoll@infoterra-global.com,,,"ASTRIUM_ADMIN_VIEW,ASTRIUM_ADMIN_UPLOAD,APPLICATIONMPS,APPLICATIONOLYMPICS,APPLICATIONTORCH,APPLICATIONNOCC,FUNCTIONADMINISTRATOR 3 | knorek,modify,Konrad,Konrad,Norek,,,,,,,,,,,konrad.norek@infoterrra-global.com,,,"ASTRIUM_ADMIN_VIEW,ASTRIUM_ADMIN_UPLOAD,APPLICATIONMPS,APPLICATIONOLYMPICS,APPLICATIONTORCH,APPLICATIONNOCC,FUNCTIONADMINISTRATOR -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | log4j.rootLogger=INFO, consoleAppender 7 | 8 | log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender 9 | log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout 10 | #log4j.appender.consoleAppender.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS} %c::%M - %m%n 11 | #log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss.SSS} %C{1}.%M(%L) - %m %n 12 | #log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss.SSS} %I - %m %n 13 | log4j.appender.consoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss.SSS} %40.40c::%-15M %3L %x - %m%n 14 | #log4j.appender.consoleAppender.layout.ConversionPattern=%m%n 15 | 16 | log4j.logger.org.geoserver.geofence.services.rest=DEBUG 17 | -------------------------------------------------------------------------------- /src/samples/csv2geofence/src/test/resources/rules.csv: -------------------------------------------------------------------------------- 1 | Reference ID,DataAdminAstrium ,DataAdminGITeam,DataViewMPS,DataViewPNN,DataViewES,DataViewUnclassified,DataViewPublic,Geosever Registered,Load Type,Description,Geosever Registered,Load Type,Description,Geosever Registered,Load Type,Description,Georepository Registered,Backup Date,,WFS /Selectable -Check,WFS-T/editable - Check 2 | MPSOSGB00110026,F,V,V,V,V,V,N,0,0,0,Y,Y,0,Y,Y,0,,,,,1 3 | MPSEAEW00010002,F,V,V,V,V,N,N,0,0,0,Y,Y,0,Y,Y,0,Y,25/06/2012,,1,1 4 | MPSEAEW00010003,F,V,V,V,V,N,N,0,0,0,Y,Y,0,Y,Y,0,Y,25/06/2012,,1,1 5 | MPSEAEW00010004,F,V,V,V,V,N,N,0,0,0,Y,Y,0,Y,Y,0,Y,25/06/2012,,1,1 6 | MPSMPSF00000010,F,F,N,N,N,N,N,0,0,0,Y,Y,0,Y,Y,0,Y,25/06/2012,,1,1 7 | MPSMPSF00000026,F,F,V,V,V,N,N,0,0,0,Y,Y,0,Y,Y,0,Y,25/06/2012,,1,0 8 | MPSMPSF00000034,F,F,V,N,N,N,N,0,0,0,Y,Y,0,Y,Y,0,,,,1,1 9 | MPSMPSF00000035,F,F,V,V,V,N,N,0,0,0,Y,Y,0,Y,Y,0,Y,25-giu,,1,0 10 | MPSNOCC00080001,F,F,V,V,N,N,N,0,0,0,Y,0,0,Y,0,0,Y,25/06/2012,,, 11 | MPSCOMB10000018,F,V,V,V,V,V,N,0,0,0,Y,0,0,Y,0,0,Y,25-giu,,, 12 | MPSTEST00000001,F,F,N,N,N,N,N,0,0,0,Y,Y,0,0,0,0,,,,, 13 | MPSTEST00000002,F,F,N,N,N,N,N,0,0,0,Y,0,0,0,0,0,,,,, 14 | MPSTEST00000003,F,F,N,N,V,N,N,0,0,0,Y,Y,0,0,0,0,,,,, 15 | MPSTEST00000004,F,F,N,N,N,N,N,0,0,0,Y,N,N/A,0,0,0,,,,, 16 | MPSDEMO00000001,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 17 | MPSDEMO00000002,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 18 | MPSDEMO00000003,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 19 | MPSDEMO00000004,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 20 | MPSDEMO00000005,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 21 | MPSDEMO00000006,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 22 | MPSDEMO00000007,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 23 | MPSDEMO00000008,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 24 | MPSDEMO00000009,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 25 | MPSDEMO00000010,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 26 | MPSDEMO00000011,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 27 | MPSDEMO00000012,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 28 | MPSDEMO00000013,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 29 | MPSDEMO00000014,F,F,V,N,N,N,N,0,0,0,Y,0,0,Y,0,0,,,,, 30 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/IPRangeProvider.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public interface IPRangeProvider { 13 | IPAddressRange getAddressRange(); 14 | } 15 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/Identifiable.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public interface Identifiable { 13 | 14 | Long getId(); 15 | void setId(Long id); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/Prioritizable.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public interface Prioritizable { 13 | 14 | long getPriority(); 15 | 16 | void setPriority(long priority); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/FK2UserAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | import org.geoserver.geofence.core.model.adapter.dual.IdNameBundle; 9 | import javax.xml.bind.annotation.adapters.XmlAdapter; 10 | 11 | import org.locationtech.jts.io.ParseException; 12 | import org.geoserver.geofence.core.model.GSUser; 13 | 14 | /** 15 | * Transform a Profile into its id. 16 | * 17 | */ 18 | public class FK2UserAdapter extends XmlAdapter { 19 | 20 | @Override 21 | public GSUser unmarshal(IdNameBundle in) throws ParseException { 22 | 23 | GSUser ret = new GSUser(); 24 | ret.setId(in.getId()); 25 | ret.setName(in.getName()); 26 | return ret; 27 | } 28 | 29 | @Override 30 | public IdNameBundle marshal(GSUser u) throws ParseException { 31 | IdNameBundle in = new IdNameBundle(); 32 | if (u != null) { 33 | in.setId(u.getId()); 34 | in.setName(u.getName()); 35 | } 36 | return in; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/FK2UserGroupAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | import org.geoserver.geofence.core.model.adapter.dual.IdNameBundle; 9 | import javax.xml.bind.annotation.adapters.XmlAdapter; 10 | 11 | import org.locationtech.jts.io.ParseException; 12 | import org.geoserver.geofence.core.model.UserGroup; 13 | 14 | /** 15 | * Transform a UserGroup into its id. 16 | * 17 | */ 18 | public class FK2UserGroupAdapter extends XmlAdapter { 19 | 20 | @Override 21 | public UserGroup unmarshal(IdNameBundle in) throws ParseException { 22 | 23 | UserGroup ret = new UserGroup(); 24 | ret.setId(in.getId()); 25 | ret.setName(in.getName()); 26 | return ret; 27 | } 28 | 29 | @Override 30 | public IdNameBundle marshal(UserGroup u) throws ParseException { 31 | IdNameBundle in = new IdNameBundle(); 32 | if (u != null) { 33 | in.setId(u.getId()); 34 | in.setName(u.getName()); 35 | } 36 | return in; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/FK2UserGroupSetAdapter2.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | import org.geoserver.geofence.core.model.adapter.dual.IdNameBundle; 9 | import javax.xml.bind.annotation.adapters.XmlAdapter; 10 | 11 | import org.locationtech.jts.io.ParseException; 12 | import org.geoserver.geofence.core.model.UserGroup; 13 | import java.util.ArrayList; 14 | import java.util.HashSet; 15 | import java.util.List; 16 | import java.util.Set; 17 | 18 | /** 19 | * Transform a UserGroup into its id. 20 | * 21 | */ 22 | public class FK2UserGroupSetAdapter2 extends XmlAdapter, Set> { 23 | 24 | @Override 25 | public Set unmarshal(ArrayList inSet) throws ParseException { 26 | if(inSet == null) 27 | return null; 28 | 29 | Set ret = new HashSet(); 30 | for (Long in : inSet) { 31 | UserGroup ug = new UserGroup(); 32 | ug.setId(in); 33 | ret.add(ug); 34 | } 35 | 36 | return ret; 37 | } 38 | 39 | @Override 40 | public ArrayList marshal(Set inSet) throws ParseException { 41 | if(inSet == null) 42 | return null; 43 | 44 | System.out.println("Marshalling " + inSet.size() + " groups"); 45 | 46 | ArrayList ret = new ArrayList(inSet.size()); 47 | for (UserGroup ug : inSet) { 48 | if (ug != null) { 49 | ret.add(ug.getId()); 50 | System.out.println("Added group " + ug.getId()); 51 | } 52 | } 53 | 54 | return ret; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/FKGSInstanceAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | 9 | import org.geoserver.geofence.core.model.GSInstance; 10 | 11 | /** 12 | * Transform a Profile into its id. 13 | * 14 | */ 15 | public class FKGSInstanceAdapter extends IdentifiableAdapter { 16 | 17 | @Override 18 | protected GSInstance createInstance() { 19 | return new GSInstance(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/FKUserAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | 9 | import org.geoserver.geofence.core.model.GSUser; 10 | 11 | /** 12 | * Transform a Profile into its id. 13 | * 14 | */ 15 | public class FKUserAdapter extends IdentifiableAdapter { 16 | 17 | @Override 18 | protected GSUser createInstance() { 19 | return new GSUser(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/FKUserGroupAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | 9 | import org.geoserver.geofence.core.model.UserGroup; 10 | 11 | /** 12 | * Transform a UserGroup into its id. 13 | * 14 | * @author ETj (etj at geo-solutions.it) 15 | */ 16 | public class FKUserGroupAdapter extends IdentifiableAdapter { 17 | 18 | @Override 19 | protected UserGroup createInstance() { 20 | return new UserGroup(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/GeometryAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | import javax.xml.bind.annotation.adapters.XmlAdapter; 9 | 10 | import org.locationtech.jts.geom.Geometry; 11 | import org.locationtech.jts.io.ParseException; 12 | import org.locationtech.jts.io.WKTReader; 13 | import org.locationtech.jts.io.WKTWriter; 14 | 15 | // TODO: Auto-generated Javadoc 16 | /** 17 | * The Class GeometryAdapter. 18 | * 19 | * @param the generic type 20 | */ 21 | public class GeometryAdapter extends XmlAdapter { 22 | 23 | /* 24 | * (non-Javadoc) 25 | * 26 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) 27 | */ 28 | @SuppressWarnings("unchecked") 29 | @Override 30 | public G unmarshal(String val) throws ParseException { 31 | WKTReader wktReader = new WKTReader(); 32 | 33 | Geometry the_geom = wktReader.read(val); 34 | if (the_geom.getSRID() == 0) 35 | the_geom.setSRID(4326); 36 | 37 | try { 38 | return (G) the_geom; 39 | } catch (ClassCastException e) { 40 | throw new ParseException("WKT val is a " + the_geom.getClass().getName()); 41 | } 42 | } 43 | 44 | /* 45 | * (non-Javadoc) 46 | * 47 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object) 48 | */ 49 | @Override 50 | public String marshal(G the_geom) throws ParseException { 51 | if (the_geom != null) { 52 | WKTWriter wktWriter = new WKTWriter(); 53 | if (the_geom.getSRID() == 0) 54 | the_geom.setSRID(4326); 55 | 56 | return wktWriter.write(the_geom); 57 | } else { 58 | throw new ParseException("Geometry obj is null."); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/IdentifiableAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | import javax.xml.bind.annotation.adapters.XmlAdapter; 9 | 10 | import org.locationtech.jts.io.ParseException; 11 | import org.geoserver.geofence.core.model.Identifiable; 12 | 13 | /** 14 | * Transform a Profile into its id. 15 | * 16 | */ 17 | public abstract class IdentifiableAdapter extends XmlAdapter { 18 | 19 | 20 | protected abstract I createInstance(); 21 | /* (non-Javadoc) 22 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) 23 | */ 24 | @SuppressWarnings("unchecked") 25 | @Override 26 | public I unmarshal(String val) throws ParseException { 27 | 28 | I ret = createInstance(); 29 | try { 30 | ret.setId(Long.valueOf(val)); 31 | return ret; 32 | } catch (NumberFormatException e) { 33 | throw new ParseException("Bad "+ ret.getClass().getSimpleName()+" id " + val); 34 | } 35 | } 36 | 37 | /* (non-Javadoc) 38 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object) 39 | */ 40 | @Override 41 | public String marshal(I p) throws ParseException { 42 | if (p != null) { 43 | return p.getId().toString(); 44 | } else { 45 | throw new ParseException("Obj is null"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/MapAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | import org.geoserver.geofence.core.model.adapter.dual.MapEntryType; 9 | import org.geoserver.geofence.core.model.adapter.dual.MapType; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | import javax.xml.bind.annotation.adapters.XmlAdapter; 13 | 14 | /** 15 | * 16 | * @author ETj (etj at geo-solutions.it) 17 | */ 18 | public class MapAdapter extends XmlAdapter> { 19 | 20 | @Override 21 | public MapType marshal(Map v) throws Exception { 22 | MapType ret = new MapType(); 23 | // System.out.println("marshalling..."); 24 | for (Map.Entry entry : v.entrySet()) { 25 | // System.out.println("marshalling " + entry.getKey()+":"+entry.getValue()); 26 | ret.add(entry); 27 | } 28 | 29 | return ret; 30 | } 31 | 32 | @Override 33 | public Map unmarshal(MapType v) throws Exception { 34 | Map ret = new HashMap(); 35 | // System.out.println("unmarshalling..."); 36 | for (MapEntryType entry : v) { 37 | // System.out.println("unmarshalling " + entry.getKey() + ":" + entry.getValue()); 38 | ret.put(entry.getKey(), entry.getValue()); 39 | } 40 | return ret; 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/MultiPolygonAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | import org.locationtech.jts.geom.MultiPolygon; 9 | 10 | /** 11 | * The Class MultiPolygonAdapter. 12 | */ 13 | public class MultiPolygonAdapter extends GeometryAdapter { 14 | } 15 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/PolygonAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | import javax.xml.bind.annotation.adapters.XmlAdapter; 9 | 10 | import org.locationtech.jts.geom.Geometry; 11 | import org.locationtech.jts.geom.Polygon; 12 | import org.locationtech.jts.io.ParseException; 13 | import org.locationtech.jts.io.WKTReader; 14 | import org.locationtech.jts.io.WKTWriter; 15 | 16 | // TODO: Auto-generated Javadoc 17 | /** 18 | * The Class PolygonAdapter. 19 | */ 20 | public class PolygonAdapter extends XmlAdapter { 21 | 22 | /* (non-Javadoc) 23 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) 24 | */ 25 | @Override 26 | public Polygon unmarshal(String val) throws ParseException { 27 | WKTReader wktReader = new WKTReader(); 28 | 29 | Geometry the_geom = wktReader.read(val); 30 | if (the_geom instanceof Polygon) { 31 | if (the_geom.getSRID() == 0) 32 | the_geom.setSRID(4326); 33 | 34 | return (Polygon) the_geom; 35 | } 36 | 37 | throw new ParseException("WKB val is not a Polygon."); 38 | } 39 | 40 | /* (non-Javadoc) 41 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object) 42 | */ 43 | @Override 44 | public String marshal(Polygon the_geom) throws ParseException { 45 | if (the_geom != null) { 46 | WKTWriter wktWriter = new WKTWriter(); 47 | if (the_geom.getSRID() == 0) 48 | the_geom.setSRID(4326); 49 | 50 | return wktWriter.write(the_geom); 51 | } else { 52 | throw new ParseException("Polygon obj is null."); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/XMultiPolygonAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; 7 | 8 | import javax.xml.bind.annotation.adapters.XmlAdapter; 9 | 10 | import org.locationtech.jts.geom.Geometry; 11 | import org.locationtech.jts.geom.MultiPolygon; 12 | import org.locationtech.jts.io.ParseException; 13 | import org.locationtech.jts.io.WKTReader; 14 | import org.locationtech.jts.io.WKTWriter; 15 | 16 | // TODO: Auto-generated Javadoc 17 | /** 18 | * The Class XMultiPolygonAdapter. 19 | */ 20 | public class XMultiPolygonAdapter extends XmlAdapter { 21 | 22 | /* (non-Javadoc) 23 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) 24 | */ 25 | @Override 26 | public MultiPolygon unmarshal(String val) throws ParseException { 27 | WKTReader wktReader = new WKTReader(); 28 | 29 | Geometry the_geom = wktReader.read(val); 30 | if (the_geom.getSRID() == 0) 31 | the_geom.setSRID(4326); 32 | 33 | try { 34 | return (MultiPolygon) the_geom; 35 | } catch (ClassCastException e) { 36 | throw new ParseException("WKT val is a " + the_geom.getClass().getName()); 37 | } 38 | } 39 | 40 | /* (non-Javadoc) 41 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object) 42 | */ 43 | @Override 44 | public String marshal(MultiPolygon the_geom) throws ParseException { 45 | if (the_geom != null) { 46 | WKTWriter wktWriter = new WKTWriter(); 47 | if (the_geom.getSRID() == 0) 48 | the_geom.setSRID(4326); 49 | 50 | return wktWriter.write(the_geom); 51 | } else { 52 | throw new ParseException("Geometry obj is null."); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/dual/IdNameBundle.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter.dual; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public class IdNameBundle { 13 | private Long id; 14 | private String name; 15 | 16 | public Long getId() { 17 | return id; 18 | } 19 | 20 | public void setId(Long id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return getClass().getSimpleName()+"[id:" + id + " name=" + name + ']'; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/dual/MapEntryType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter.dual; 7 | 8 | import javax.xml.bind.annotation.XmlAttribute; 9 | import javax.xml.bind.annotation.XmlRootElement; 10 | import javax.xml.bind.annotation.XmlValue; 11 | 12 | /** 13 | * 14 | * @author ETj (etj at geo-solutions.it) 15 | */ 16 | @XmlRootElement(name="entry") 17 | public class MapEntryType { 18 | 19 | private String key; 20 | private String value; 21 | 22 | public MapEntryType(String key, String value) { 23 | this.key = key; 24 | this.value = value; 25 | } 26 | 27 | public MapEntryType() { 28 | } 29 | 30 | @XmlAttribute 31 | public String getKey() { 32 | return key; 33 | } 34 | 35 | public void setKey(String key) { 36 | this.key = key; 37 | } 38 | 39 | @XmlValue 40 | public String getValue() { 41 | return value; 42 | } 43 | 44 | public void setValue(String value) { 45 | this.value = value; 46 | } 47 | } -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/dual/MapType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter.dual; 7 | 8 | import java.util.Iterator; 9 | import java.util.LinkedList; 10 | import java.util.List; 11 | import java.util.Map; 12 | import javax.xml.bind.annotation.XmlElement; 13 | import javax.xml.bind.annotation.XmlRootElement; 14 | 15 | /** 16 | * 17 | * @author ETj (etj at geo-solutions.it) 18 | */ 19 | @XmlRootElement(name = "Map") 20 | public class MapType implements Iterable { 21 | 22 | 23 | List entries = new LinkedList(); 24 | 25 | @XmlElement(name = "entry") 26 | public List getEntries() { 27 | return entries; 28 | } 29 | 30 | public void setEntries(List entries) { 31 | this.entries = entries; 32 | } 33 | 34 | public void add(Map.Entry entry) { 35 | entries.add(new MapEntryType(entry.getKey(), entry.getValue())); 36 | } 37 | 38 | @Override 39 | public Iterator iterator() { 40 | return entries.iterator(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/adapter/package-info.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.adapter; -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/AccessType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.enums; 7 | 8 | /** 9 | * The Enum AccessType. 10 | * 11 | * @author ETj (etj at geo-solutions.it) 12 | */ 13 | public enum AccessType { 14 | 15 | /** No access to the resource. */ 16 | NONE, 17 | 18 | /** Read only access. */ 19 | READONLY, 20 | 21 | /** Full access. */ 22 | READWRITE 23 | } 24 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/AdminGrantType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.enums; 7 | 8 | /** 9 | * The Enum AdminGrantType. 10 | */ 11 | public enum AdminGrantType { 12 | ADMIN, 13 | USER 14 | } 15 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/CatalogMode.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.enums; 7 | 8 | /** 9 | * CatalogMode is the mode used in geoserver for a given layer. 10 | * 11 | * @author ETj (etj at geo-solutions.it) 12 | */ 13 | public enum CatalogMode { 14 | HIDE, CHALLENGE, MIXED; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/GrantType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.enums; 7 | 8 | /** 9 | * The Enum GrantType. 10 | */ 11 | public enum GrantType { 12 | ALLOW, 13 | DENY, 14 | LIMIT 15 | } 16 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/InsertPosition.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.enums; 7 | 8 | /** 9 | * Used in DAOs and Services 10 | * 11 | * @author ETj (etj at geo-solutions.it) 12 | */ 13 | public enum InsertPosition { 14 | 15 | /** priority is a fixed value */ 16 | FIXED, 17 | /** priority is the position from start (0 is the first one) */ 18 | FROM_START, 19 | /** * priority is the position from end (0 is the last one) */ 20 | FROM_END 21 | } 22 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/KnownServices.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.enums; 7 | 8 | /** 9 | * The Enum AccessType. 10 | */ 11 | public enum KnownServices { 12 | WMS, WCS, WFS, WPS 13 | } 14 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/LayerType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.enums; 7 | 8 | /** 9 | * The type of a Layer (Vector or Raster) 10 | */ 11 | public enum LayerType { 12 | VECTOR, 13 | RASTER, 14 | LAYERGROUP 15 | } 16 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/SpatialFilterType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2020 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.core.model.enums; 6 | 7 | public enum SpatialFilterType { 8 | INTERSECT,CLIP 9 | } 10 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/ValueType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.enums; 7 | 8 | /** 9 | * The Enum ValueType. 10 | */ 11 | public enum ValueType { 12 | 13 | /** The BOOL. */ 14 | BOOL, 15 | 16 | /** The INT. */ 17 | INT, 18 | 19 | /** The STRING. */ 20 | STRING, 21 | 22 | /** The STRINGLIST. */ 23 | STRINGLIST 24 | } 25 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/enums/package-info.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.enums; -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/package-info.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model; -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/util/EWKTParser.java: -------------------------------------------------------------------------------- 1 | /* (c) 2024 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.core.model.util; 6 | 7 | import org.locationtech.jts.geom.Geometry; 8 | import org.locationtech.jts.io.ParseException; 9 | import org.locationtech.jts.io.WKTReader; 10 | 11 | /** 12 | * 13 | * @author etj 14 | */ 15 | public class EWKTParser { 16 | 17 | static public Geometry parse(String wkt) throws ParseException { 18 | if (wkt == null) { 19 | return null; 20 | } 21 | 22 | WKTReader reader = new WKTReader(); 23 | Geometry result; 24 | if (wkt.startsWith("SRID=")) { 25 | String[] areaAr = wkt.split(";"); 26 | String srid = areaAr[0].split("=")[1]; 27 | result = reader.read(areaAr[1]); 28 | result.setSRID(Integer.valueOf(srid)); 29 | } else { 30 | result = reader.read(wkt); 31 | result.setSRID(4326); 32 | } 33 | return result; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/services/core/model/src/main/java/org/geoserver/geofence/core/model/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model.util; -------------------------------------------------------------------------------- /src/services/core/model/src/test/java/org/geoserver/geofence/core/model/Base64EncodersTest.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model; 7 | 8 | import java.util.Arrays; 9 | import javax.xml.bind.DatatypeConverter; 10 | import org.apache.commons.codec.binary.Base64; 11 | import org.junit.Assert; 12 | import static org.junit.Assert.assertEquals; 13 | import org.junit.Test; 14 | 15 | /** 16 | * Moving base64 de-coding from commons codec to DatatypeConverter. 17 | * Making sure the results are the same, or we may lose some passwords in the db... 18 | * 19 | * @author ETj (etj at geo-solutions.it) 20 | */ 21 | public class Base64EncodersTest { 22 | 23 | @Test 24 | public void testEq() { 25 | 26 | String msg1 = "this is the message to encode"; 27 | 28 | String output_codec = new String(Base64.encodeBase64(msg1.getBytes())); 29 | String output_dconv = DatatypeConverter.printBase64Binary(msg1.getBytes()); 30 | 31 | System.out.println("apache commons: " + output_codec); 32 | System.out.println("DatatypeConverter: " + output_dconv); 33 | assertEquals(output_codec, output_dconv); 34 | 35 | byte[] back_codec = Base64.decodeBase64(output_dconv); 36 | byte[] back_dconv = DatatypeConverter.parseBase64Binary(output_dconv); 37 | 38 | 39 | 40 | Assert.assertTrue( Arrays.equals(msg1.getBytes(), back_codec)); 41 | Assert.assertTrue( Arrays.equals(msg1.getBytes(), back_dconv)); 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/services/core/model/src/test/java/org/geoserver/geofence/core/model/IPAddressRangeTest.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.model; 7 | 8 | import org.geoserver.geofence.core.model.IPAddressRange; 9 | import org.junit.Test; 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * 14 | * @author ETj (etj at geo-solutions.it) 15 | */ 16 | public class IPAddressRangeTest { 17 | 18 | public IPAddressRangeTest() { 19 | } 20 | 21 | 22 | @Test 23 | public void testCIDRConstructorV4() { 24 | 25 | IPAddressRange r = new IPAddressRange("1.2.0.0/16"); 26 | 27 | assertEquals(16, r.getSize()); 28 | 29 | assertEquals((long)(1<<24 | 2 << 16), (long)r.getLow()); 30 | assertNull(r.getHigh()); 31 | } 32 | 33 | @Test 34 | public void testMatch() { 35 | 36 | IPAddressRange r = new IPAddressRange("1.2.0.0/16"); 37 | 38 | assertTrue(r.match("1.2.3.4")); 39 | assertFalse(r.match("1.1.3.4")); 40 | 41 | assertTrue(new IPAddressRange("10.10.100.80/32").match("10.10.100.80")); 42 | } 43 | 44 | @Test 45 | public void testToString() { 46 | 47 | String s = "1.2.0.0/16"; 48 | 49 | IPAddressRange r = new IPAddressRange(s); 50 | 51 | assertEquals(s, r.getCidrSignature()); 52 | assertEquals("1.2.0.0", r.getAddress()); 53 | } 54 | 55 | @Test 56 | public void testHigestBitV4() { 57 | 58 | IPAddressRange r = new IPAddressRange("255.2.127.0/20"); 59 | 60 | assertEquals(20, r.getSize()); 61 | 62 | assertEquals((255<<24 | 2 << 16 | 127 << 8)&0x0ffffffff, (long)r.getLow()); 63 | assertNull(r.getHigh()); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/services/core/persistence-pg-test/src/test/resources/geofence-datasource-ovr.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | 7 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=create-drop 8 | geofenceVendorAdapter.generateDdl=true 9 | geofenceVendorAdapter.showSql=true 10 | 11 | geofenceVendorAdapter.databasePlatform=org.hibernate.spatial.dialect.postgis.PostgisDialect 12 | geofenceDataSource.driverClassName=org.postgresql.Driver 13 | geofenceDataSource.url=jdbc:postgresql://localhost:5432/geofence_test 14 | geofenceDataSource.username=geofence_test 15 | geofenceDataSource.password=geofence_test 16 | #geofenceEntityManagerFactory.jpaPropertyMap[hibernate.default_schema]=geofence_test 17 | -------------------------------------------------------------------------------- /src/services/core/persistence-pg-test/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | log4j.rootLogger=INFO, consoleAppender 7 | 8 | log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender 9 | log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout 10 | log4j.appender.consoleAppender.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS} %c::%M - %m%n 11 | 12 | log4j.logger.org.hibernate=INFO 13 | log4j.logger.com.trg=INFO 14 | 15 | log4j.logger.org.geoserver.geofence=DEBUG 16 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/AdminRuleDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import org.geoserver.geofence.core.model.AdminRule; 9 | import org.geoserver.geofence.core.model.enums.InsertPosition; 10 | 11 | /** 12 | * Public interface to define operations on AdminRule 13 | * 14 | * @author Emanuele Tajariol (etj at geo-solutions.it) 15 | */ 16 | 17 | public interface AdminRuleDAO // 18 | extends PrioritizableDAO, SearchableDAO { 19 | 20 | long persist(AdminRule entity, InsertPosition position); 21 | } 22 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/AllowedStylesProvider.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * 12 | * @author ETj (etj at geo-solutions.it) 13 | */ 14 | public interface AllowedStylesProvider { 15 | 16 | public Set getAllowedStyles(Long id); 17 | public void setAllowedStyles(Long id, Set styles); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/DuplicateKeyException.java: -------------------------------------------------------------------------------- 1 | /* (c) 2016 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) */ 11 | public class DuplicateKeyException extends RuntimeException { 12 | static final long serialVersionUID = 3804897190745766939L; 13 | 14 | public DuplicateKeyException() { 15 | } 16 | 17 | public DuplicateKeyException(String message) { 18 | super(message); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/GFUserDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import org.geoserver.geofence.core.model.GFUser; 9 | 10 | /** 11 | * Public interface to define operations on GRUsers 12 | * 13 | * @author Emanuele Tajariol (etj at geo-solutions.it) 14 | */ 15 | 16 | public interface GFUserDAO // 17 | extends RestrictedGenericDAO, SearchableDAO { 18 | } 19 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/GSInstanceDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import org.geoserver.geofence.core.model.GSInstance; 9 | 10 | /** 11 | * Public interface to define operations on GSInstances 12 | * 13 | * @author Emanuele Tajariol (etj at geo-solutions.it) 14 | */ 15 | 16 | public interface GSInstanceDAO // 17 | extends RestrictedGenericDAO, SearchableDAO { 18 | } 19 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/GSUserDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import java.util.List; 9 | import org.geoserver.geofence.core.model.GSUser; 10 | 11 | /** 12 | * Public interface to define operations on GSUsers 13 | * 14 | * @author Emanuele Tajariol (etj at geo-solutions.it) 15 | */ 16 | 17 | public interface GSUserDAO extends RestrictedGenericDAO, RegistrableDAO { 18 | 19 | /** Fetch a GSUser with all of its related groups */ 20 | GSUser getFull(String name); 21 | 22 | List search(String nameLike, Integer page, Integer entries, boolean fetchGroups) throws IllegalArgumentException; 23 | long countByNameLike(String nameLike); 24 | } 25 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/LayerDetailsDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import org.geoserver.geofence.core.model.LayerDetails; 9 | 10 | /** 11 | * Public interface to define operations on LayerDetails 12 | * 13 | * @author Emanuele Tajariol (etj at geo-solutions.it) 14 | */ 15 | 16 | public interface LayerDetailsDAO 17 | extends RestrictedGenericDAO, 18 | AllowedStylesProvider{ 19 | } 20 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/PrioritizableDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import org.geoserver.geofence.core.model.Prioritizable; 9 | import org.geoserver.geofence.core.model.enums.InsertPosition; 10 | 11 | /** 12 | * 13 | * @author ETj (etj at geo-solutions.it) 14 | */ 15 | public interface PrioritizableDAO extends RestrictedGenericDAO{ 16 | 17 | long persist(T entity, InsertPosition position); 18 | 19 | /** 20 | * Shifts the priority of the rules having priority >= priorityStart 21 | * down by offset. 22 | *

23 | * The shift will not be performed if there are no Rules with priority:
24 | * startPriority <= priority < startPriority + offset 25 | * 26 | * @return the number of rules updated, or -1 if no need to shift. 27 | */ 28 | int shift(long priorityStart, long offset); 29 | 30 | /** 31 | * Swaps the priorities of the two rules. 32 | */ 33 | void swap(long id1, long id2); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/RegistrableDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.core.dao; 6 | 7 | /** 8 | * @author Emanuele Tajariol (etj at geo-solutions.it) 9 | */ 10 | public interface RegistrableDAO 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/RestrictedGenericDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Public interface to define a restricted set of operation wrt to ones 12 | * defined in GenericDAO. 13 | * This may be useful if some constraints are implemented in the DAO, so that fewer 14 | * point of access are allowed. 15 | * 16 | * @author Emanuele Tajariol (etj at geo-solutions.it) 17 | */ 18 | 19 | public interface RestrictedGenericDAO /* extends GenericDAO */{ 20 | public List findAll(); 21 | public ENTITY find(Long id); 22 | public void persist(ENTITY... entities); 23 | public ENTITY merge(ENTITY entity); 24 | public boolean remove(ENTITY entity); 25 | public boolean removeById(Long id); 26 | } 27 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/RuleDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014, 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import org.geoserver.geofence.core.model.Rule; 9 | import org.geoserver.geofence.core.model.enums.InsertPosition; 10 | 11 | /** 12 | * Public interface to define operations on Rule 13 | * 14 | * @author Emanuele Tajariol (etj at geo-solutions.it) 15 | */ 16 | 17 | public interface RuleDAO // 18 | extends PrioritizableDAO, SearchableDAO { 19 | 20 | long persist(Rule entity, InsertPosition position); 21 | } 22 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/RuleLimitsDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import org.geoserver.geofence.core.model.RuleLimits; 9 | 10 | /** 11 | * Public interface to define operations on RuleLimits 12 | * 13 | * @author Emanuele Tajariol (etj at geo-solutions.it) 14 | */ 15 | 16 | public interface RuleLimitsDAO extends RestrictedGenericDAO { 17 | } 18 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/SearchableDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2020 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.core.dao; 6 | 7 | import java.util.List; 8 | import org.geoserver.geofence.core.dao.search.LongSearch; 9 | import org.geoserver.geofence.core.dao.search.Search; 10 | 11 | /** 12 | * @author Emanuele Tajariol (etj at geo-solutions.it) 13 | */ 14 | public interface SearchableDAO { 15 | 16 | public Search createSearch(); 17 | public LongSearch createLongSearch(); 18 | 19 | public List search(Search search); 20 | public long count(LongSearch search); 21 | } 22 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/UserGroupDAO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import java.util.List; 9 | import org.geoserver.geofence.core.model.UserGroup; 10 | 11 | /** 12 | * Public interface to define operations on UserGroups 13 | * 14 | * @author Emanuele Tajariol (etj at geo-solutions.it) 15 | */ 16 | 17 | public interface UserGroupDAO // 18 | extends RestrictedGenericDAO, RegistrableDAO { 19 | 20 | UserGroup get(String name); 21 | 22 | List search(String nameLike, Integer page, Integer entries) throws IllegalArgumentException; 23 | long countByNameLike(String nameLike); 24 | } 25 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/impl/GFUserDAOImpl.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao.impl; 7 | 8 | 9 | import org.geoserver.geofence.core.dao.GFUserDAO; 10 | import org.geoserver.geofence.core.model.GFUser; 11 | import org.geoserver.geofence.core.dao.search.Search; 12 | 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | import org.springframework.transaction.annotation.Transactional; 17 | 18 | import org.apache.logging.log4j.LogManager; 19 | import org.apache.logging.log4j.Logger; 20 | 21 | 22 | /** 23 | * Public implementation of the GFUserDAO interface 24 | * 25 | * @author Emanuele Tajariol (etj at geo-solutions.it) 26 | */ 27 | @Transactional(value = "geofenceTransactionManager") 28 | public class GFUserDAOImpl // 29 | extends BaseDAO // 30 | implements GFUserDAO 31 | { 32 | 33 | private static final Logger LOGGER = LogManager.getLogger(GFUserDAOImpl.class); 34 | 35 | public GFUserDAOImpl() { 36 | super(GFUser.class); 37 | } 38 | 39 | @Override 40 | public void persist(GFUser... entities) 41 | { 42 | Date now = new Date(); 43 | for (GFUser user : entities) 44 | { 45 | user.setDateCreation(now); 46 | } 47 | super.persist(entities); 48 | } 49 | 50 | @Override 51 | public List findAll() 52 | { 53 | return super.findAll(); 54 | } 55 | 56 | @Override 57 | public GFUser merge(GFUser entity) 58 | { 59 | return super.merge(entity); 60 | } 61 | 62 | @Override 63 | public boolean remove(GFUser entity) 64 | { 65 | return super.remove(entity); 66 | } 67 | 68 | @Override 69 | public boolean removeById(Long id) 70 | { 71 | return super.removeById(id); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/impl/GSInstanceDAOImpl.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao.impl; 7 | 8 | import java.util.List; 9 | 10 | 11 | import org.geoserver.geofence.core.dao.GSInstanceDAO; 12 | import org.geoserver.geofence.core.model.GSInstance; 13 | 14 | import org.apache.logging.log4j.LogManager; 15 | import org.apache.logging.log4j.Logger; 16 | 17 | import org.springframework.transaction.annotation.Transactional; 18 | 19 | 20 | /** 21 | * Public implementation of the GSInstanceDAO interface 22 | * 23 | * @author Emanuele Tajariol (etj at geo-solutions.it) 24 | */ 25 | @Transactional(value = "geofenceTransactionManager") 26 | public class GSInstanceDAOImpl extends BaseDAO implements GSInstanceDAO 27 | { 28 | 29 | private static final Logger LOGGER = LogManager.getLogger(GSInstanceDAOImpl.class); 30 | 31 | public GSInstanceDAOImpl() { 32 | super(GSInstance.class); 33 | } 34 | 35 | @Override 36 | public void persist(GSInstance... entities) 37 | { 38 | super.persist(entities); 39 | } 40 | 41 | @Override 42 | public List findAll() 43 | { 44 | return super.findAll(); 45 | } 46 | 47 | @Override 48 | public GSInstance merge(GSInstance entity) 49 | { 50 | return super.merge(entity); 51 | } 52 | 53 | @Override 54 | public boolean remove(GSInstance entity) 55 | { 56 | return super.remove(entity); 57 | } 58 | 59 | @Override 60 | public boolean removeById(Long id) 61 | { 62 | return super.removeById(id); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/impl/RuleLimitsDAOImpl.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao.impl; 7 | 8 | import org.geoserver.geofence.core.dao.RuleLimitsDAO; 9 | import org.geoserver.geofence.core.dao.search.Search; 10 | import org.geoserver.geofence.core.model.RuleLimits; 11 | 12 | import org.apache.logging.log4j.LogManager; 13 | import org.apache.logging.log4j.Logger; 14 | 15 | import java.util.List; 16 | 17 | import org.springframework.transaction.annotation.Transactional; 18 | 19 | 20 | /** 21 | * Public implementation of the RuleLimitsDAO interface 22 | * 23 | * @author Emanuele Tajariol (etj at geo-solutions.it) 24 | */ 25 | @Transactional(value = "geofenceTransactionManager") 26 | public class RuleLimitsDAOImpl // 27 | extends BaseDAO // 28 | implements RuleLimitsDAO 29 | { 30 | private static final Logger LOGGER = LogManager.getLogger(RuleLimitsDAOImpl.class); 31 | 32 | public RuleLimitsDAOImpl() { 33 | super(RuleLimits.class); 34 | } 35 | 36 | @Override 37 | public void persist(RuleLimits... entities) 38 | { 39 | super.persist(entities); 40 | } 41 | 42 | @Override 43 | public List findAll() 44 | { 45 | return super.findAll(); 46 | } 47 | 48 | @Override 49 | public RuleLimits merge(RuleLimits entity) 50 | { 51 | return super.merge(entity); 52 | } 53 | 54 | @Override 55 | public boolean remove(RuleLimits entity) 56 | { 57 | return super.remove(entity); 58 | } 59 | 60 | @Override 61 | public boolean removeById(Long id) 62 | { 63 | return super.removeById(id); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/search/LongSearch.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.geoserver.geofence.core.dao.search; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.TypedQuery; 7 | import javax.persistence.criteria.Selection; 8 | 9 | /** 10 | * 11 | * @author etj 12 | */ 13 | public class LongSearch extends BaseSearch { 14 | 15 | public LongSearch(EntityManager em, Class rootClass) { 16 | super(em, Long.class, rootClass); 17 | } 18 | 19 | public TypedQuery getCountQuery() { 20 | applyWhere(cquery); 21 | cquery.select(cb.count(root)); 22 | return em.createQuery(cquery); 23 | } 24 | 25 | public void addField(String field, Field op) { 26 | if (op == Field.OP_MAX) { 27 | cquery.select(cb.max(root.get(field))); 28 | } else { 29 | throw new UnsupportedOperationException("Not supported yet."); 30 | } 31 | } 32 | 33 | @Override 34 | // just a sample implementation, probably never used 35 | public Selection getDefaultSelection() { 36 | return cb.count(root); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/java/org/geoserver/geofence/core/dao/search/Search.java: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | package org.geoserver.geofence.core.dao.search; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.criteria.Selection; 7 | 8 | /** 9 | * A search on the BASE class returning instances of the BASE class. 10 | * 11 | * @author Emanuele Tajariol 12 | */ 13 | public class Search extends BaseSearch { 14 | 15 | public Search(EntityManager em, Class baseClass) { 16 | super(em, baseClass, baseClass); 17 | } 18 | 19 | @Override 20 | public Selection getDefaultSelection() { 21 | return root; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/resources/geofence-ehcache.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 12 | 13 | 14 | 15 | 19 | 20 | 24 | 28 | 32 | 33 | 40 | 41 | 46 | 47 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/main/resources/geofence-externalize-aux.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | geofence-ovr=dummy_ovr 7 | geofence.dir=dummy_dir -------------------------------------------------------------------------------- /src/services/core/persistence/src/test/java/org/geoserver/geofence/core/dao/GFUserDAOTest.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.core.dao; 7 | 8 | import org.geoserver.geofence.core.model.GFUser; 9 | 10 | import static org.junit.Assert.*; 11 | import org.junit.Test; 12 | 13 | /** 14 | * 15 | * @author ETj (etj at geo-solutions.it) 16 | */ 17 | public class GFUserDAOTest extends BaseDAOTest { 18 | 19 | @Test 20 | public void testPersistUser() throws Exception { 21 | 22 | removeAllGRUsers(); 23 | 24 | long id; 25 | { 26 | GFUser user = new GFUser(); 27 | user.setName(name.getMethodName()); 28 | gfUserDAO.persist(user); 29 | id = user.getId(); 30 | } 31 | 32 | // test save & load 33 | { 34 | GFUser loaded = gfUserDAO.find(id); 35 | assertNotNull("Can't retrieve user", loaded); 36 | } 37 | 38 | gfUserDAO.removeById(id); 39 | assertNull("User not deleted", gfUserDAO.find(id)); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /src/services/core/persistence/src/test/resources/geofence-datasource-ovr.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=create-drop 7 | geofenceVendorAdapter.generateDdl=true 8 | geofenceVendorAdapter.showSql=true 9 | 10 | #geofenceVendorAdapter.databasePlatform=org.hibernatespatial.postgis.PostgisDialect 11 | #geofenceDataSource.driverClassName=org.postgresql.Driver 12 | #geofenceDataSource.url=jdbc:postgresql://localhost:5432/geofence_test 13 | #geofenceDataSource.username=geofence_test 14 | #geofenceDataSource.password=geofence_test 15 | -------------------------------------------------------------------------------- /src/services/core/persistence/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/services/core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 4.0.0 13 | 14 | 15 | org.geoserver.geofence 16 | geofence-root 17 | 3.8-SNAPSHOT 18 | 19 | 20 | org.geoserver.geofence 21 | geofence-core 22 | GeoFence - Core 23 | pom 24 | 25 | 26 | model 27 | model-external 28 | persistence 29 | services-api 30 | services-impl 31 | webtest 32 | 33 | 34 | 35 | 36 | postgis 37 | 38 | persistence-pg-test 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/AuthorizationService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services; 7 | 8 | import org.geoserver.geofence.services.dto.AuthUser; 9 | 10 | /** 11 | * 12 | * @author ETj (etj at geo-solutions.it) 13 | */ 14 | public interface AuthorizationService { 15 | 16 | public AuthUser authorize(String username, String password); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/ConfigAdminService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services; 7 | 8 | import org.geoserver.geofence.core.model.GSUser; 9 | import org.geoserver.geofence.services.dto.ShortUser; 10 | import org.geoserver.geofence.services.exception.NotFoundServiceEx; 11 | 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * Operations on {@link GSUser GSUser}s. 17 | * 18 | * @author Emanuele Tajariol (etj at geo-solutions.it) 19 | */ 20 | public interface ConfigAdminService 21 | { 22 | 23 | // ========================================================================== 24 | // Basic operations 25 | 26 | long insert(GSUser user); 27 | 28 | long update(GSUser user) throws NotFoundServiceEx; 29 | 30 | boolean delete(long id) throws NotFoundServiceEx; 31 | 32 | GSUser get(long id) throws NotFoundServiceEx; 33 | 34 | List getAll(); 35 | 36 | List getList(String nameLike, Integer page, Integer entries); 37 | 38 | long getCount(String nameLike); 39 | } 40 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/GFUserAdminService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services; 7 | 8 | import org.geoserver.geofence.core.model.GFUser; 9 | import org.geoserver.geofence.services.dto.ShortUser; 10 | import org.geoserver.geofence.services.exception.NotFoundServiceEx; 11 | 12 | import java.util.List; 13 | 14 | 15 | /** 16 | * Operations on {@link GFUser GFUser}s. 17 | * 18 | * @author Emanuele Tajariol (etj at geo-solutions.it) 19 | */ 20 | public interface GFUserAdminService extends GetProviderService 21 | { 22 | 23 | // ========================================================================== 24 | // Basic operations 25 | 26 | long insert(GFUser user); 27 | 28 | long update(GFUser user) throws NotFoundServiceEx; 29 | 30 | boolean delete(long id) throws NotFoundServiceEx; 31 | 32 | @Override 33 | GFUser get(long id) throws NotFoundServiceEx; 34 | GFUser get(String name) throws NotFoundServiceEx; 35 | 36 | long getCount(String nameLike); 37 | 38 | List getList(String nameLike, Integer page, Integer entries); 39 | 40 | List getFullList(String nameLike, Integer page, Integer entries); 41 | } 42 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/GetProviderService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services; 7 | 8 | import org.geoserver.geofence.core.model.UserGroup; 9 | import org.geoserver.geofence.services.exception.NotFoundServiceEx; 10 | 11 | 12 | /** 13 | * Operations on {@link UserGroup UserGroup}s. 14 | * 15 | * @author Emanuele Tajariol (etj at geo-solutions.it) 16 | */ 17 | public interface GetProviderService 18 | { 19 | 20 | E get(long id) throws NotFoundServiceEx; 21 | } 22 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/InstanceAdminService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services; 7 | 8 | import org.geoserver.geofence.core.model.GSInstance; 9 | import org.geoserver.geofence.services.dto.ShortInstance; 10 | import org.geoserver.geofence.services.exception.NotFoundServiceEx; 11 | 12 | import java.util.List; 13 | 14 | 15 | /** 16 | * Operations on {@link GSInstance GSInstance}s. 17 | * 18 | * @author Emanuele Tajariol (etj at geo-solutions.it) 19 | */ 20 | public interface InstanceAdminService extends GetProviderService 21 | { 22 | 23 | // ========================================================================== 24 | // Basic operations 25 | 26 | long insert(GSInstance instance); 27 | 28 | long update(GSInstance instance) throws NotFoundServiceEx; 29 | 30 | boolean delete(long id) throws NotFoundServiceEx; 31 | 32 | @Override 33 | GSInstance get(long id) throws NotFoundServiceEx; 34 | GSInstance get(String name) throws NotFoundServiceEx; 35 | 36 | List getAll(); 37 | 38 | List getFullList(String nameLike, Integer page, Integer entries); 39 | List getList(String nameLike, Integer page, Integer entries); 40 | 41 | long getCount(String nameLike); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/RuleReaderService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services; 7 | 8 | import org.geoserver.geofence.core.model.Rule; 9 | import org.geoserver.geofence.services.dto.AccessInfo; 10 | import org.geoserver.geofence.services.dto.AuthUser; 11 | import org.geoserver.geofence.services.dto.RuleFilter; 12 | import org.geoserver.geofence.services.dto.ShortRule; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * Operations on 18 | * 19 | * @author Emanuele Tajariol (etj at geo-solutions.it) 20 | */ 21 | public interface RuleReaderService 22 | { 23 | 24 | /** 25 | * Return info on resource accessibility. 26 | */ 27 | AccessInfo getAccessInfo(RuleFilter filter); 28 | 29 | /** 30 | * info about admin authorization on a given workspace. 31 | * 32 | * Returned AccessInfo will always be ALLOW, with the computed adminRights. 33 | */ 34 | AccessInfo getAdminAuthorization(RuleFilter filter); 35 | 36 | /** 37 | * Return the unprocessed {@link Rule} list matching a given filter, sorted 38 | * by priority. 39 | *

40 | * Use {@link getAccessInfo(RuleFilter) getAccessInfo(RuleFilter)} 41 | * if you need the resulting coalesced access info. 42 | */ 43 | List getMatchingRules(RuleFilter filter); 44 | 45 | public AuthUser authorize(String username, String password); 46 | 47 | // ========================================================================== 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/UserAdminService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services; 7 | 8 | import org.geoserver.geofence.core.model.GSUser; 9 | import org.geoserver.geofence.services.dto.ShortUser; 10 | import org.geoserver.geofence.services.exception.BadRequestServiceEx; 11 | import org.geoserver.geofence.services.exception.NotFoundServiceEx; 12 | 13 | import java.util.List; 14 | 15 | 16 | /** 17 | * Operations on {@link GSUser GSUser}s. 18 | * 19 | * @author Emanuele Tajariol (etj at geo-solutions.it) 20 | */ 21 | public interface UserAdminService extends GetProviderService 22 | { 23 | 24 | // ========================================================================== 25 | // Basic operations 26 | 27 | long insert(GSUser user); 28 | 29 | long update(GSUser user) throws NotFoundServiceEx; 30 | 31 | boolean delete(long id) throws NotFoundServiceEx; 32 | 33 | /** 34 | * Retrieves basic info on Users.
35 | * If you need structured info (such as Groups), use the {@link #getFull(long)} method. 36 | * 37 | * @return Basic GSUser, with some info left unreferenced. 38 | * 39 | * @throws NotFoundServiceEx 40 | */ 41 | @Override 42 | GSUser get(long id) throws NotFoundServiceEx; 43 | GSUser getFull(String name) throws NotFoundServiceEx; 44 | 45 | long getCount(String nameLike); 46 | 47 | List getList(String nameLike, Integer page, Integer entries); 48 | 49 | List getFullList(String nameLike, Integer page, Integer entries) throws BadRequestServiceEx; 50 | List getFullList(String nameLike, Integer page, Integer entries, boolean fetchGroups) throws BadRequestServiceEx; 51 | } 52 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/UserGroupAdminService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services; 7 | 8 | import org.geoserver.geofence.core.model.UserGroup; 9 | import org.geoserver.geofence.services.dto.ShortGroup; 10 | import org.geoserver.geofence.services.exception.NotFoundServiceEx; 11 | 12 | import java.util.List; 13 | 14 | 15 | /** 16 | * Operations on {@link UserGroup UserGroup}s. 17 | * 18 | * @author Emanuele Tajariol (etj at geo-solutions.it) 19 | */ 20 | public interface UserGroupAdminService extends GetProviderService 21 | { 22 | 23 | // ========================================================================== 24 | // Basic operations 25 | 26 | long insert(ShortGroup group); 27 | 28 | long update(ShortGroup group) throws NotFoundServiceEx; 29 | 30 | boolean delete(long id) throws NotFoundServiceEx; 31 | 32 | @Override 33 | UserGroup get(long id) throws NotFoundServiceEx; 34 | UserGroup get(String name) throws NotFoundServiceEx; 35 | 36 | long getCount(String nameLike); 37 | 38 | List getList(String nameLike, Integer page, Integer entries); 39 | 40 | // List getFullList(String nameLike, Integer page, Integer entries); 41 | 42 | // ========================================================================== 43 | 44 | // public Map getCustomProps(Long id); 45 | 46 | // public void setCustomProps(Long id, Map props); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/dto/AuthUser.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.dto; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 12 | * @author ETj (etj at geo-solutions.it) 13 | */ 14 | public class AuthUser implements Serializable { 15 | 16 | public static enum Role { 17 | ADMIN, 18 | USER 19 | } 20 | 21 | private String name; 22 | private Role role; 23 | 24 | public AuthUser() { 25 | } 26 | 27 | public AuthUser(String name, Role role) { 28 | this.name = name; 29 | this.role = role; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public void setRole(Role role) { 37 | this.role = role; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public Role getRole() { 45 | return role; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "AuthUser["+name + ":"+ role + ']'; 51 | } 52 | 53 | @Override 54 | public int hashCode() { 55 | int hash = 3; 56 | hash = 79 * hash + (this.name != null ? this.name.hashCode() : 0); 57 | hash = 79 * hash + (this.role != null ? this.role.hashCode() : 0); 58 | return hash; 59 | } 60 | 61 | @Override 62 | public boolean equals(Object obj) { 63 | if (obj == null) { 64 | return false; 65 | } 66 | if (getClass() != obj.getClass()) { 67 | return false; 68 | } 69 | final AuthUser other = (AuthUser) obj; 70 | if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { 71 | return false; 72 | } 73 | if (this.role != other.role) { 74 | return false; 75 | } 76 | return true; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/dto/CatalogModeDTO.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.dto; 7 | 8 | /** 9 | * CatalogMode is the mode used in geoserver for a given layer. 10 | * 11 | * @author ETj (etj at geo-solutions.it) 12 | */ 13 | public enum CatalogModeDTO { 14 | HIDE, CHALLENGE, MIXED; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/dto/ShortInstance.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.dto; 7 | 8 | import org.geoserver.geofence.core.model.GSInstance; 9 | 10 | import java.io.Serializable; 11 | 12 | import javax.xml.bind.annotation.XmlRootElement; 13 | import javax.xml.bind.annotation.XmlType; 14 | 15 | /** 16 | * A compact representation of GSInstance useful in lists. 17 | * 18 | * @author Etj (etj at geo-solutions.it) 19 | */ 20 | @XmlRootElement(name = "GSInstance") 21 | @XmlType(propOrder = {"id", "name", "url", "description"}) 22 | public class ShortInstance implements Serializable { 23 | 24 | private long id; 25 | private String name; 26 | private String url; 27 | private String description; 28 | 29 | public ShortInstance() { 30 | } 31 | 32 | public ShortInstance(GSInstance i) { 33 | this.id = i.getId(); 34 | this.name = i.getName(); 35 | this.url = i.getBaseURL(); 36 | this.description = i.getDescription(); 37 | } 38 | 39 | public long getId() { 40 | return id; 41 | } 42 | 43 | public void setId(long id) { 44 | this.id = id; 45 | } 46 | 47 | public String getName() { 48 | return name; 49 | } 50 | 51 | public void setName(String name) { 52 | this.name = name; 53 | } 54 | 55 | public String getUrl() { 56 | return url; 57 | } 58 | 59 | public void setUrl(String url) { 60 | this.url = url; 61 | } 62 | 63 | public String getDescription() { 64 | return description; 65 | } 66 | 67 | public void setDescription(String description) { 68 | this.description = description; 69 | } 70 | 71 | 72 | @Override 73 | public String toString() { 74 | return getClass().getSimpleName() 75 | + "[id:" + id 76 | + " name:" + name 77 | + " url:" + url 78 | + ']'; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/dto/ShortUser.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.dto; 7 | 8 | import org.geoserver.geofence.core.model.GFUser; 9 | import org.geoserver.geofence.core.model.GSUser; 10 | 11 | import java.io.Serializable; 12 | 13 | 14 | /** 15 | * A compact representation of GSUser useful in lists. 16 | * 17 | * @author Etj (etj@geo-solutions.it) 18 | */ 19 | public class ShortUser implements Serializable 20 | { 21 | 22 | private static final long serialVersionUID = -24846270926852L; 23 | 24 | private Long id; 25 | 26 | private String name; 27 | 28 | public ShortUser() 29 | { 30 | } 31 | 32 | public ShortUser(GSUser user) 33 | { 34 | this.id = user.getId(); 35 | this.name = user.getName(); 36 | } 37 | 38 | public ShortUser(GFUser user) 39 | { 40 | this.id = user.getId(); 41 | this.name = user.getName(); 42 | } 43 | 44 | public Long getId() 45 | { 46 | return id; 47 | } 48 | 49 | public void setId(Long id) 50 | { 51 | this.id = id; 52 | } 53 | 54 | public String getName() 55 | { 56 | return name; 57 | } 58 | 59 | public void setName(String name) 60 | { 61 | this.name = name; 62 | } 63 | 64 | @Override 65 | public String toString() 66 | { 67 | return getClass().getSimpleName()+"[id:" + id + " name:" + name + ']'; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/exception/BadRequestServiceEx.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.exception; 7 | 8 | 9 | /** 10 | * 11 | * @author ETj (etj at geo-solutions.it) 12 | */ 13 | public class BadRequestServiceEx extends WebApplicationException 14 | { 15 | 16 | private String message; 17 | 18 | public BadRequestServiceEx(String message) 19 | { 20 | super(Response.Status.BAD_REQUEST); 21 | this.message = message; 22 | } 23 | 24 | @Override 25 | public String getMessage() 26 | { 27 | return message; 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/exception/InternalErrorServiceEx.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.exception; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public class InternalErrorServiceEx extends WebApplicationException 13 | { 14 | 15 | private String message; 16 | 17 | public InternalErrorServiceEx(String message) 18 | { 19 | super(Response.Status.BAD_REQUEST); 20 | this.message = message; 21 | } 22 | 23 | @Override 24 | public String getMessage() 25 | { 26 | return message; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/exception/NotFoundServiceEx.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.exception; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public class NotFoundServiceEx extends WebApplicationException 13 | { 14 | 15 | private String message; 16 | 17 | public NotFoundServiceEx(String message) 18 | { 19 | super(Response.Status.NOT_FOUND); 20 | this.message = message; 21 | } 22 | 23 | public NotFoundServiceEx(String message, Long id) 24 | { 25 | super(Response.Status.NOT_FOUND); 26 | this.message = message + " (id:" + id + ")"; 27 | } 28 | 29 | public NotFoundServiceEx(String message, String name) 30 | { 31 | super(Response.Status.NOT_FOUND); 32 | this.message = message + " (name:" + name + ")"; 33 | } 34 | 35 | @Override 36 | public String getMessage() 37 | { 38 | return message; 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/services/util/IPUtils.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.util; 7 | 8 | import java.util.regex.Pattern; 9 | 10 | /** 11 | * 12 | * @author ETj (etj at geo-solutions.it) 13 | */ 14 | public class IPUtils { 15 | private static final String IPV4_ADDRESS = "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})"; 16 | private static final String IPV6_STANDARD_ADDRESS = "(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}"; 17 | private static final String IPV6_COMPRESSED_ADDRESS = "((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)"; 18 | 19 | private static final String SLASH_FORMAT = "/(\\d{1,3})"; 20 | 21 | private static final Pattern[] ipAddressPatterns = new Pattern[] { 22 | Pattern.compile(IPV4_ADDRESS), 23 | Pattern.compile(IPV6_STANDARD_ADDRESS), 24 | Pattern.compile(IPV6_COMPRESSED_ADDRESS) 25 | }; 26 | 27 | private static final Pattern[] cidrPatterns = new Pattern[] { 28 | Pattern.compile(IPV4_ADDRESS + SLASH_FORMAT), 29 | Pattern.compile(IPV6_STANDARD_ADDRESS + SLASH_FORMAT), 30 | Pattern.compile(IPV6_COMPRESSED_ADDRESS + SLASH_FORMAT) 31 | }; 32 | 33 | 34 | public static boolean isAddressValid(String ipAddress) { 35 | return checkAllPatterns(ipAddress, ipAddressPatterns); 36 | } 37 | 38 | private static boolean checkAllPatterns(String ipAddress, Pattern[] patterns) { 39 | if(ipAddress == null) { 40 | return false; 41 | } 42 | for(Pattern pattern : patterns) { 43 | if(pattern.matcher(ipAddress).matches()) { 44 | return true; 45 | } 46 | } 47 | return false; 48 | } 49 | 50 | public static boolean isRangeValid(String ipAddressRange) { 51 | return checkAllPatterns(ipAddressRange, cidrPatterns); 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/main/java/org/geoserver/geofence/spi/UserResolver.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.spi; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * 12 | * @author ETj (etj at geo-solutions.it) 13 | */ 14 | public interface UserResolver { 15 | 16 | @Deprecated 17 | boolean existsUser(String username); 18 | 19 | @Deprecated 20 | boolean existsRole(String rolename); 21 | 22 | Set getRoles(String username); 23 | 24 | } -------------------------------------------------------------------------------- /src/services/core/services-api/src/test/java/org/geoserver/geofence/services/util/IPUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.services.util; 6 | 7 | import static org.junit.Assert.assertFalse; 8 | import static org.junit.Assert.assertTrue; 9 | 10 | import org.junit.Test; 11 | 12 | public class IPUtilsTest { 13 | @Test 14 | public void testIPv4() { 15 | assertTrue(IPUtils.isAddressValid("192.168.1.1")); 16 | assertTrue(IPUtils.isAddressValid("127.0.0.1")); 17 | assertFalse(IPUtils.isAddressValid("192.168.1.1.2")); 18 | 19 | assertTrue(IPUtils.isRangeValid("192.168.1.0/32")); 20 | assertTrue(IPUtils.isRangeValid("127.0.0.1/8")); 21 | assertFalse(IPUtils.isRangeValid("127.0.0.1/1111")); 22 | assertFalse(IPUtils.isRangeValid("127.0.0.1/32/2")); 23 | } 24 | 25 | @Test 26 | public void testIPv6() { 27 | assertTrue(IPUtils.isAddressValid("0:0:0:0:0:0:0:1")); 28 | assertTrue(IPUtils.isAddressValid("B012:a000:361:44:f87:11:0:0")); 29 | assertTrue(IPUtils.isAddressValid("::1")); 30 | 31 | assertFalse(IPUtils.isAddressValid("B012:a000:361:44:f87:11:0:g0")); 32 | assertFalse(IPUtils.isAddressValid("B012:a000:361:44:f87:11:0")); 33 | 34 | assertTrue(IPUtils.isRangeValid("0:0:0:0:0:0:0:1/32")); 35 | assertFalse(IPUtils.isRangeValid("0:0:0:0:0:0:0:1/32/1")); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/services/core/services-api/src/test/java/org/geoserver/geofence/services/util/RuleFilterTest.java: -------------------------------------------------------------------------------- 1 | package org.geoserver.geofence.services.util; 2 | 3 | import org.geoserver.geofence.services.dto.RuleFilter; 4 | import static org.junit.Assert.*; 5 | import org.junit.Test; 6 | 7 | /** 8 | * 9 | */ 10 | public class RuleFilterTest { 11 | @Test 12 | public void testRole() { 13 | RuleFilter f = new RuleFilter(); 14 | f.setRole("pippo"); 15 | assertEquals("pippo", f.getRole().getText()); 16 | 17 | f.setRole("a,b"); 18 | assertEquals("a,b", f.getRole().getText()); 19 | 20 | f.setRole("b,a"); 21 | assertEquals("a,b", f.getRole().getText()); 22 | 23 | f.setRole("a, b"); 24 | assertEquals("a,b", f.getRole().getText()); 25 | 26 | f.setRole(" b , a "); 27 | assertEquals("a,b", f.getRole().getText()); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/services/core/services-impl/src/main/java/org/geoserver/geofence/services/AuthorizationServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services; 7 | 8 | import org.geoserver.geofence.core.model.GSUser; 9 | import org.geoserver.geofence.core.dao.GSUserDAO; 10 | import org.geoserver.geofence.services.dto.AuthUser; 11 | 12 | 13 | import org.apache.logging.log4j.LogManager; 14 | import org.apache.logging.log4j.Logger; 15 | 16 | /** 17 | * 18 | * @author ETj (etj at geo-solutions.it) 19 | */ 20 | public class AuthorizationServiceImpl implements AuthorizationService { 21 | 22 | private final static Logger LOGGER = LogManager.getLogger(AuthorizationServiceImpl.class); 23 | 24 | private GSUserDAO userDAO; 25 | 26 | @Override 27 | public AuthUser authorize(String username, String password) { 28 | GSUser user = userDAO.getFull(username); 29 | if(user == null) { 30 | LOGGER.debug("User not found " + username); 31 | return null; 32 | } 33 | if(! user.getPassword().equals(password)) { 34 | LOGGER.debug("Bad pw for user " + username); 35 | return null; 36 | } 37 | 38 | return new AuthUser(username, user.isAdmin() ? AuthUser.Role.ADMIN : AuthUser.Role.USER); 39 | } 40 | 41 | public void setGsUserDAO(GSUserDAO userDAO) { 42 | this.userDAO = userDAO; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/services/core/services-impl/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/services/core/services-impl/src/test/java/org/geoserver/test/AbstractSpringContextTest.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.test; 7 | 8 | import junit.framework.TestCase; 9 | 10 | import org.apache.logging.log4j.LogManager; 11 | import org.apache.logging.log4j.Logger; 12 | 13 | import org.springframework.context.support.ClassPathXmlApplicationContext; 14 | 15 | /** 16 | * Base class for tests with a spring context loaded from the classpath. 17 | * 18 | * @author Nate Sammons 19 | */ 20 | public abstract class AbstractSpringContextTest extends TestCase { 21 | protected Logger logger = LogManager.getLogger(getClass()); 22 | 23 | protected ClassPathXmlApplicationContext context = null; 24 | 25 | /** 26 | * Get the filename to use for this context. 27 | */ 28 | protected abstract String[] getContextFilenames(); 29 | 30 | @Override 31 | protected void setUp() throws Exception { 32 | super.setUp(); 33 | 34 | context = new ClassPathXmlApplicationContext(getContextFilenames()); 35 | logger.info("Built test context: " + context); 36 | } 37 | 38 | @Override 39 | protected void tearDown() throws Exception { 40 | super.tearDown(); 41 | 42 | logger.info("Closing test context"); 43 | context.close(); 44 | context = null; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/services/core/services-impl/src/test/resources/geofence-datasource-ovr.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=update 7 | geofenceVendorAdapter.generateDdl=true 8 | geofenceVendorAdapter.showSql=false 9 | -------------------------------------------------------------------------------- /src/services/core/services-impl/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/services/core/webtest/src/main/resources/META-INF/cxf/org.apache.cxf.Logger: -------------------------------------------------------------------------------- 1 | org.apache.cxf.common.logging.Log4jLogger 2 | -------------------------------------------------------------------------------- /src/services/core/webtest/src/main/resources/geofence-datasource-ovr.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=create-drop 7 | geofenceVendorAdapter.generateDdl=true 8 | geofenceVendorAdapter.showSql=false 9 | -------------------------------------------------------------------------------- /src/services/core/webtest/src/main/resources/geofence-datasource.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | #geofenceDataSource.schema=geofence_test -------------------------------------------------------------------------------- /src/services/core/webtest/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/services/core/webtest/src/main/webapp/WEB-INF/remoting-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/services/core/webtest/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 15 | 16 | 17 | contextConfigLocation 18 | classpath*:applicationContext.xml 19 | 20 | 21 | 22 | log4jConfiguration 23 | log4j2.xml 24 | 25 | 26 | 27 | 28 | 29 | org.springframework.web.context.ContextLoaderListener 30 | 31 | 32 | 33 | 34 | CXFServlet 35 | org.apache.cxf.transport.servlet.CXFServlet 36 | 37 | 38 | 39 | CXFServlet 40 | /serv/* 41 | 42 | 43 | 44 | 45 | remoting 46 | org.springframework.web.servlet.DispatcherServlet 47 | 1 48 | 49 | 50 | 51 | remoting 52 | /remoting/* 53 | 54 | 55 | 56 | 57 | Application.html 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/services/modules/generic-api/src/main/java/org/geoserver/geofence/api/AuthProvider.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.api; 7 | 8 | import org.geoserver.geofence.api.dto.GrantedAuths; 9 | import org.geoserver.geofence.api.exception.AuthException; 10 | 11 | /** 12 | * This interface should be provided by classes that bridges toward and external auth source.
13 | * Let's say we have and external LDAP service, we may want to forward login requests to it. 14 | * 15 | * @author Emanuele Tajariol (etj at geo-solutions.it) 16 | */ 17 | public interface AuthProvider { 18 | GrantedAuths login(String username, String password, String pwFromDB) throws AuthException; 19 | 20 | void logout(String token); 21 | } 22 | -------------------------------------------------------------------------------- /src/services/modules/generic-api/src/main/java/org/geoserver/geofence/api/UserRegistry.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.api; 7 | 8 | import org.geoserver.geofence.api.dto.RegisteredUser; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * 14 | * @author Emanuele Tajariol (etj at geo-solutions.it) 15 | */ 16 | public interface UserRegistry { 17 | 18 | List getUsers(String nameLike, int page, int entries); 19 | 20 | long getUsersCount(String nameLike); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/services/modules/generic-api/src/main/java/org/geoserver/geofence/api/dto/Authority.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.api.dto; 7 | 8 | /** 9 | * @author etj 10 | */ 11 | public enum Authority { 12 | /** 13 | * Authorization to log into the application 14 | */ 15 | LOGIN 16 | 17 | /** 18 | * Authorization to perform remote calls 19 | */ 20 | , REMOTE 21 | 22 | ; 23 | } 24 | -------------------------------------------------------------------------------- /src/services/modules/generic-api/src/main/java/org/geoserver/geofence/api/dto/GrantedAuths.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.api.dto; 7 | 8 | import java.io.Serializable; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @author 14 | * 15 | */ 16 | public class GrantedAuths implements Serializable { 17 | 18 | private List auths; 19 | 20 | public GrantedAuths() { 21 | if (auths == null) 22 | auths = new ArrayList(); 23 | } 24 | 25 | /** 26 | * @param authorities 27 | * the authorities to set 28 | */ 29 | public void setAuthorities(List authorities) { 30 | this.auths = authorities; 31 | } 32 | 33 | /** 34 | * @return the authorities 35 | */ 36 | public List getAuthorities() { 37 | return auths; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/services/modules/generic-api/src/main/java/org/geoserver/geofence/api/dto/RegisteredUser.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.api.dto; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public class RegisteredUser { 13 | 14 | protected String id; 15 | 16 | protected String username; 17 | 18 | public String getId() { 19 | return id; 20 | } 21 | 22 | public void setId(String id) { 23 | this.id = id; 24 | } 25 | 26 | public String getUsername() { 27 | return username; 28 | } 29 | 30 | public void setUsername(String username) { 31 | this.username = username; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return getClass().getSimpleName() + "[" + "id:" + id + " userName:" + username + ']'; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/services/modules/generic-api/src/main/java/org/geoserver/geofence/api/exception/AuthException.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.api.exception; 7 | 8 | import javax.xml.ws.WebFault; 9 | 10 | /** 11 | * 12 | * @author ETj (etj at geo-solutions.it) 13 | */ 14 | @WebFault(name = "AuthFault", faultBean = "org.geoserver.geofence.login.exception.AuthException") 15 | public class AuthException extends RuntimeException { 16 | 17 | public AuthException(Throwable cause) { 18 | super(cause); 19 | } 20 | 21 | public AuthException(String message, Throwable cause) { 22 | super(message, cause); 23 | } 24 | 25 | public AuthException(String message) { 26 | super(message); 27 | } 28 | 29 | public AuthException() { 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/services/modules/ldap/src/main/java/org/geoserver/geofence/ldap/LdapAttributesMapper.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.ldap; 6 | 7 | import org.springframework.ldap.core.AttributesMapper; 8 | 9 | /** 10 | * @author "Mauro Bartolomeoli - mauro.bartolomeoli@geo-solutions.it" 11 | */ 12 | public interface LdapAttributesMapper extends AttributesMapper 13 | { 14 | /** 15 | * Maps a DAO attribute to the LDAP one. 16 | * 17 | * @param attributeName 18 | * @return 19 | */ 20 | public String getLdapAttribute(String attributeName); 21 | } 22 | -------------------------------------------------------------------------------- /src/services/modules/ldap/src/main/java/org/geoserver/geofence/ldap/dao/impl/GSUserAttributesMapper.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.ldap.dao.impl; 6 | 7 | import org.geoserver.geofence.core.model.GSUser; 8 | 9 | import java.util.Collections; 10 | 11 | import javax.naming.NamingException; 12 | import javax.naming.directory.Attribute; 13 | import javax.naming.directory.Attributes; 14 | import org.apache.commons.lang.StringUtils; 15 | import org.apache.logging.log4j.LogManager; 16 | import org.apache.logging.log4j.Logger; 17 | 18 | /** 19 | * AttributeMapper for GSUser objects. 20 | * 21 | * @author "Mauro Bartolomeoli - mauro.bartolomeoli@geo-solutions.it" 22 | * @author Emanuele Tajariol (etj at geo-solutions.it) 23 | */ 24 | public class GSUserAttributesMapper extends BaseAttributesMapper 25 | { 26 | private static final Logger LOGGER = LogManager.getLogger(GSUserAttributesMapper.class); 27 | 28 | @Override 29 | public Object mapFromAttributes(Attributes attrs) throws NamingException 30 | { 31 | GSUser user = new GSUser(); 32 | String id = getAttribute(attrs, "id"); 33 | if(StringUtils.isBlank(id)) { 34 | LOGGER.warn("Empty id for GSUser"); 35 | if(LOGGER.isDebugEnabled()) { 36 | for(Object oa: Collections.list(attrs.getAll())) { 37 | Attribute a = (Attribute)oa; 38 | LOGGER.debug("---> " + a); 39 | } 40 | } 41 | } 42 | user.setExtId(id); 43 | user.setName(getAttribute(attrs, "username")); 44 | user.setEmailAddress(getAttribute(attrs, "email")); 45 | user.setEnabled(true); 46 | user.setFullName(getAttribute(attrs, "name") + " " + getAttribute(attrs, "surname")); 47 | user.setPassword(getAttribute(attrs, "password")); 48 | 49 | return user; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/services/modules/ldap/src/main/java/org/geoserver/geofence/ldap/dao/impl/UserGroupAttributesMapper.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.ldap.dao.impl; 6 | 7 | import org.geoserver.geofence.core.model.UserGroup; 8 | 9 | import java.util.Collections; 10 | 11 | import javax.naming.NamingException; 12 | import javax.naming.directory.Attribute; 13 | import javax.naming.directory.Attributes; 14 | import org.apache.commons.lang.StringUtils; 15 | import org.apache.logging.log4j.LogManager; 16 | import org.apache.logging.log4j.Logger; 17 | 18 | /** 19 | * AttributeMapper for UserGroup objects. 20 | * 21 | * @author "Mauro Bartolomeoli - mauro.bartolomeoli@geo-solutions.it" 22 | * @author Emanuele Tajariol (etj at geo-solutions.it) 23 | */ 24 | public class UserGroupAttributesMapper extends BaseAttributesMapper 25 | { 26 | private static final Logger LOGGER = LogManager.getLogger(UserGroupAttributesMapper.class); 27 | 28 | @Override 29 | public Object mapFromAttributes(Attributes attrs) throws NamingException 30 | { 31 | UserGroup group = new UserGroup(); 32 | 33 | String id = getAttribute(attrs, "id"); 34 | if(StringUtils.isBlank(id)) { 35 | LOGGER.warn("Empty id for UserGroup"); 36 | if(LOGGER.isDebugEnabled()) { 37 | for(Object oa: Collections.list(attrs.getAll())) { 38 | Attribute a = (Attribute)oa; 39 | LOGGER.debug("---> " + a); 40 | } 41 | } 42 | } 43 | group.setExtId(id); 44 | group.setName(getAttribute(attrs, "groupname")); 45 | group.setEnabled(true); 46 | 47 | return group; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/services/modules/ldap/src/main/java/org/geoserver/geofence/ldap/utils/LdapUtils.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.ldap.utils; 6 | 7 | import org.geoserver.geofence.ldap.LdapAttributesMapper; 8 | 9 | import org.springframework.ldap.core.AttributesMapper; 10 | 11 | import org.apache.logging.log4j.LogManager; 12 | import org.apache.logging.log4j.Logger; 13 | 14 | /** 15 | * @author "Mauro Bartolomeoli - mauro.bartolomeoli@geo-solutions.it" 16 | */ 17 | public class LdapUtils 18 | { 19 | private static Logger LOGGER = LogManager.getLogger(LdapUtils.class); 20 | 21 | public static String createLDAPFilterEqual(String propertyName, String value, AttributesMapper mapper) 22 | { 23 | if (mapper instanceof LdapAttributesMapper) { 24 | propertyName = ((LdapAttributesMapper) mapper) 25 | .getLdapAttribute(propertyName); 26 | } 27 | return propertyName + "=" + value; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/services/modules/ldap/src/test/resources/geofence-datasource-ovr.properties: -------------------------------------------------------------------------------- 1 | # (c) 2017 Open Source Geospatial Foundation - all rights reserved 2 | # This code is licensed under the GPL 2.0 license, available at the root application directory. 3 | 4 | # Some DB param overrides 5 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=update 6 | geofenceVendorAdapter.generateDdl=true 7 | geofenceVendorAdapter.showSql=false 8 | 9 | # Switch the DAOs from DB to LDAP 10 | geofence_dao_registry.selectedType = LDAP 11 | 12 | # LDAP directory connection params 13 | geofenceLdapSource.url = ldap://localhost:10389 14 | geofenceLdapSource.base = dc=example,dc=com 15 | geofenceLdapSource.userDn = uid=admin,ou=system 16 | geofenceLdapSource.password = secret 17 | 18 | # User filters 19 | gsUserDAO_LDAP.searchBase = ou=People 20 | gsUserDAO_LDAP.searchFilter = objectClass=inetOrgPerson 21 | #gsUserDAO_LDAP.userDn = uid=%s,ou=People 22 | #gsUserDAO_LDAP.userDn = cn=%s 23 | #gsUserDAO_LDAP.groupsBase = ou=Groups 24 | 25 | # Group filters 26 | userGroupDAO_LDAP.searchBase = ou=Groups 27 | userGroupDAO_LDAP.searchFilter = objectClass=groupOfNames 28 | 29 | # Mapping LDAP user attributes to internal 30 | geofenceLdapUserMapper.map[id] = distinguishedName 31 | geofenceLdapUserMapper.map[username] = cn 32 | geofenceLdapUserMapper.map[email] = mail 33 | geofenceLdapUserMapper.map[name] = givenName 34 | geofenceLdapUserMapper.map[surname] = sn 35 | geofenceLdapUserMapper.map[password] = userPassword 36 | # optional searchfilter for userobjects other than member 37 | #geofenceLdapUserMapper.map[memberSearchFilter] = uniqueMember=uid={0},ou=users,ou=mapeo,dc=eodata,dc=vito,dc=be 38 | 39 | # Mapping LDAP group attributes to internal 40 | geofenceLdapGroupMapper.map[id] = distinguishedName 41 | geofenceLdapGroupMapper.map[groupname] = cn 42 | geofenceLdapGroupMapper.map[member] = member 43 | -------------------------------------------------------------------------------- /src/services/modules/ldap/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/services/modules/login/api/src/main/java/org/geoserver/geofence/login/LoginService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.login; 7 | 8 | import org.geoserver.geofence.api.dto.GrantedAuths; 9 | import org.geoserver.geofence.api.exception.AuthException; 10 | 11 | import javax.jws.WebParam; 12 | import javax.jws.WebResult; 13 | import javax.jws.WebService; 14 | 15 | /** 16 | * 17 | * @author Emanuele Tajariol (etj at geo-solutions.it) 18 | */ 19 | @WebService(name = "LoginService", targetNamespace = "http://www.geo-solutions.it/org.geoserver.geofence.login") 20 | public interface LoginService { 21 | 22 | @WebResult(name = "token") 23 | String login(@WebParam(name = "username") String username, 24 | @WebParam(name = "password") String password, String pwFromDb) throws AuthException; 25 | 26 | GrantedAuths getGrantedAuthorities(@WebParam(name = "token") String token); 27 | 28 | void logout(@WebParam(name = "token") String token); 29 | } 30 | -------------------------------------------------------------------------------- /src/services/modules/login/impl/src/main/java/org/geoserver/geofence/login/util/GrantAll.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.login.util; 7 | 8 | import java.util.Arrays; 9 | 10 | import org.geoserver.geofence.api.AuthProvider; 11 | import org.geoserver.geofence.api.dto.Authority; 12 | import org.geoserver.geofence.api.dto.GrantedAuths; 13 | import org.geoserver.geofence.api.exception.AuthException; 14 | 15 | import org.apache.logging.log4j.LogManager; 16 | import org.apache.logging.log4j.Logger; 17 | 18 | 19 | /** 20 | * A dummy AuthProvider which grants all auths to every request. 21 | * 22 | * TODO: this class used to provide a GrantAll grant, but since long an MD5 check 23 | * was implemented here. Naming should be fixed 24 | * 25 | * @author ETj (etj at geo-solutions.it) 26 | */ 27 | public class GrantAll implements AuthProvider { 28 | 29 | private static final Logger LOGGER = LogManager.getLogger(GrantAll.class); 30 | 31 | @Override 32 | public GrantedAuths login(String username, String password, String pwFromDb) throws AuthException { 33 | // allow auth to anybody 34 | LOGGER.warn("Login request from '" + username + "'"); 35 | 36 | GrantedAuths ga = new GrantedAuths(); 37 | String hashedPw = MD5Util.getHash(password); 38 | 39 | LOGGER.info("hashedPw: " + hashedPw); 40 | 41 | if (hashedPw.equals(pwFromDb)) { 42 | ga.setAuthorities(Arrays.asList(Authority.values())); 43 | } else { 44 | ga.setAuthorities(Arrays.asList(Authority.REMOTE)); 45 | } 46 | 47 | return ga; 48 | } 49 | 50 | @Override 51 | public void logout(String token) { 52 | // nothing to do 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/services/modules/login/impl/src/main/java/org/geoserver/geofence/login/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.login.util; 7 | 8 | import org.geoserver.geofence.api.exception.AuthException; 9 | import java.io.UnsupportedEncodingException; 10 | import java.security.MessageDigest; 11 | import java.security.NoSuchAlgorithmException; 12 | import org.apache.logging.log4j.LogManager; 13 | import org.apache.logging.log4j.Logger; 14 | 15 | /** 16 | * 17 | * @author ETj (etj at geo-solutions.it) 18 | */ 19 | public class MD5Util { 20 | private static final Logger LOGGER = LogManager.getLogger(MD5Util.class); 21 | 22 | public static String getHash(String password) throws AuthException { 23 | byte[] passwordByteArr; 24 | try { 25 | passwordByteArr = password.getBytes("UTF-8"); 26 | } catch (UnsupportedEncodingException e) { 27 | LOGGER.error(e.getLocalizedMessage(), e); 28 | throw new AuthException(e.getLocalizedMessage(), e); 29 | } 30 | MessageDigest md; 31 | try { 32 | md = MessageDigest.getInstance("MD5"); 33 | md.reset(); 34 | } catch (NoSuchAlgorithmException e) { 35 | LOGGER.error(e.getLocalizedMessage(), e); 36 | throw new AuthException(e.getLocalizedMessage(), e); 37 | } 38 | byte[] thedigest = md.digest(passwordByteArr); 39 | StringBuilder hexString = new StringBuilder(); 40 | for (int i = 0; i < thedigest.length; i++) { 41 | String hexByte = Integer.toHexString(0xFF & thedigest[i]); 42 | if(hexByte.length()==1) { 43 | hexString.append('0'); 44 | } 45 | hexString.append(hexByte); 46 | } 47 | return hexString.toString(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/services/modules/login/impl/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/services/modules/login/impl/src/test/java/org/geoserver/geofence/login/util/MD5UtilTest.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | package org.geoserver.geofence.login.util; 6 | 7 | import org.junit.Test; 8 | import static org.junit.Assert.*; 9 | 10 | /** 11 | * 12 | * @author ETj (etj at geo-solutions.it) 13 | */ 14 | public class MD5UtilTest { 15 | 16 | /** 17 | * Test of getHash method, of class MD5Util. 18 | */ 19 | @Test 20 | public void testGetHash() { 21 | System.out.println("getHash"); 22 | String password = "test"; 23 | String expResult = "098f6bcd4621d373cade4e832627b4f6"; 24 | String result = MD5Util.getHash(password); 25 | assertEquals(expResult, result); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/services/modules/login/impl/src/test/resources/applicationContext-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | -------------------------------------------------------------------------------- /src/services/modules/login/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 4.0.0 13 | 14 | 15 | org.geoserver.geofence 16 | geofence-modules 17 | 3.8-SNAPSHOT 18 | 19 | 20 | org.geoserver.geofence 21 | geofence-login-parent 22 | pom 23 | GeoFence - Modules - Login 24 | 25 | 26 | api 27 | impl 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/services/modules/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 4.0.0 13 | 14 | 15 | org.geoserver.geofence 16 | geofence-root 17 | 3.8-SNAPSHOT 18 | 19 | 20 | org.geoserver.geofence 21 | geofence-modules 22 | pom 23 | GeoFence - Modules - 0 Root 24 | 25 | 26 | login 27 | generic-api 28 | rest 29 | ldap 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/RESTBatchService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest; 7 | 8 | import org.geoserver.geofence.services.rest.exception.BadRequestRestEx; 9 | import org.geoserver.geofence.services.rest.exception.InternalErrorRestEx; 10 | import org.geoserver.geofence.services.rest.exception.NotFoundRestEx; 11 | import org.geoserver.geofence.services.rest.model.RESTBatch; 12 | 13 | import javax.ws.rs.Consumes; 14 | import javax.ws.rs.POST; 15 | import javax.ws.rs.Path; 16 | import javax.ws.rs.core.MediaType; 17 | import javax.ws.rs.core.Response; 18 | 19 | import org.apache.cxf.jaxrs.ext.multipart.Multipart; 20 | 21 | 22 | /** 23 | * 24 | * @author Emanuele Tajariol (etj at geo-solutions.it) 25 | */ 26 | 27 | @Path("/") 28 | public interface RESTBatchService 29 | { 30 | @POST 31 | @Path("/exec") 32 | @Consumes({MediaType.APPLICATION_XML, MediaType.TEXT_XML}) 33 | Response exec(@Multipart("batch")RESTBatch batch) throws BadRequestRestEx, NotFoundRestEx, InternalErrorRestEx; 34 | 35 | /** 36 | * Similar to exec, but not transaction. 37 | * Used internally. 38 | */ 39 | void runBatch(RESTBatch batch) throws BadRequestRestEx, NotFoundRestEx, InternalErrorRestEx; 40 | } 41 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/exception/BadRequestRestEx.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.exception; 7 | 8 | import javax.ws.rs.core.Response; 9 | import javax.ws.rs.core.Response.Status; 10 | 11 | /** 12 | * 13 | * @author ETj (etj at geo-solutions.it) 14 | */ 15 | public class BadRequestRestEx extends GeoFenceRestEx { 16 | 17 | /** 18 | * The Constant serialVersionUID. 19 | */ 20 | private static final long serialVersionUID = -2585698525010604674L; 21 | 22 | public BadRequestRestEx(String message) { 23 | super(message, Response.status(Status.BAD_REQUEST).type("text/plain").entity(message).build()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/exception/ConflictRestEx.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.exception; 7 | 8 | import javax.ws.rs.core.Response; 9 | import javax.ws.rs.core.Response.Status; 10 | 11 | /** 12 | * 13 | * @author ETj (etj at geo-solutions.it) 14 | */ 15 | public class ConflictRestEx extends GeoFenceRestEx { 16 | 17 | public ConflictRestEx(String message) { 18 | super(message, Response.status(Status.CONFLICT).type("text/plain").entity(message).build()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/exception/GeoFenceRestEx.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.exception; 7 | 8 | import javax.ws.rs.WebApplicationException; 9 | import javax.ws.rs.core.Response; 10 | 11 | /** 12 | * Used as a catchall when forwarding exceptions 13 | * 14 | * @author ETj (etj at geo-solutions.it) 15 | */ 16 | public abstract class GeoFenceRestEx extends WebApplicationException { 17 | 18 | private String message; 19 | 20 | public GeoFenceRestEx(String message, Response response) { 21 | super(response); 22 | this.message = message; 23 | } 24 | 25 | @Override 26 | public String getMessage() { 27 | return message; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/exception/InternalErrorRestEx.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.exception; 7 | 8 | import javax.ws.rs.core.Response; 9 | import javax.ws.rs.core.Response.Status; 10 | 11 | /** 12 | * 13 | * @author ETj (etj at geo-solutions.it) 14 | */ 15 | public class InternalErrorRestEx extends GeoFenceRestEx { 16 | 17 | /** 18 | * The Constant serialVersionUID. 19 | */ 20 | private static final long serialVersionUID = 9014519381293787498L; 21 | 22 | public InternalErrorRestEx(String message) { 23 | super(message, Response.status(Status.INTERNAL_SERVER_ERROR).type("text/plain").entity(message).build()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/exception/NotFoundRestEx.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.exception; 7 | 8 | import javax.ws.rs.core.Response; 9 | import javax.ws.rs.core.Response.Status; 10 | 11 | /** 12 | * 13 | * @author ETj (etj at geo-solutions.it) 14 | */ 15 | public class NotFoundRestEx extends GeoFenceRestEx { 16 | 17 | /** 18 | * The Constant serialVersionUID. 19 | */ 20 | private static final long serialVersionUID = 1263563388095079971L; 21 | 22 | public NotFoundRestEx(String message) { 23 | super(message, Response.status(Status.NOT_FOUND).type("text/plain").entity(message).build()); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/AbstractRESTPayload.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import java.io.Serializable; 9 | 10 | import javax.xml.bind.annotation.XmlType; 11 | 12 | /** 13 | * A compact representation of UserGroup holding only the insertable/updatadable fields 14 | * 15 | * @author Etj (etj at geo-solutions.it) 16 | */ 17 | @XmlType 18 | abstract public class AbstractRESTPayload implements Serializable { 19 | 20 | protected AbstractRESTPayload() { 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTBatch.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import java.util.LinkedList; 9 | import java.util.List; 10 | 11 | import javax.xml.bind.annotation.XmlElement; 12 | import javax.xml.bind.annotation.XmlRootElement; 13 | 14 | /** 15 | * 16 | * @author ETj (etj at geo-solutions.it) 17 | */ 18 | @XmlRootElement(name = "batch") 19 | public class RESTBatch { 20 | 21 | private List list; 22 | 23 | public RESTBatch() { 24 | list = new LinkedList(); 25 | } 26 | 27 | @XmlElement(name = "operation") 28 | public List getList() { 29 | return list; 30 | } 31 | 32 | public void setList(List list) { 33 | this.list = list; 34 | } 35 | 36 | public void add(RESTBatchOperation op) { 37 | list.add(op); 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return getClass().getSimpleName() + "[" + list.size() + " ops]"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTInputGroup.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import javax.xml.bind.annotation.XmlAttribute; 9 | import javax.xml.bind.annotation.XmlRootElement; 10 | import javax.xml.bind.annotation.XmlType; 11 | 12 | /** 13 | * A compact representation of UserGroup holding only the insertable/updatadable fields 14 | * 15 | * @author Etj (etj at geo-solutions.it) 16 | */ 17 | @XmlRootElement(name = "userGroup") 18 | @XmlType(name="Group", propOrder = {"extId", "name"}) 19 | public class RESTInputGroup extends AbstractRESTPayload { 20 | 21 | private static final long serialVersionUID = -8410646966443187827L; 22 | private String name; 23 | private String extId; 24 | private Boolean enabled; 25 | 26 | public RESTInputGroup() { 27 | } 28 | 29 | @XmlAttribute(name = "enabled") 30 | public Boolean isEnabled() { 31 | return enabled; 32 | } 33 | 34 | public void setEnabled(Boolean enabled) { 35 | this.enabled = enabled; 36 | } 37 | 38 | public String getExtId() { 39 | return extId; 40 | } 41 | 42 | public void setExtId(String extId) { 43 | this.extId = extId; 44 | } 45 | 46 | public String getName() { 47 | return name; 48 | } 49 | 50 | public void setName(String name) { 51 | this.name = name; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | return getClass().getSimpleName() 57 | + "[" 58 | + (extId!=null? " extid=" + extId : "") 59 | + (name != null? " name=" + name : "") 60 | + (enabled != null? (enabled? " enabled" : " disabled") : "") 61 | + ']'; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTOutputAdminRuleList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Iterator; 10 | import java.util.List; 11 | 12 | import javax.xml.bind.annotation.XmlElement; 13 | import javax.xml.bind.annotation.XmlRootElement; 14 | 15 | /** 16 | * 17 | * @author ETj (etj at geo-solutions.it) 18 | */ 19 | @XmlRootElement(name = "AdminRuleList") 20 | public class RESTOutputAdminRuleList implements Iterable{ 21 | 22 | private List list; 23 | 24 | public RESTOutputAdminRuleList() { 25 | this(10); 26 | } 27 | 28 | public RESTOutputAdminRuleList(int initialCapacity) { 29 | list = new ArrayList(initialCapacity); 30 | } 31 | 32 | @XmlElement(name = "adminrule") 33 | public List getList() { 34 | return list; 35 | } 36 | 37 | public void setList(List userList) { 38 | this.list = userList; 39 | } 40 | 41 | public void add(RESTOutputAdminRule rule) { 42 | list.add(rule); 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return getClass().getSimpleName() + "[" + list.size() + " adminrules]"; 48 | } 49 | 50 | @Override 51 | public Iterator iterator() { 52 | return list.iterator(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTOutputGroup.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import java.io.Serializable; 9 | 10 | import javax.xml.bind.annotation.XmlRootElement; 11 | 12 | /** 13 | * A compact representation of UserGroup holding only the insertable/updatadable fields 14 | * 15 | * @author Etj (etj at geo-solutions.it) 16 | */ 17 | @XmlRootElement(name = "UserGroup") 18 | public class RESTOutputGroup implements Serializable { 19 | 20 | private Long id; 21 | private String name; 22 | private String extId; 23 | private Boolean enabled; 24 | 25 | public RESTOutputGroup() { 26 | } 27 | 28 | public Long getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Long id) { 33 | this.id = id; 34 | } 35 | 36 | public Boolean getEnabled() { 37 | return enabled; 38 | } 39 | 40 | public void setEnabled(Boolean enabled) { 41 | this.enabled = enabled; 42 | } 43 | 44 | public String getExtId() { 45 | return extId; 46 | } 47 | 48 | public void setExtId(String extId) { 49 | this.extId = extId; 50 | } 51 | 52 | public String getName() { 53 | return name; 54 | } 55 | 56 | public void setName(String name) { 57 | this.name = name; 58 | } 59 | 60 | @Override 61 | public String toString() { 62 | return getClass().getSimpleName() 63 | + "[id:" + id 64 | + (extId!=null? " extid=" + extId : "") 65 | + " name=" + name 66 | + (enabled? "" : "disabled") 67 | + ']'; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTOutputRuleList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Iterator; 10 | import java.util.List; 11 | 12 | import javax.xml.bind.annotation.XmlElement; 13 | import javax.xml.bind.annotation.XmlRootElement; 14 | 15 | /** 16 | * 17 | * @author ETj (etj at geo-solutions.it) 18 | */ 19 | @XmlRootElement(name = "RuleList") 20 | public class RESTOutputRuleList implements Iterable{ 21 | 22 | private List list; 23 | 24 | public RESTOutputRuleList() { 25 | this(10); 26 | } 27 | 28 | public RESTOutputRuleList(int initialCapacity) { 29 | list = new ArrayList(initialCapacity); 30 | } 31 | 32 | @XmlElement(name = "rule") 33 | public List getList() { 34 | return list; 35 | } 36 | 37 | public void setList(List userList) { 38 | this.list = userList; 39 | } 40 | 41 | public void add(RESTOutputRule user) { 42 | list.add(user); 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return getClass().getSimpleName() + "[" + list.size() + " users]"; 48 | } 49 | 50 | @Override 51 | public Iterator iterator() { 52 | return list.iterator(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTRulePosition.java: -------------------------------------------------------------------------------- 1 | /* (c) 2015 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import javax.xml.bind.annotation.XmlAttribute; 9 | 10 | public class RESTRulePosition { 11 | 12 | public enum RulePosition { 13 | 14 | fixedPriority, 15 | offsetFromTop, 16 | offsetFromBottom 17 | } 18 | 19 | private RulePosition position; 20 | private long value; 21 | 22 | public RESTRulePosition() { 23 | } 24 | 25 | public RESTRulePosition(RulePosition position, long value) { 26 | this.position = position; 27 | this.value = value; 28 | } 29 | 30 | @XmlAttribute 31 | public RulePosition getPosition() { 32 | return position; 33 | } 34 | 35 | public void setPosition(RulePosition position) { 36 | this.position = position; 37 | } 38 | 39 | @XmlAttribute 40 | public long getValue() { 41 | return value; 42 | } 43 | 44 | public void setValue(long value) { 45 | this.value = value; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTShortInstanceList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import org.geoserver.geofence.services.dto.ShortInstance; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Iterator; 12 | import java.util.List; 13 | 14 | import javax.xml.bind.annotation.XmlElement; 15 | import javax.xml.bind.annotation.XmlRootElement; 16 | 17 | /** 18 | * 19 | * @author ETj (etj at geo-solutions.it) 20 | */ 21 | @XmlRootElement(name = "GSInstanceList") 22 | public class RESTShortInstanceList implements Iterable { 23 | 24 | private List list; 25 | 26 | public RESTShortInstanceList() { 27 | this(10); 28 | } 29 | 30 | public RESTShortInstanceList(List list) { 31 | this.list = list; 32 | } 33 | 34 | public RESTShortInstanceList(int initialCapacity) { 35 | list = new ArrayList(initialCapacity); 36 | } 37 | 38 | @XmlElement(name = "Instance") 39 | public List getList() { 40 | return list; 41 | } 42 | 43 | public void setList(List list) { 44 | this.list = list; 45 | } 46 | 47 | public void add(ShortInstance instance) { 48 | list.add(instance); 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return getClass().getSimpleName() + "[" + list.size() + " gs instances]"; 54 | } 55 | 56 | @Override 57 | public Iterator iterator() { 58 | return list.iterator(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTShortUser.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import javax.xml.bind.annotation.XmlAttribute; 9 | import javax.xml.bind.annotation.XmlElement; 10 | import javax.xml.bind.annotation.XmlRootElement; 11 | import javax.xml.bind.annotation.XmlType; 12 | 13 | /** 14 | * 15 | * @author ETj (etj at geo-solutions.it) 16 | */ 17 | @XmlRootElement(name = "ShortUser") 18 | @XmlType(propOrder = {"id", "extId", "userName"}) 19 | public class RESTShortUser { 20 | 21 | private Long id; 22 | private String extId; 23 | private String userName; 24 | private boolean enabled; 25 | 26 | public Long getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | // @XmlAttribute(name = "extid") 35 | public String getExtId() { 36 | return extId; 37 | } 38 | 39 | public void setExtId(String extId) { 40 | this.extId = extId; 41 | } 42 | 43 | @XmlElement 44 | public String getUserName() { 45 | return userName; 46 | } 47 | 48 | public void setUserName(String userName) { 49 | this.userName = userName; 50 | } 51 | 52 | @XmlAttribute(name = "enabled") 53 | public boolean isEnabled() { 54 | return enabled; 55 | } 56 | 57 | public void setEnabled(boolean enabled) { 58 | this.enabled = enabled; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return this.getClass().getSimpleName() 64 | + '[' 65 | + "id:" + id 66 | + " name:" + userName 67 | + (extId!=null? " ext:" + extId : "") 68 | + (enabled ? " enabled" : " disabled") 69 | + ']'; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTShortUserGroup.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import javax.xml.bind.annotation.XmlRootElement; 9 | 10 | /** 11 | * 12 | * @author ETj (etj at geo-solutions.it) 13 | */ 14 | @XmlRootElement(name = "ShortUserGroup") 15 | public class RESTShortUserGroup { 16 | 17 | private Long id; 18 | private String name; 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | public Long getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Long id) { 33 | this.id = id; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return getClass().getSimpleName() + "[id:" + id + " name:" + name + ']'; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTShortUserGroupList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | import javax.xml.bind.annotation.XmlElement; 12 | import javax.xml.bind.annotation.XmlRootElement; 13 | 14 | /** 15 | * 16 | * @author ETj (etj at geo-solutions.it) 17 | */ 18 | @XmlRootElement(name = "UserGroupList") 19 | public class RESTShortUserGroupList { 20 | 21 | private List list; 22 | 23 | public RESTShortUserGroupList() { 24 | this(10); 25 | } 26 | 27 | public RESTShortUserGroupList(int initialCapacity) { 28 | list = new ArrayList(initialCapacity); 29 | } 30 | 31 | @XmlElement(name = "userGroup") 32 | public List getList() { 33 | return list; 34 | } 35 | 36 | public void setList(List list) { 37 | this.list = list; 38 | } 39 | 40 | public void add(RESTShortUserGroup group) { 41 | list.add(group); 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return getClass().getSimpleName() + "[" + list.size() + " groups]"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/RESTShortUserList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Iterator; 10 | import java.util.List; 11 | 12 | import javax.xml.bind.annotation.XmlElement; 13 | import javax.xml.bind.annotation.XmlRootElement; 14 | 15 | /** 16 | * 17 | * @author ETj (etj at geo-solutions.it) 18 | */ 19 | @XmlRootElement(name = "UserList") 20 | public class RESTShortUserList implements Iterable{ 21 | 22 | private List list; 23 | 24 | public RESTShortUserList() { 25 | this(10); 26 | } 27 | 28 | public RESTShortUserList(int initialCapacity) { 29 | list = new ArrayList(initialCapacity); 30 | } 31 | 32 | @XmlElement(name = "User") 33 | public List getUserList() { 34 | return list; 35 | } 36 | 37 | public void setUserList(List userList) { 38 | this.list = userList; 39 | } 40 | 41 | public void add(RESTShortUser user) { 42 | list.add(user); 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return getClass().getSimpleName() + "[" + list.size() + " users]"; 48 | } 49 | 50 | @Override 51 | public Iterator iterator() { 52 | return list.iterator(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/config/RESTFullGRUserList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model.config; 7 | 8 | import org.geoserver.geofence.core.model.GFUser; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | import javax.xml.bind.annotation.XmlElement; 14 | import javax.xml.bind.annotation.XmlRootElement; 15 | 16 | /** 17 | * 18 | * @author ETj (etj at geo-solutions.it) 19 | */ 20 | @XmlRootElement(name = "GRUserList") 21 | public class RESTFullGRUserList { 22 | 23 | private List list; 24 | 25 | public RESTFullGRUserList() { 26 | this(10); 27 | } 28 | 29 | public RESTFullGRUserList(int initialCapacity) { 30 | list = new ArrayList(initialCapacity); 31 | } 32 | 33 | @XmlElement(name = "User") 34 | public List getList() { 35 | return list; 36 | } 37 | 38 | public void setList(List userList) { 39 | this.list = userList; 40 | } 41 | 42 | public void add(GFUser user) { 43 | list.add(user); 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return getClass().getSimpleName() + "[" + list.size() + " users]"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/config/RESTFullGSInstanceList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model.config; 7 | 8 | import org.geoserver.geofence.core.model.GSInstance; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | import javax.xml.bind.annotation.XmlElement; 14 | import javax.xml.bind.annotation.XmlRootElement; 15 | 16 | /** 17 | * 18 | * @author ETj (etj at geo-solutions.it) 19 | */ 20 | @XmlRootElement(name = "GSInstanceList") 21 | public class RESTFullGSInstanceList { 22 | 23 | private List list; 24 | 25 | public RESTFullGSInstanceList() { 26 | this(10); 27 | } 28 | 29 | public RESTFullGSInstanceList(int initialCapacity) { 30 | list = new ArrayList(initialCapacity); 31 | } 32 | 33 | @XmlElement(name = "GSInstance") 34 | public List getList() { 35 | return list; 36 | } 37 | 38 | public void setList(List list) { 39 | this.list = list; 40 | } 41 | 42 | public void add(GSInstance gs) { 43 | list.add(gs); 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return getClass().getSimpleName() + "[" + list.size() + " items]"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/config/RESTFullRuleList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model.config; 7 | 8 | import org.geoserver.geofence.core.model.Rule; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Iterator; 12 | import java.util.List; 13 | 14 | import javax.xml.bind.annotation.XmlElement; 15 | import javax.xml.bind.annotation.XmlRootElement; 16 | 17 | /** 18 | * 19 | * @author ETj (etj at geo-solutions.it) 20 | */ 21 | @XmlRootElement(name = "RuleList") 22 | public class RESTFullRuleList implements Iterable { 23 | 24 | private List list; 25 | 26 | public RESTFullRuleList() { 27 | this(10); 28 | } 29 | 30 | public RESTFullRuleList(List list) { 31 | this.list = list; 32 | } 33 | 34 | public RESTFullRuleList(int initialCapacity) { 35 | list = new ArrayList(initialCapacity); 36 | } 37 | 38 | @XmlElement(name = "Rule") 39 | public List getList() { 40 | return list; 41 | } 42 | 43 | public void setList(List list) { 44 | this.list = list; 45 | } 46 | 47 | public void add(Rule rule) { 48 | list.add(rule); 49 | } 50 | 51 | @Override 52 | public Iterator iterator() { 53 | return list.iterator(); 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return getClass().getSimpleName() + "[" + list.size() + " items]"; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/config/RESTFullUserGroupList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model.config; 7 | 8 | import org.geoserver.geofence.services.dto.ShortGroup; 9 | 10 | import java.util.ArrayList; 11 | import java.util.Iterator; 12 | import java.util.List; 13 | 14 | import javax.xml.bind.annotation.XmlElement; 15 | import javax.xml.bind.annotation.XmlRootElement; 16 | 17 | /** 18 | * 19 | * @author ETj (etj at geo-solutions.it) 20 | */ 21 | @XmlRootElement(name = "UserGroupList") 22 | public class RESTFullUserGroupList implements Iterable { 23 | 24 | private List list; 25 | 26 | public RESTFullUserGroupList() { 27 | this(10); 28 | } 29 | 30 | public RESTFullUserGroupList(List list) { 31 | this.list = list; 32 | } 33 | 34 | public RESTFullUserGroupList(int initialCapacity) { 35 | list = new ArrayList(initialCapacity); 36 | } 37 | 38 | @XmlElement(name = "UserGroup") 39 | public List getList() { 40 | return list; 41 | } 42 | 43 | public void setList(List list) { 44 | this.list = list; 45 | } 46 | 47 | public void add(ShortGroup group) { 48 | list.add(group); 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return getClass().getSimpleName() + "[" + list.size() + " groups]"; 54 | } 55 | 56 | @Override 57 | public Iterator iterator() { 58 | return list.iterator(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/config/RESTFullUserList.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model.config; 7 | 8 | import org.geoserver.geofence.core.model.GSUser; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | import javax.xml.bind.annotation.XmlElement; 14 | import javax.xml.bind.annotation.XmlRootElement; 15 | 16 | /** 17 | * 18 | * @author ETj (etj at geo-solutions.it) 19 | */ 20 | @XmlRootElement(name = "UserList") 21 | public class RESTFullUserList { 22 | 23 | private List list; 24 | 25 | public RESTFullUserList() { 26 | this(10); 27 | } 28 | 29 | public RESTFullUserList(int initialCapacity) { 30 | list = new ArrayList(initialCapacity); 31 | } 32 | 33 | @XmlElement(name = "User") 34 | public List getList() { 35 | return list; 36 | } 37 | 38 | public void setList(List userList) { 39 | this.list = userList; 40 | } 41 | 42 | public void add(GSUser user) { 43 | list.add(user); 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return getClass().getSimpleName() + "[" + list.size() + " users]"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/config/adapter/MapType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model.config.adapter; 7 | 8 | import java.util.Iterator; 9 | import java.util.LinkedList; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | import javax.xml.bind.annotation.XmlElement; 14 | import javax.xml.bind.annotation.XmlRootElement; 15 | 16 | /** 17 | * 18 | * @author ETj (etj at geo-solutions.it) 19 | */ 20 | @XmlRootElement(name = "Map") 21 | public class MapType implements Iterable { 22 | 23 | List entries = new LinkedList(); 24 | 25 | @XmlElement(name = "item") 26 | public List getEntries() { 27 | return entries; 28 | } 29 | 30 | public void setEntries(List entries) { 31 | this.entries = entries; 32 | } 33 | 34 | public void add(Map.Entry entry) { 35 | entries.add(new RemappedType(entry.getKey(), entry.getValue())); 36 | } 37 | 38 | @Override 39 | public Iterator iterator() { 40 | return entries.iterator(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/config/adapter/RemappedType.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model.config.adapter; 7 | 8 | import javax.xml.bind.annotation.XmlAttribute; 9 | import javax.xml.bind.annotation.XmlRootElement; 10 | 11 | /** 12 | * 13 | * @author ETj (etj at geo-solutions.it) 14 | */ 15 | @XmlRootElement(name = "item") 16 | public class RemappedType { 17 | 18 | private Long oldId; 19 | private Long newId; 20 | 21 | public RemappedType(Long key, Long value) { 22 | this.oldId = key; 23 | this.newId = value; 24 | } 25 | 26 | public RemappedType() { 27 | } 28 | 29 | @XmlAttribute 30 | public Long getOld() { 31 | return oldId; 32 | } 33 | 34 | public void setOld(Long key) { 35 | this.oldId = key; 36 | } 37 | 38 | @XmlAttribute 39 | public Long getNew() { 40 | return newId; 41 | } 42 | 43 | public void setNew(Long value) { 44 | this.newId = value; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/config/adapter/RemapperAdapter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model.config.adapter; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | import javax.xml.bind.annotation.adapters.XmlAdapter; 12 | 13 | /** 14 | * 15 | * @author ETj (etj at geo-solutions.it) 16 | */ 17 | public class RemapperAdapter extends XmlAdapter> { 18 | 19 | @Override 20 | public MapType marshal(Map v) throws Exception { 21 | MapType ret = new MapType(); 22 | // System.out.println("marshalling..."); 23 | for (Map.Entry entry : v.entrySet()) { 24 | // System.out.println("marshalling " + entry.getKey()+":"+entry.getValue()); 25 | ret.add(entry); 26 | } 27 | 28 | return ret; 29 | } 30 | 31 | @Override 32 | public Map unmarshal(MapType v) throws Exception { 33 | Map ret = new HashMap(); 34 | // System.out.println("unmarshalling..."); 35 | for (RemappedType entry : v) { 36 | // System.out.println("unmarshalling " + entry.getKey() + ":" + entry.getValue()); 37 | ret.put(entry.getOld(), entry.getNew()); 38 | } 39 | 40 | return ret; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/services/modules/rest/api/src/main/java/org/geoserver/geofence/services/rest/model/util/IdName.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.model.util; 7 | 8 | import javax.xml.bind.annotation.XmlElement; 9 | import javax.xml.bind.annotation.XmlRootElement; 10 | import javax.xml.bind.annotation.XmlType; 11 | 12 | /** 13 | * 14 | * @author ETj (etj at geo-solutions.it) 15 | */ 16 | @XmlRootElement(name = "identifier") 17 | @XmlType(propOrder={"id", "name"}) 18 | public class IdName { 19 | private String name; 20 | private Long id; 21 | 22 | protected IdName() { 23 | } 24 | 25 | public IdName(Long id, String name) { 26 | this.name = name; 27 | this.id = id; 28 | } 29 | 30 | public IdName(String name) { 31 | setName(name); 32 | } 33 | 34 | public IdName(Long id) { 35 | setId(id); 36 | } 37 | 38 | @XmlElement 39 | public Long getId() { 40 | return id; 41 | } 42 | 43 | @XmlElement 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | public void setId(Long id) { 49 | this.id = id; 50 | this.name = null; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | this.id=null; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | StringBuffer sb = new StringBuffer(); 61 | // sb.append(getClass().getSimpleName()).append('['); 62 | sb.append('['); 63 | if(id != null) 64 | sb.append("id:").append(id); 65 | if(name != null) 66 | sb.append("name:").append(name); 67 | sb.append(']'); 68 | return sb.toString(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/services/modules/rest/client/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/services/modules/rest/impl/src/main/java/org/geoserver/geofence/services/rest/auth/AuthUser.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.auth; 7 | 8 | /** 9 | * 10 | * @author ETj (etj at geo-solutions.it) 11 | */ 12 | public class AuthUser 13 | { 14 | 15 | private String name; 16 | 17 | public String getName() 18 | { 19 | return name; 20 | } 21 | 22 | public void setName(String name) 23 | { 24 | this.name = name; 25 | } 26 | 27 | @Override 28 | public boolean equals(Object obj) 29 | { 30 | if (obj == null) 31 | { 32 | return false; 33 | } 34 | if (getClass() != obj.getClass()) 35 | { 36 | return false; 37 | } 38 | 39 | final AuthUser other = (AuthUser) obj; 40 | if ((this.name == null) ? (other.name != null) : (!this.name.equals(other.name))) 41 | { 42 | return false; 43 | } 44 | 45 | return true; 46 | } 47 | 48 | @Override 49 | public int hashCode() 50 | { 51 | int hash = 5; 52 | hash = (19 * hash) + ((this.name != null) ? this.name.hashCode() : 0); 53 | 54 | return hash; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/services/modules/rest/impl/src/main/java/org/geoserver/geofence/services/rest/auth/GeofencePrincipal.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.auth; 7 | 8 | import java.security.Principal; 9 | 10 | 11 | /** 12 | * 13 | * @author ETj (etj at geo-solutions.it) 14 | */ 15 | public class GeofencePrincipal implements Principal 16 | { 17 | 18 | static GeofencePrincipal createGuest() 19 | { 20 | return new GeofencePrincipal(); 21 | } 22 | 23 | private AuthUser user; 24 | 25 | public GeofencePrincipal() 26 | { 27 | } 28 | 29 | public GeofencePrincipal(AuthUser user) 30 | { 31 | if (user == null) 32 | { 33 | throw new NullPointerException("Null user"); 34 | } 35 | this.user = user; 36 | } 37 | 38 | @Override 39 | public String getName() 40 | { 41 | return (user != null) ? user.getName() : "GUEST"; 42 | } 43 | 44 | @Override 45 | public boolean equals(Object obj) 46 | { 47 | if (obj == null) 48 | { 49 | return false; 50 | } 51 | if (getClass() != obj.getClass()) 52 | { 53 | return false; 54 | } 55 | 56 | final GeofencePrincipal other = (GeofencePrincipal) obj; 57 | if ((this.user != other.user) && ((this.user == null) || !this.user.equals(other.user))) 58 | { 59 | return false; 60 | } 61 | 62 | return true; 63 | } 64 | 65 | @Override 66 | public int hashCode() 67 | { 68 | int hash = 3; 69 | hash = (97 * hash) + ((this.user != null) ? this.user.hashCode() : 0); 70 | 71 | return hash; 72 | } 73 | 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/services/modules/rest/impl/src/main/java/org/geoserver/geofence/services/rest/auth/GeofenceSecurityContext.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.services.rest.auth; 7 | 8 | import java.security.Principal; 9 | 10 | import org.apache.cxf.security.SecurityContext; 11 | import org.apache.logging.log4j.LogManager; 12 | import org.apache.logging.log4j.Logger; 13 | 14 | /** 15 | * 16 | * @author ETj (etj at geo-solutions.it) 17 | */ 18 | public class GeofenceSecurityContext implements SecurityContext 19 | { 20 | 21 | private static final Logger LOGGER = LogManager.getLogger(GeofenceSecurityContext.class); 22 | 23 | private GeofencePrincipal principal; 24 | 25 | public void setPrincipal(GeofencePrincipal principal) 26 | { 27 | this.principal = principal; 28 | } 29 | 30 | @Override 31 | public Principal getUserPrincipal() 32 | { 33 | return principal; 34 | } 35 | 36 | 37 | @Override 38 | public boolean isUserInRole(String role) 39 | { 40 | boolean ret = isUserInRoleAux(role); 41 | LOGGER.info("User" + principal.getName() + " in " + role + " : " + ret); 42 | 43 | return ret; 44 | } 45 | 46 | public boolean isUserInRoleAux(String role) 47 | { 48 | // TODO pls use an enum here 49 | if ("*".equals(role)) 50 | { 51 | return true; 52 | } 53 | 54 | if ("guest".equalsIgnoreCase(role)) 55 | { 56 | return true; 57 | } 58 | 59 | if ("user".equalsIgnoreCase(role)) // so user is registered 60 | { 61 | return true; 62 | } 63 | 64 | if ("admin".equalsIgnoreCase(principal.getName()) && "admin".equalsIgnoreCase(role)) 65 | { 66 | return true; 67 | } 68 | 69 | return false; 70 | } 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/services/modules/rest/impl/src/test/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/services/modules/rest/impl/src/test/resources/geofence-datasource-ovr.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=create-drop 7 | geofenceVendorAdapter.generateDdl=false 8 | geofenceVendorAdapter.showSql=false 9 | -------------------------------------------------------------------------------- /src/services/modules/rest/impl/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/services/modules/rest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 4.0.0 13 | 14 | 15 | org.geoserver.geofence 16 | geofence-modules 17 | 3.8-SNAPSHOT 18 | 19 | 20 | org.geoserver.geofence 21 | geofence-rest-root 22 | GeoFence - Modules - REST root 23 | pom 24 | 25 | 26 | api 27 | impl 28 | test 29 | client 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/main/resources/META-INF/cxf/org.apache.cxf.Logger: -------------------------------------------------------------------------------- 1 | org.apache.cxf.common.logging.Log4jLogger 2 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/main/resources/geofence-datasource-ovr.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=update 7 | geofenceVendorAdapter.generateDdl=true 8 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 17 | 18 | contextConfigLocation 19 | 20 | classpath*:applicationContext.xml 21 | 22 | 23 | 24 | 28 | 29 | 30 | 33 | 34 | 35 | org.springframework.web.context.ContextLoaderListener 36 | 37 | 38 | 39 | 40 | 41 | CXFServlet 42 | org.apache.cxf.transport.servlet.CXFServlet 43 | 44 | 45 | 46 | CXFServlet 47 | /rest/* 48 | 49 | 50 | 51 | 52 | Application.html 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/test/resources/batch01.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 20 | 21 | 22 | group1001 23 | 24 | 25 | 26 | 27 | 28 | group1002 29 | 30 | 31 | 32 | 33 | 34 | group1003 35 | _1003 36 | 37 | 38 | 39 | 40 | 41 | sample_instance_01 42 | sample descr 43 | http://yourgeoserver/geoserver 44 | admin 45 | clearpw 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/test/resources/batch02.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 20 | 21 | 22 | group1001 23 | 24 | 25 | 26 | 27 | 28 | group1002 29 | 30 | 31 | 32 | 33 | 34 | group1003 35 | _1003 36 | 37 | 38 | 39 | 40 | 41 | sample_instance_01 42 | sample descr 43 | http://yourgeoserver/geoserver 44 | admin 45 | clearpw 46 | 47 | 48 | 49 | 50 | 51 | ext_zz 52 | user_01 53 | pw_01 54 | fullname_01 55 | email_01 56 | 57 | 58 | group1001 59 | 60 | 61 | group1002 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/test/resources/batch_empty_payload.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/test/resources/group01.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | external_id_here 12 | sample REST group 13 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/test/resources/instance01.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | sample_instance_01 13 | sample descr 14 | http://yourgeoserver/geoserver 15 | admin 16 | clearpw 17 | 18 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/test/resources/rule01.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | user_01 15 | 16 | 19 | 22 | WMS_02 23 | getMap_02 24 | wsp_02 25 | layer_02 26 | 27 | VECTOR 28 | Style_02 29 | CQL_READ_SAMPLE 30 | CQL_WRITE_SAMPLE 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | java.lang.String 40 | attr1 41 | 42 | 43 | java.lang.String 44 | attr2 45 | 46 | 47 | java.lang.String 48 | attr3 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/test/resources/user0101.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | ext_zz 12 | user_02 13 | pw_02 14 | fullname_02 15 | email_02 16 | 17 | 18 | sample REST group 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/services/modules/rest/test/src/test/resources/user0_update.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | group1002 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/services/webapp/src/main/java/org/geoserver/geofence/web/AuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.web; 7 | 8 | import org.springframework.security.authentication.AnonymousAuthenticationToken; 9 | import org.springframework.security.core.Authentication; 10 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 11 | import org.springframework.security.core.context.SecurityContextHolder; 12 | 13 | import javax.servlet.Filter; 14 | import javax.servlet.FilterChain; 15 | import javax.servlet.FilterConfig; 16 | import javax.servlet.ServletException; 17 | import javax.servlet.ServletRequest; 18 | import javax.servlet.ServletResponse; 19 | import javax.servlet.http.HttpServletRequest; 20 | import java.io.IOException; 21 | import java.util.Collections; 22 | 23 | public class AuthenticationFilter implements Filter { 24 | 25 | private static final String ANONYMOUS_ROLE = "ANONYMOUS"; 26 | 27 | public void destroy() { 28 | // nothing to do 29 | } 30 | 31 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, 32 | ServletException { 33 | HttpServletRequest httpRequest = (HttpServletRequest) request; 34 | httpRequest.getSession().setAttribute("userLoggedToken", ""); 35 | Authentication authentication = new AnonymousAuthenticationToken("geofence", "null", 36 | Collections.singletonList(new SimpleGrantedAuthority(ANONYMOUS_ROLE))); 37 | SecurityContextHolder.getContext().setAuthentication(authentication); 38 | chain.doFilter(httpRequest, response); 39 | } 40 | 41 | public void init(FilterConfig filterConfig) { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/services/webapp/src/main/java/org/geoserver/geofence/web/StartupService.java: -------------------------------------------------------------------------------- 1 | /* (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | * This code is licensed under the GPL 2.0 license, available at the root 3 | * application directory. 4 | */ 5 | 6 | package org.geoserver.geofence.web; 7 | 8 | import org.geoserver.geofence.core.model.GFUser; 9 | import org.geoserver.geofence.login.util.MD5Util; 10 | import org.geoserver.geofence.services.GFUserAdminServiceImpl; 11 | 12 | import org.apache.logging.log4j.LogManager; 13 | import org.apache.logging.log4j.Logger; 14 | 15 | import org.springframework.beans.factory.InitializingBean; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | 18 | 19 | public class StartupService implements InitializingBean 20 | { 21 | private static final Logger LOGGER = LogManager.getLogger(StartupService.class); 22 | 23 | @Autowired 24 | GFUserAdminServiceImpl gfUserAdminService; 25 | 26 | @Override 27 | public void afterPropertiesSet() throws Exception { 28 | long cnt = gfUserAdminService.getCount(null); 29 | if(cnt == 0) { 30 | LOGGER.warn("No GF users found. Creating the default admin."); 31 | 32 | GFUser user = new GFUser(); 33 | user.setFullName("Default admin"); 34 | user.setName("admin"); 35 | user.setPassword(MD5Util.getHash("geofence")); 36 | user.setEnabled(Boolean.TRUE); 37 | gfUserAdminService.insert(user); 38 | } 39 | } 40 | 41 | public void setGfUserAdminService(GFUserAdminServiceImpl gfUserAdminService) { 42 | this.gfUserAdminService = gfUserAdminService; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/services/webapp/src/main/resources/geofence-datasource-ovr.properties: -------------------------------------------------------------------------------- 1 | # (c) 2014 - 2017 Open Source Geospatial Foundation - all rights reserved 2 | # This code is licensed under the GPL 2.0 license, available at the root 3 | # application directory. 4 | 5 | ################################################################################ 6 | ## These are default values, please DO NOT modify this file. 7 | ## If you need to customise these values, please create a new property file 8 | ## outside the webapp dir, and put into the system var "-Dgeofence-ovr" the 9 | ## path of your file. 10 | ## 11 | ## Take as example the file geofence-datasource-ovr.properties.sample which also 12 | ## contains some info about each setting. 13 | ################################################################################ 14 | 15 | geofenceVendorAdapter.databasePlatform=org.hibernate.spatial.dialect.h2geodb.GeoDBDialect 16 | geofenceDataSource.driverClassName=org.h2.Driver 17 | geofenceDataSource.url=jdbc:h2:${user.dir}/geofence_db/geofence 18 | geofenceDataSource.username=sa 19 | geofenceDataSource.password=sa 20 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.default_schema]=public 21 | 22 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.hbm2ddl.auto]=update 23 | geofenceEntityManagerFactory.jpaPropertyMap[javax.persistence.validation.mode]=none 24 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.validator.apply_to_ddl]=false 25 | geofenceEntityManagerFactory.jpaPropertyMap[hibernate.validator.autoregister_listeners]=false 26 | 27 | ### END ######################################################################## 28 | -------------------------------------------------------------------------------- /src/services/webapp/src/main/resources/geofence-datasource.properties: -------------------------------------------------------------------------------- 1 | # /* (c) 2014 Open Source Geospatial Foundation - all rights reserved 2 | # * This code is licensed under the GPL 2.0 license, available at the root 3 | # * application directory. 4 | # */ 5 | # 6 | -------------------------------------------------------------------------------- /src/services/webapp/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/services/webapp/src/main/webapp/WEB-INF/dispatcher-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | -------------------------------------------------------------------------------- /src/services/webapp/src/main/webapp/WEB-INF/remoting-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | --------------------------------------------------------------------------------