Skip to content

Commit a0c5f65

Browse files
committed
rollback/remove remotecall interfaces, added test for is deletion call
1 parent 19eb99d commit a0c5f65

5 files changed

Lines changed: 20 additions & 134 deletions

File tree

src/main/java/com/staffbase/plugins/sdk/RemoteCall/AbstractRemoteCallHandler.java

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

src/main/java/com/staffbase/plugins/sdk/RemoteCall/DeleteInstanceCallHandlerInterface.java

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

src/main/java/com/staffbase/plugins/sdk/RemoteCall/RemoteCallInterface.java

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

src/main/java/com/staffbase/plugins/sdk/sso/SSOFacade.java

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import java.util.Objects;
1717

1818

19-
import com.staffbase.plugins.sdk.RemoteCall.DeleteInstanceCallHandlerInterface;
20-
import com.staffbase.plugins.sdk.RemoteCall.RemoteCallInterface;
2119
import org.apache.logging.log4j.LogManager;
2220
import org.apache.logging.log4j.Logger;
2321

@@ -69,12 +67,6 @@ public static SSOFacade create(final RSAPublicKey rsaPublicKey) {
6967
*/
7068
private JwtConsumer jwtConsumer;
7169

72-
/**
73-
* An instance handling remote calls
74-
*/
75-
private RemoteCallInterface remoteCallHandler;
76-
77-
7870
/**********************************************
7971
* Constructors
8072
**********************************************/
@@ -90,19 +82,14 @@ public static SSOFacade create(final RSAPublicKey rsaPublicKey) {
9082
* Initialization
9183
**********************************************/
9284

93-
SSOFacade initialize(final RSAPublicKey rsaPublicKey) {
94-
return this.initialize(rsaPublicKey, null);
95-
}
96-
9785
/**
9886
* Initialize this component by building up the consumer for JWT using the
9987
* pre-configured secret
10088
*
10189
* @param rsaPublicKey the RSA public key to be used for verification.
102-
* @param remoteCallHandler a class handling remote calls
10390
* @return Fluent interface.
10491
*/
105-
SSOFacade initialize(final RSAPublicKey rsaPublicKey, final RemoteCallInterface remoteCallHandler) {
92+
SSOFacade initialize(final RSAPublicKey rsaPublicKey) {
10693

10794
if (logger.isDebugEnabled()) {
10895
logger.debug("Initializing single-sign-on manager SSOFacade. ");
@@ -122,13 +109,9 @@ SSOFacade initialize(final RSAPublicKey rsaPublicKey, final RemoteCallInterface
122109
.setRequireNotBefore()
123110
.setRequireIssuedAt()
124111
.build();
125-
126-
this.remoteCallHandler = remoteCallHandler;
127-
128112
return this;
129113
}
130114

131-
132115
/**********************************************
133116
* Methods
134117
**********************************************/
@@ -175,23 +158,7 @@ public SSOData verify(final String raw) throws SSOException {
175158
}
176159

177160
// Parse and return the container data.
178-
SSOData ssoData = new SSOData(jwtClaims);
179-
if(ssoData.isDeleteInstanceCall() && this.remoteCallHandler != null) {
180-
boolean result = true;
181-
if (this.remoteCallHandler instanceof DeleteInstanceCallHandlerInterface){
182-
result = ((DeleteInstanceCallHandlerInterface) this.remoteCallHandler).deleteInstance(instanceId);
183-
} else {
184-
logger.warn("Warning: An instance deletion call for instance $instanceId was not handled.");
185-
}
186-
187-
if(result){
188-
this.remoteCallHandler.exitSuccess();
189-
} else {
190-
this.remoteCallHandler.exitFailure();
191-
}
192-
exitRemoteCall();
193-
}
194-
return ssoData;
161+
return new SSOData(jwtClaims);
195162
} catch (final MalformedClaimException malformationException) {
196163
if (logger.isFatalEnabled()) {
197164
logger.fatal("Encountered malformed sso attempt.", malformationException);
@@ -206,14 +173,4 @@ public SSOData verify(final String raw) throws SSOException {
206173
throw new SSOException(invalidJwtException.getMessage(), invalidJwtException);
207174
}
208175
}
209-
210-
211-
/**
212-
* @throws SSOException if a remote call was not handled by the user
213-
*/
214-
private void exitRemoteCall() throws SSOException {
215-
String message = "Warning: The exit procedure for a remote call was not properly handled.";
216-
logger.warn(message);
217-
throw new SSOException(message);
218-
}
219176
}

src/test/java/com/staffbase/plugins/sdk/sso/SSODataTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
package com.staffbase.plugins.sdk.sso;
1313

14+
import static org.junit.Assert.assertTrue;
1415
import static org.junit.Assert.fail;
1516
import static org.junit.Assert.assertEquals;
1617
import static org.mockito.Mockito.mock;
@@ -28,6 +29,7 @@
2829
public class SSODataTest {
2930

3031
private static final String ROLE_EDITOR = "editor";
32+
private static final String REMOTE_CALL_DELETE = "delete";
3133

3234
public static final String DATA_INSTANCE_ID = "55c79b6ee4b06c6fb19bd1e2";
3335
public static final String DATA_USER_ID = "541954c3e4b08bbdce1a340a";
@@ -104,4 +106,20 @@ public void createWithJwtClaims() throws MalformedClaimException {
104106

105107
assertEquals(Locale.US, ssoData.getUserLocale().get());
106108
}
109+
110+
/**
111+
* Test deletion claim accessor.
112+
* @throws MalformedClaimException
113+
*/
114+
@Test
115+
public void testWithDeleteJWTClaims() throws MalformedClaimException {
116+
117+
final JwtClaims claims = mock(JwtClaims.class);
118+
119+
when(claims.getClaimValue(SSOData.KEY_INSTANCE_ID, String.class)).thenReturn(DATA_INSTANCE_ID);
120+
when(claims.getClaimValue(SSOData.KEY_USER_ID, String.class)).thenReturn(REMOTE_CALL_DELETE);
121+
122+
final SSOData ssoData = new SSOData(claims);
123+
assertTrue(ssoData.isDeleteInstanceCall());
124+
}
107125
}

0 commit comments

Comments
 (0)