| 1 |
|
package com.atlassian.security.auth.trustedapps; |
| 2 |
|
|
| 3 |
|
import java.security.PublicKey; |
| 4 |
|
|
| 5 |
|
import javax.servlet.http.HttpServletRequest; |
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (32) |
Complexity: 10 |
Complexity Density: 0.45 |
|
| 10 |
|
public class DefaultTrustedApplication implements TrustedApplication |
| 11 |
|
{ |
| 12 |
|
protected final String id; |
| 13 |
|
protected final PublicKey publicKey; |
| 14 |
|
protected final long certificateTimeout; |
| 15 |
|
protected final RequestValidator requestValidator; |
| 16 |
|
protected final EncryptionProvider encryptionProvider; |
| 17 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
| 18 |
14
|
public DefaultTrustedApplication(EncryptionProvider encryptionProvider, PublicKey publicKey, String id, long certificateTimeout, RequestValidator requestValidator)... |
| 19 |
|
{ |
| 20 |
14
|
Null.not("encryptionProvider", encryptionProvider); |
| 21 |
14
|
Null.not("publicKey", publicKey); |
| 22 |
13
|
Null.not("id", id); |
| 23 |
12
|
Null.not("requestValidator", requestValidator); |
| 24 |
|
|
| 25 |
12
|
this.encryptionProvider = encryptionProvider; |
| 26 |
12
|
this.publicKey = publicKey; |
| 27 |
12
|
this.id = id; |
| 28 |
12
|
this.certificateTimeout = certificateTimeout; |
| 29 |
12
|
this.requestValidator = requestValidator; |
| 30 |
|
} |
| 31 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 32 |
1
|
public DefaultTrustedApplication(EncryptionProvider encryptionProvider, PublicKey key, String id, long certificateTimeout, URLMatcher urlMatcher, IPMatcher ipMatcher)... |
| 33 |
|
{ |
| 34 |
1
|
this(encryptionProvider , key, id, certificateTimeout, new DefaultRequestValidator(ipMatcher, urlMatcher)); |
| 35 |
|
} |
| 36 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 37 |
1
|
public DefaultTrustedApplication(PublicKey key, String id, long certificateTimeout, URLMatcher urlMatcher, IPMatcher ipMatcher)... |
| 38 |
|
{ |
| 39 |
1
|
this(new BouncyCastleEncryptionProvider(), key, id, certificateTimeout, urlMatcher, ipMatcher); |
| 40 |
|
} |
| 41 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 42 |
13
|
public ApplicationCertificate decode(EncryptedCertificate encCert, HttpServletRequest request) throws InvalidCertificateException... |
| 43 |
|
{ |
| 44 |
13
|
ApplicationCertificate certificate = encryptionProvider.decodeEncryptedCertificate(encCert, publicKey, getID()); |
| 45 |
|
|
| 46 |
10
|
checkCertificateExpiry(certificate); |
| 47 |
9
|
checkRequest(request); |
| 48 |
|
|
| 49 |
6
|
return certificate; |
| 50 |
|
} |
| 51 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 52 |
20
|
public String getID()... |
| 53 |
|
{ |
| 54 |
20
|
return id; |
| 55 |
|
} |
| 56 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 57 |
1
|
public PublicKey getPublicKey()... |
| 58 |
|
{ |
| 59 |
1
|
return publicKey; |
| 60 |
|
} |
| 61 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 62 |
10
|
private void checkCertificateExpiry(ApplicationCertificate certificate) throws InvalidCertificateException... |
| 63 |
|
{ |
| 64 |
10
|
if (certificate.getCreationTime().getTime() + certificateTimeout <= System.currentTimeMillis()) |
| 65 |
|
{ |
| 66 |
1
|
throw new CertificateTooOldException(certificate, certificateTimeout); |
| 67 |
|
} |
| 68 |
|
} |
| 69 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 70 |
9
|
private void checkRequest(HttpServletRequest request) throws InvalidCertificateException... |
| 71 |
|
{ |
| 72 |
9
|
try |
| 73 |
|
{ |
| 74 |
9
|
requestValidator.validate(request); |
| 75 |
|
} |
| 76 |
|
catch (InvalidRequestException e) |
| 77 |
|
{ |
| 78 |
3
|
throw new InvalidCertificateException(e); |
| 79 |
|
} |
| 80 |
|
} |
| 81 |
|
} |