Skip to content

Commit 9c498ba

Browse files
authored
Merge pull request #47 from /issues/46
Untangle
2 parents 568b52c + 833de4e commit 9c498ba

File tree

78 files changed

+1886
-2956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1886
-2956
lines changed

hub/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@
7171
</profiles>
7272

7373
<dependencies>
74-
<dependency>
75-
<groupId>ch.cyberduck</groupId>
76-
<artifactId>binding</artifactId>
77-
</dependency>
7874
<dependency>
7975
<groupId>ch.cyberduck</groupId>
8076
<artifactId>nio</artifactId>

hub/src/main/java/ch/iterate/hub/core/CreateHubBookmarkAction.java

Lines changed: 0 additions & 68 deletions
This file was deleted.

hub/src/main/java/ch/iterate/hub/core/CreateVaultBookmarkAction.java

Lines changed: 0 additions & 81 deletions
This file was deleted.

hub/src/main/java/ch/iterate/hub/core/FirstLoginDeviceSetupCallbackFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public FirstLoginDeviceSetupCallback create() {
2525
final Constructor<? extends FirstLoginDeviceSetupCallback> constructor
2626
= ConstructorUtils.getMatchingAccessibleConstructor(clazz);
2727
if(null == constructor) {
28-
log.warn(String.format("No default controller in %s", constructor.getClass()));
28+
log.warn("No default controller in {}", constructor.getClass());
2929
// Call default constructor for disabled implementations
3030
return clazz.getDeclaredConstructor().newInstance();
3131
}
3232
return constructor.newInstance();
3333
}
3434
catch(InstantiationException | InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
35-
log.error(String.format("Failure loading callback class %s. %s", clazz, e.getMessage()));
35+
log.error("Failure loading callback class {}. {}", clazz, e.getMessage());
3636
return FirstLoginDeviceSetupCallback.disabled;
3737
}
3838
}

hub/src/main/java/ch/iterate/hub/core/callback/CreateVaultCallback.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

hub/src/main/java/ch/iterate/hub/core/callback/CreateVaultModel.java

Lines changed: 0 additions & 90 deletions
This file was deleted.

hub/src/main/java/ch/iterate/hub/crypto/JWE.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static String ecdhEsEncrypt(final JWEPayload payload, final String kid, f
6666
*/
6767
public static String ecdhEsEncrypt(final JWEPayload payload, final String kid, final ECPublicKey recipientPublicKey, final String apu, final String apv) throws JOSEException, JsonProcessingException {
6868
final JWEEncrypter jweEncrypter = new ECDHEncrypter(recipientPublicKey);
69-
JWEHeader header = new JWEHeader.Builder(ECDHES_DESIGNATION_ALG, ECDHES_DESIGNATION_ENC)
69+
final JWEHeader header = new JWEHeader.Builder(ECDHES_DESIGNATION_ALG, ECDHES_DESIGNATION_ENC)
7070
.keyID(kid)
7171
.agreementPartyUInfo(Base64URL.encode(apu))
7272
.agreementPartyVInfo(Base64URL.encode(apv))
@@ -101,7 +101,7 @@ public static String pbes2Encrypt(final JWEPayload payload, final String kid, fi
101101
*/
102102
public static String pbes2Encrypt(final JWEPayload payload, final String kid, final String password, final String apu, final String apv) throws JsonProcessingException, JOSEException {
103103
final JWEEncrypter jweEncrypter = new PasswordBasedEncrypter(password, PBES2_SALT_LENGTH, PBES2_ITERATION_COUNT);
104-
JWEHeader header = new JWEHeader.Builder(PBES2_DESIGNATION_ALG, PBES2_DESIGNATION_ENC)
104+
final JWEHeader header = new JWEHeader.Builder(PBES2_DESIGNATION_ALG, PBES2_DESIGNATION_ENC)
105105
.keyID(kid)
106106
.agreementPartyUInfo(Base64URL.encode(apu))
107107
.agreementPartyVInfo(Base64URL.encode(apv))

hub/src/main/java/ch/iterate/hub/crypto/uvf/UvfAccessTokenPayload.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public class UvfAccessTokenPayload extends JWEPayload {
3838
@JsonProperty("recoveryKey")
3939
String recoveryKey;
4040

41-
public static UvfAccessTokenPayload fromJWE(String jwe) throws JsonProcessingException {
42-
ObjectMapper mapper = new ObjectMapper();
41+
public static UvfAccessTokenPayload fromJWE(final String jwe) throws JsonProcessingException {
42+
final ObjectMapper mapper = new ObjectMapper();
4343
mapper.registerModule(new JsonNullableModule());
4444
return mapper.readValue(jwe, UvfAccessTokenPayload.class);
4545
}
@@ -53,7 +53,7 @@ public boolean equals(Object o) {
5353
return false;
5454
}
5555

56-
UvfAccessTokenPayload that = (UvfAccessTokenPayload) o;
56+
final UvfAccessTokenPayload that = (UvfAccessTokenPayload) o;
5757
return key.equals(that.key) && Objects.equals(recoveryKey, that.recoveryKey);
5858
}
5959

hub/src/main/java/ch/iterate/hub/crypto/uvf/UvfMetadataPayload.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public class UvfMetadataPayload extends JWEPayload {
8787
VaultMetadataJWEBackendDto storage;
8888

8989

90-
public static UvfMetadataPayload fromJWE(String jwe) throws JsonProcessingException {
91-
ObjectMapper mapper = new ObjectMapper();
90+
public static UvfMetadataPayload fromJWE(final String jwe) throws JsonProcessingException {
91+
final ObjectMapper mapper = new ObjectMapper();
9292
mapper.registerModule(new JsonNullableModule());
9393
return mapper.readValue(jwe, UvfMetadataPayload.class);
9494
}
@@ -122,7 +122,7 @@ public String computeRootDirIdHash(final byte[] rootDirId) {
122122
final HMac hMac = new HMac(digest);
123123
hMac.init(new KeyParameter(hmacKey));
124124
hMac.update(rootDirId, 0, rootDirId.length);
125-
byte[] hmacOut = new byte[hMac.getMacSize()];
125+
final byte[] hmacOut = new byte[hMac.getMacSize()];
126126
hMac.doFinal(hmacOut, 0);
127127
return Base32.toBase32String(Arrays.copyOfRange(hmacOut, 0, 20));
128128
}
@@ -288,7 +288,7 @@ public UvfMetadataPayload withStorage(final VaultMetadataJWEBackendDto backend)
288288
* @param jwk The jwk
289289
*/
290290
public static UvfMetadataPayload decryptWithJWK(final String jwe, final JWK jwk) throws ParseException, JOSEException, JsonProcessingException {
291-
JWEObjectJSON jweObject = JWEObjectJSON.parse(jwe);
291+
final JWEObjectJSON jweObject = JWEObjectJSON.parse(jwe);
292292
jweObject.decrypt(new MultiDecrypter(jwk));
293293
final Payload payload = jweObject.getPayload();
294294
return UvfMetadataPayload.fromJWE(payload.toString());

hub/src/main/java/ch/iterate/hub/crypto/wot/WoT.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ public static int computeTrustLevel(final UserDto trustedUser, final TrustedUser
134134
return signatureChain.size();
135135
}
136136
catch(SecurityFailure | NoSuchAlgorithmException | InvalidKeySpecException | NotECKeyException e) {
137-
if(log.isWarnEnabled()) {
138-
log.warn("WoT signature verification failed.", e);
139-
}
137+
log.warn("Web of Trust signature chain verification failed for user {}", trustedUser, e);
140138
return -1; // unverified
141139
}
142140
}
@@ -157,27 +155,21 @@ public static Map<TrustedUserDto, Integer> verifyTrusts(final List<TrustedUserDt
157155
for(final TrustedUserDto trust : trusts) {
158156
final String trustedUserId = trust.getTrustedUserId();
159157
if(trustedUserId == null) {
160-
if(log.isWarnEnabled()) {
161-
log.warn("Verification for {} failed. No ID found for trustee.", trust);
162-
}
158+
log.warn("Verification for {} failed. No ID found for trustee.", trust);
163159
continue;
164160
}
165161
final UserDto user = users.stream().filter(u -> trustedUserId.equals(u.getId())).findFirst().orElse(null);
166162
final List<String> signatureChain = trust.getSignatureChain();
167163
if(user == null || signatureChain == null) {
168-
if(log.isWarnEnabled()) {
169-
log.warn("Verification for {} failed. No user or no signature chain found.", trust);
170-
}
164+
log.warn("Verification for {} failed. No user or no signature chain found.", trust);
171165
continue;
172166
}
173167
try {
174168
WoT.verifyRecursive(signatureChain, signerPublicKey, SignedKeys.fromUser(user));
175169
verified.put(trust, signatureChain.size());
176170
}
177171
catch(SecurityFailure e) {
178-
if(log.isWarnEnabled()) {
179-
log.warn(String.format("Verification for %s failed - not granting access.", trust), e);
180-
}
172+
log.warn("Verification for {} failed - not granting access.", trust, e);
181173
}
182174
}
183175
return verified;

0 commit comments

Comments
 (0)