@Test public void shouldThrowSMSExceptionWhenFailToGetOrgConfig() throws SSOException, SMSException, SignatureException { LoginConfiguration loginConfiguration = mock(LoginConfiguration.class); AuthContextLocalWrapper authContext = mock(AuthContextLocalWrapper.class); given(coreServicesWrapper.getServiceConfigManager("iPlanetAMAuthService", null)).willThrow(SMSException.class); boolean exceptionCaught = false; RestAuthException exception = null; try { authIdHelper.createAuthId(loginConfiguration, authContext); fail(); } catch (RestAuthException e) { exceptionCaught = true; exception = e; } assertTrue(exceptionCaught); assertEquals(exception.getResponse().getStatus(), 500); verify(amKeyProvider, never()).getPrivateKey(anyString()); }
public String createAuthId(LoginConfiguration loginConfiguration, AuthenticationContext authContext) throws SignatureException { String keyAlias = getKeyAlias(authContext.getOrgDN()); Map<String, Object> jwtValues = new HashMap<String, Object>(); if (loginConfiguration.getIndexType().getIndexType() != null && loginConfiguration.getIndexValue() != null) { jwtValues.put("authIndexType", loginConfiguration.getIndexType().getIndexType().toString()); jwtValues.put("authIndexValue", loginConfiguration.getIndexValue()); } jwtValues.put("realm", authContext.getOrgDN()); jwtValues.put("sessionId", authContext.getSessionID().toString()); String authId = generateAuthId(keyAlias, jwtValues); return authId; }
AuthIdHelper { public String createAuthId(LoginConfiguration loginConfiguration, AuthenticationContext authContext) throws SignatureException { String keyAlias = getKeyAlias(authContext.getOrgDN()); Map<String, Object> jwtValues = new HashMap<String, Object>(); if (loginConfiguration.getIndexType().getIndexType() != null && loginConfiguration.getIndexValue() != null) { jwtValues.put("authIndexType", loginConfiguration.getIndexType().getIndexType().toString()); jwtValues.put("authIndexValue", loginConfiguration.getIndexValue()); } jwtValues.put("realm", authContext.getOrgDN()); jwtValues.put("sessionId", authContext.getSessionID().toString()); String authId = generateAuthId(keyAlias, jwtValues); return authId; } }
AuthIdHelper { public String createAuthId(LoginConfiguration loginConfiguration, AuthenticationContext authContext) throws SignatureException { String keyAlias = getKeyAlias(authContext.getOrgDN()); Map<String, Object> jwtValues = new HashMap<String, Object>(); if (loginConfiguration.getIndexType().getIndexType() != null && loginConfiguration.getIndexValue() != null) { jwtValues.put("authIndexType", loginConfiguration.getIndexType().getIndexType().toString()); jwtValues.put("authIndexValue", loginConfiguration.getIndexValue()); } jwtValues.put("realm", authContext.getOrgDN()); jwtValues.put("sessionId", authContext.getSessionID().toString()); String authId = generateAuthId(keyAlias, jwtValues); return authId; } @Inject  AuthIdHelper(CoreServicesWrapper coreServicesWrapper, AMKeyProvider amKeyProvider,
            JwtBuilderFactory jwtBuilderFactory); }
AuthIdHelper { public String createAuthId(LoginConfiguration loginConfiguration, AuthenticationContext authContext) throws SignatureException { String keyAlias = getKeyAlias(authContext.getOrgDN()); Map<String, Object> jwtValues = new HashMap<String, Object>(); if (loginConfiguration.getIndexType().getIndexType() != null && loginConfiguration.getIndexValue() != null) { jwtValues.put("authIndexType", loginConfiguration.getIndexType().getIndexType().toString()); jwtValues.put("authIndexValue", loginConfiguration.getIndexValue()); } jwtValues.put("realm", authContext.getOrgDN()); jwtValues.put("sessionId", authContext.getSessionID().toString()); String authId = generateAuthId(keyAlias, jwtValues); return authId; } @Inject  AuthIdHelper(CoreServicesWrapper coreServicesWrapper, AMKeyProvider amKeyProvider,
            JwtBuilderFactory jwtBuilderFactory); String createAuthId(LoginConfiguration loginConfiguration, AuthenticationContext authContext); SignedJwt reconstructAuthId(String authId); void verifyAuthId(String realmDN, String authId); }
AuthIdHelper { public String createAuthId(LoginConfiguration loginConfiguration, AuthenticationContext authContext) throws SignatureException { String keyAlias = getKeyAlias(authContext.getOrgDN()); Map<String, Object> jwtValues = new HashMap<String, Object>(); if (loginConfiguration.getIndexType().getIndexType() != null && loginConfiguration.getIndexValue() != null) { jwtValues.put("authIndexType", loginConfiguration.getIndexType().getIndexType().toString()); jwtValues.put("authIndexValue", loginConfiguration.getIndexValue()); } jwtValues.put("realm", authContext.getOrgDN()); jwtValues.put("sessionId", authContext.getSessionID().toString()); String authId = generateAuthId(keyAlias, jwtValues); return authId; } @Inject  AuthIdHelper(CoreServicesWrapper coreServicesWrapper, AMKeyProvider amKeyProvider,
            JwtBuilderFactory jwtBuilderFactory); String createAuthId(LoginConfiguration loginConfiguration, AuthenticationContext authContext); SignedJwt reconstructAuthId(String authId); void verifyAuthId(String realmDN, String authId);  }