Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'origin/1.6.x'"
Browse files Browse the repository at this point in the history
This reverts commit 8c8c61a, reversing
changes made to 52daf39.
  • Loading branch information
psmith committed Sep 28, 2015
1 parent 4d8b866 commit 12a3412
Show file tree
Hide file tree
Showing 23 changed files with 165 additions and 227 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ install: "mvn install -P ci -U --quiet -DskipTests=true"
script: "mvn -U -P ci test"
env: MAVEN_OPTS="-Dhttps.protocols=SSLv3 -Dforce.http.jre.executor=true"
branches:
only:
- master
except:
- demo-profile
24 changes: 3 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,10 @@
<name>Zuul: Parent POM</name>
<url>https://github.com/psmith/Zuul</url>
<scm>
<connection>scm:git:[email protected]:Confluex/zuul.git</connection>
<url>scm:git:[email protected]:Confluex/zuul.git</url>
<developerConnection>scm:git:[email protected]:Confluex/zuul.git</developerConnection>
<tag>1.6.x</tag>
<connection>scm:git:[email protected]:mcantrell/Zuul.git</connection>
<url>scm:git:[email protected]:mcantrell/Zuul.git</url>
<developerConnection>scm:git:[email protected]:mcantrell/Zuul.git</developerConnection>
</scm>
<distributionManagement>
<repository>
<id>confluex-public-releases</id>
<url>http://dev.confluex.com/nexus/content/repositories/public-releases</url>
</repository>
<snapshotRepository>
<id>confluex-public-snapshots</id>
<url>http://dev.confluex.com/nexus/content/repositories/public-snapshots</url>
</snapshotRepository>
</distributionManagement>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
Expand All @@ -36,16 +25,9 @@
<name>Mike Cantrell</name>
<email>[email protected]</email>
</developer>
<developer>
<id>psmith</id>
<name>Paul.Smith</name>
<email>[email protected]</email>
</developer>
</developers>
<properties>
<devnull.version>1.1</devnull.version>
<sonar.language>grvy</sonar.language>
<sonar.sources>src/main/groovy</sonar.sources>
</properties>
<parent>
<groupId>org.devnull</groupId>
Expand Down
14 changes: 14 additions & 0 deletions zuul-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,18 @@
<artifactId>greenmail</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<!-- no need to deploy this module to central repo -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,4 @@ class SettingsEntry implements Serializable {

@Column(nullable = false)
Boolean encrypted = false

SettingsEntry copy() {
return new SettingsEntry(
key: this.key,
value: this.value,
group: this.group,
id: this.id,
encrypted: this.encrypted
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public interface ZuulService {

SettingsEntry findSettingsEntry(Integer id)

@PreAuthorize("hasPermission(#entry.group.environment, 'admin')")
SettingsEntry encryptSettingsEntryValue(SettingsEntry entry)
@PreAuthorize("hasRole('ROLE_ADMIN')")
SettingsEntry encryptSettingsEntryValue(Integer entryId)

@PreAuthorize("hasPermission(#entry.group.environment, 'admin')")
SettingsEntry decryptSettingsEntryValue(SettingsEntry entry)
@PreAuthorize("hasRole('ROLE_ADMIN')")
SettingsEntry decryptSettingsEntryValue(Integer entryId)

@PreAuthorize("hasPermission(#entry.group.environment, 'admin')")
void deleteSettingsEntry(SettingsEntry entry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,25 +204,25 @@ class ZuulServiceImpl implements ZuulService {
}

@Transactional(readOnly = false)
SettingsEntry encryptSettingsEntryValue(final SettingsEntry entry) {
def result = entry.copy()
if (result.encrypted) {
throw new ConflictingOperationException("Cannot encrypt value that are already encrypted. Entry ID: " + result.id)
SettingsEntry encryptSettingsEntryValue(Integer entryId) {
def entry = settingsEntryDao.findOne(entryId)
if (entry.encrypted) {
throw new ConflictingOperationException("Cannot encrypt value that are already encrypted. Entry ID: " + entryId)
}
result.value = encryptionStrategy.encrypt(result.value, result.group.key)
result.encrypted = true
return result
entry.value = encryptionStrategy.encrypt(entry.value, entry.group.key)
entry.encrypted = true
return entry
}

@Transactional(readOnly = false)
SettingsEntry decryptSettingsEntryValue(final SettingsEntry entry) {
def result = entry.copy()
if (!result.encrypted) {
throw new ConflictingOperationException("Cannot decrypt value that are already decrypted. Entry ID: " + result.id)
SettingsEntry decryptSettingsEntryValue(Integer entryId) {
def entry = settingsEntryDao.findOne(entryId)
if (!entry.encrypted) {
throw new ConflictingOperationException("Cannot decrypt value that are already decrypted. Entry ID: " + entryId)
}
result.value = encryptionStrategy.decrypt(result.value, result.group.key)
result.encrypted = false
return result
entry.value = encryptionStrategy.decrypt(entry.value, entry.group.key)
entry.encrypted = false
return entry
}

SettingsEntry findSettingsEntry(Integer id) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -562,14 +562,14 @@ public class ZuulServiceImplTest {
void shouldErrorWhenTryingToEncryptValuesWhichAreAlreadyEncrypted() {
def entry = new SettingsEntry(id: 1, encrypted: true)
when(service.settingsEntryDao.findOne(entry.id)).thenReturn(entry)
service.encryptSettingsEntryValue(entry)
service.encryptSettingsEntryValue(entry.id)
}

@Test(expected = ConflictingOperationException)
void shouldErrorWhenTryingToDecryptValuesWhichAreAlreadyDecrypted() {
def entry = new SettingsEntry(id: 1, encrypted: false)
when(service.settingsEntryDao.findOne(entry.id)).thenReturn(entry)
service.decryptSettingsEntryValue(entry)
service.decryptSettingsEntryValue(entry.id)
}

@Test
Expand All @@ -581,32 +581,12 @@ public class ZuulServiceImplTest {
when(service.settingsEntryDao.findOne(entry.id)).thenReturn(entry)
when(service.settingsEntryDao.save(entry)).thenReturn(entry)
when(service.encryptionStrategy.encrypt(entry.value, group.key)).thenReturn("encryptedValue")
def encryptedEntry = service.encryptSettingsEntryValue(entry)
def encryptedEntry = service.encryptSettingsEntryValue(entry.id)
verify(service.encryptionStrategy).encrypt("foo", group.key)
assert encryptedEntry.encrypted
assert encryptedEntry.value == "encryptedValue"
}

@Test
void shouldEncryptSettingsEntryWithoutModifyingTheOriginalObject() {
def group = new SettingsGroup(key: new EncryptionKey(password: "abc123"))
def entry = new SettingsEntry(id: 1, key: "a", value: "foo")
group.addToEntries(entry)

def result = service.encryptSettingsEntryValue(entry)
assert !result.is(entry)

assert result.id == entry.id
assert result.group == entry.group
assert entry.key == entry.key

assert result.value != entry.value
assert entry.value == "foo"
assert result.encrypted != entry.encrypted
assert result.encrypted
assert !entry.encrypted
}

@Test
void shouldDecryptSettingsEntryWithItsGroupKey() {
def group = new SettingsGroup(key: new EncryptionKey(password: "abc123"))
Expand All @@ -616,31 +596,12 @@ public class ZuulServiceImplTest {
when(service.settingsEntryDao.findOne(entry.id)).thenReturn(entry)
when(service.settingsEntryDao.save(entry)).thenReturn(entry)
when(service.encryptionStrategy.decrypt(entry.value, group.key)).thenReturn("decrypted")
def decrypted = service.decryptSettingsEntryValue(entry)
def decrypted = service.decryptSettingsEntryValue(entry.id)
verify(service.encryptionStrategy).decrypt("encrypted", group.key)
assert !decrypted.encrypted
assert decrypted.value == "decrypted"
}

@Test
void shouldDecryptSettingsEntryWithoutModifyingTheOriginalObject() {
def group = new SettingsGroup(key: new EncryptionKey(password: "abc123"))
def entry = new SettingsEntry(id: 1, key: "a", value: "foo", encrypted: true)
group.addToEntries(entry)

def result = service.decryptSettingsEntryValue(entry)
assert !result.is(entry)

assert result.id == entry.id
assert result.group == entry.group
assert entry.key == entry.key

assert result.value != entry.value
assert entry.value == "foo"
assert !result.encrypted
assert entry.encrypted
}

@Test
void findEntryShouldReturnResultFromDao() {
def expected = new SettingsEntry(id: 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
package org.devnull.zuul.web

import groovy.json.JsonSlurper
import org.springframework.context.annotation.Profile
import org.springframework.core.io.ClassPathResource
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.servlet.ModelAndView

@Controller
@Profile("security-openid")
class OpenIdLoginController {

@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView login() {
//return back to index.jsp
ModelAndView model = new ModelAndView("/login/openid");
model.addObject("providers", getProviders());
return model;

}

def getProviders(){
def json = new ClassPathResource("security/OpenIdProviders.json").inputStream.text
def slurper = new JsonSlurper()
return slurper.parseText(json).openIdProviders
@RequestMapping("/login")
String login() {
return "/login/openid"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ class SettingsServicesController {
*/
@RequestMapping(value = "/settings/entry/encrypt.json")
@ResponseBody
SettingsEntry encrypt(@RequestParam("id")Integer id) {
def entry = zuulService.findSettingsEntry(id)
return zuulService.encryptSettingsEntryValue(entry)
SettingsEntry encrypt(@RequestParam("id") Integer id) {
def entry = zuulService.encryptSettingsEntryValue(id)
return zuulService.save(entry, SettingsAudit.AuditType.ENCRYPT)
}

/**
Expand All @@ -161,8 +161,8 @@ class SettingsServicesController {
@RequestMapping(value = "/settings/entry/decrypt.json")
@ResponseBody
SettingsEntry decrypt(@RequestParam("id") Integer id) {
def entry = zuulService.findSettingsEntry(id)
return zuulService.decryptSettingsEntryValue(entry)
def entry = zuulService.decryptSettingsEntryValue(id)
return zuulService.save(entry, SettingsAudit.AuditType.DECRYPT)
}

}
59 changes: 59 additions & 0 deletions zuul-web/src/main/resources/examples/zuul-data-config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#------------ In Memory H2 Database ------------#
# Embedded databases which is useful for #
# evaluation purposes. The data is wiped after #
# server restart. #
#-----------------------------------------------#
jdbc.zuul.url=jdbc:h2:mem:zuul
#jdbc.zuul.url=jdbc:h2:tcp://localhost/~/.zuul/data
jdbc.zuul.generate.ddl=validate
jdbc.zuul.username=sa
jdbc.zuul.password=
jdbc.zuul.driver=org.h2.Driver
jdbc.zuul.dialect=org.hibernate.dialect.H2Dialect
jdbc.zuul.validationQuery=select 1

#------------ Microsoft SQL Database ------------#
# Create a connection for microsoft SQL server #
# using the JTDS driver. #
# #
# Check the JTDS docs for more info: #
# http://jtds.sourceforge.net/faq.html#urlFormat #
#------------------------------------------------#
#jdbc.zuul.url=jdbc:jtds:sqlserver://SERVERNAME:1433/zuul
#jdbc.zuul.generate.ddl=none
#jdbc.zuul.username=
#jdbc.zuul.password=
#jdbc.zuul.driver=net.sourceforge.jtds.jdbc.Driver
#jdbc.zuul.dialect=org.hibernate.dialect.SQLServerDialect
#jdbc.zuul.validationQuery=select 1

#---------------- MySQL Database ----------------#
# Create a connection for MySQL #
#------------------------------------------------#
#jdbc.zuul.url=jdbc:mysql://SERVERNAME/zuul
#jdbc.zuul.generate.ddl=none
#jdbc.zuul.username=
#jdbc.zuul.password=
#jdbc.zuul.driver=com.mysql.jdbc.Driver
#jdbc.zuul.dialect=org.hibernate.dialect.MySQLDialect
#jdbc.zuul.validationQuery=select 1 from DUAL

#---------------- Other Databases ----------------#
# Zuul should work with most other databases. You #
# Just need to find out the appropriate driver #
# class, hibernate dialect and validation query. #
# #
# Google has your back. Go do some searching :-) #
#-------------------------------------------------#


#------------ Mail Settings ------------#
# If set to 3025 and localhost, an #
# embedded GreenMail server will be #
# started for testing purposes. #
#---------------------------------------#
smtp.port=25
smtp.host=smtp
smtp.from=Zuul <[email protected]>
smtp.username=
smtp.password=
26 changes: 0 additions & 26 deletions zuul-web/src/main/resources/security/OpenIdProviders.json

This file was deleted.

Loading

0 comments on commit 12a3412

Please sign in to comment.