| DefaultCurrentApplication | Line # 6 | 12 | 5 | 100% |
1.0
|
| (12) | |||
| Result | |||
|
0.7647059
|
com.atlassian.security.auth.trustedapps.TestDefaultTrustedApplicationsManager.testConstructorEncryptionProvider
com.atlassian.security.auth.trustedapps.TestDefaultTrustedApplicationsManager.testConstructorEncryptionProvider
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadRequestUrl
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadRequestUrl
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.TestTrustedApplications.testNonExpiry
com.atlassian.security.auth.trustedapps.TestTrustedApplications.testNonExpiry
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadSecretKey
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadSecretKey
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.TestTrustedApplications.testExpiry
com.atlassian.security.auth.trustedapps.TestTrustedApplications.testExpiry
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.TestTrustedApplications.testRoundTrip
com.atlassian.security.auth.trustedapps.TestTrustedApplications.testRoundTrip
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testKnownAppProtocolVersion0
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testKnownAppProtocolVersion0
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadXForwardIp
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadXForwardIp
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testKnownAppProtocolVersion1
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testKnownAppProtocolVersion1
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadRequestIp
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadRequestIp
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadPublicKey
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadPublicKey
|
1 PASS | |
|
0.23529412
|
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadCertificate
com.atlassian.security.auth.trustedapps.filter.TestTrustedApplicationsFilterAuthenticate.testBadCertificate
|
1 PASS | |
| 1 | package com.atlassian.security.auth.trustedapps; | |
| 2 | ||
| 3 | import java.security.PrivateKey; | |
| 4 | import java.security.PublicKey; | |
| 5 | ||
| 6 | public class DefaultCurrentApplication implements CurrentApplication | |
| 7 | { | |
| 8 | private final EncryptionProvider encryptionProvider; | |
| 9 | ||
| 10 | protected final String id; | |
| 11 | protected final PublicKey publicKey; | |
| 12 | protected final PrivateKey privateKey; | |
| 13 | ||
| 14 | 14 |
public DefaultCurrentApplication(EncryptionProvider encryptionProvider, PublicKey publicKey, PrivateKey privateKey, String id) |
| 15 | { | |
| 16 | 14 | Null.not("encryptionProvider", encryptionProvider); |
| 17 | 14 | Null.not("publicKey", publicKey); |
| 18 | 14 | Null.not("privateKey", privateKey); |
| 19 | 14 | Null.not("id", id); |
| 20 | ||
| 21 | 14 | this.encryptionProvider = encryptionProvider; |
| 22 | 14 | this.publicKey = publicKey; |
| 23 | 14 | this.privateKey = privateKey; |
| 24 | 14 | this.id = id; |
| 25 | } | |
| 26 | ||
| 27 | 13 |
public DefaultCurrentApplication(PublicKey publicKey, PrivateKey privateKey, String id) |
| 28 | { | |
| 29 | 13 | this(new BouncyCastleEncryptionProvider(), publicKey, privateKey, id); |
| 30 | } | |
| 31 | ||
| 32 | /** | |
| 33 | * Returned String can be used as a certificate to talk | |
| 34 | * to the server that trusts this application. I.e. the ID of this app and the certificate go into the following header parameters: | |
| 35 | * {@link CurrentApplication#HEADER_TRUSTED_APP_CERT} | |
| 36 | * {@link CurrentApplication#HEADER_TRUSTED_APP_ID} | |
| 37 | */ | |
| 38 | 11 |
public EncryptedCertificate encode(String userName) |
| 39 | { | |
| 40 | 11 | return encryptionProvider.createEncryptedCertificate(userName, privateKey, getID()); |
| 41 | } | |
| 42 | ||
| 43 | 12 |
public String getID() |
| 44 | { | |
| 45 | 12 | return id; |
| 46 | } | |
| 47 | ||
| 48 | 2 |
public PublicKey getPublicKey() |
| 49 | { | |
| 50 | 2 | return publicKey; |
| 51 | } | |
| 52 | } | |
|
||||||||||