@Test public void shouldCreateAuthIdIncludingAuthIndexTypeAndValue() throws SignatureException, SMSException, SSOException { LoginConfiguration loginConfiguration = mock(LoginConfiguration.class); AuthContextLocalWrapper authContext = mock(AuthContextLocalWrapper.class); given(authContext.getOrgDN()).willReturn("ORG_DN"); given(authContext.getSessionID()).willReturn(new SessionID("SESSION_ID")); given(loginConfiguration.getIndexType()).willReturn(AuthIndexType.SERVICE); given(loginConfiguration.getIndexValue()).willReturn("INDEX_VALUE"); mockGetKeyAliasMethod("ORG_DN", false); PrivateKey privateKey = mock(PrivateKey.class); given(amKeyProvider.getPrivateKey("KEY_ALIAS")).willReturn(privateKey); String authId = authIdHelper.createAuthId(loginConfiguration, authContext); assertNotNull(authId); verify(jwsHeaderBuilder).alg(JwsAlgorithm.HS256); verify(claimsSetBuilder).claim(eq("otk"), anyString()); ArgumentCaptor<Map> argumentCaptor = ArgumentCaptor.forClass(Map.class); verify(claimsSetBuilder).claims(argumentCaptor.capture()); Map jwtValues = argumentCaptor.getValue(); assertTrue(jwtValues.containsKey("realm")); assertTrue(jwtValues.containsValue("ORG_DN")); assertTrue(jwtValues.containsKey("sessionId")); assertTrue(jwtValues.containsValue("SESSION_ID")); assertTrue(jwtValues.containsKey("authIndexType")); assertTrue(jwtValues.containsValue(AuthIndexType.SERVICE.getIndexType().toString())); assertTrue(jwtValues.containsKey("authIndexValue")); assertTrue(jwtValues.containsValue("INDEX_VALUE")); }
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);  }