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xvY2FsaG9zdDo4MDgxLyoiLCJodHRwczovL3Ntcy5zZWM6ODQ0MyIsImh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC90ZXN0Il0sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJTRUFUX01BVENISU5HX0FMTCIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19LCJzbXM0Ijp7InJvbGVzIjpbIlNFQVRfTUFUQ0hJTkciXX19LCJuYW1lIjoiVmFsZXJpeSBUYXJhcHVua2EiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJhZG1pbiIsImdpdmVuX25hbWUiOiJWYWxlcml5IiwiZmFtaWx5X25hbWUiOiJUYXJhcHVua2EiLCJlbWFpbCI6ImFkbWluQHRlc3QuY29tIn0.YRDyKM0LQOY29GQKWPbJ5-zViz1z_TJYD_8RwzJkidzLjahdJ1t0fvfhedpGY0sG_xXChwjsBWqPbJYPbnQC2abtg6eer6DkTwEUWKiYwxgrvpWLCdswOc74X9hrD3pXFyg92jQ1oU493U2iKRHH4nSm0Sfz2-CxpQ6i9dwcbRuSID3uYUAEYvA9NPkZ9TGUyScb8J6BLyJdp21vY5mqLyzMizLry4PqEWyBm4vjmgZbHIwEziYEGDJyCfiPW7mxPY-ZrL5oAQv8XHDvRO-nD8JYAhzz-jXIi7MvRLC8nCMtSggP3TiicFnBXGuyTHNtkkcw01E6G9NlffUrjcGueA"; assertThat(TokenVerifier.getRealm(tokenString), is("test-flyglinjen")); assertThat(TokenVerifier.getRealm(""), is(nullValue())); assertThat(TokenVerifier.getRealm(null), is(nullValue())); }
public static String getRealm(String tokenString) { JWSInput jwtInput; AccessToken token = null; try { jwtInput = new JWSInput(tokenString); token = jwtInput.readJsonContent(AccessToken.class); } catch (Exception e) { logger.error(e.getMessage(), e); return null; } String issuer = token.getIssuer(); Matcher matcher = realmPattern.matcher(issuer); if (matcher.find()) { return matcher.group(1); } return null; }
TokenVerifier { public static String getRealm(String tokenString) { JWSInput jwtInput; AccessToken token = null; try { jwtInput = new JWSInput(tokenString); token = jwtInput.readJsonContent(AccessToken.class); } catch (Exception e) { logger.error(e.getMessage(), e); return null; } String issuer = token.getIssuer(); Matcher matcher = realmPattern.matcher(issuer); if (matcher.find()) { return matcher.group(1); } return null; } }
TokenVerifier { public static String getRealm(String tokenString) { JWSInput jwtInput; AccessToken token = null; try { jwtInput = new JWSInput(tokenString); token = jwtInput.readJsonContent(AccessToken.class); } catch (Exception e) { logger.error(e.getMessage(), e); return null; } String issuer = token.getIssuer(); Matcher matcher = realmPattern.matcher(issuer); if (matcher.find()) { return matcher.group(1); } return null; } protected  TokenVerifier(String tokenString); }
TokenVerifier { public static String getRealm(String tokenString) { JWSInput jwtInput; AccessToken token = null; try { jwtInput = new JWSInput(tokenString); token = jwtInput.readJsonContent(AccessToken.class); } catch (Exception e) { logger.error(e.getMessage(), e); return null; } String issuer = token.getIssuer(); Matcher matcher = realmPattern.matcher(issuer); if (matcher.find()) { return matcher.group(1); } return null; } protected  TokenVerifier(String tokenString); static TokenVerifier create(String tokenString); TokenVerifier publicKey(PublicKey publicKey); TokenVerifier secretKey(SecretKey secretKey); TokenVerifier realm(String realm); TokenVerifier checkTokenType(boolean checkTokenType); TokenVerifier checkActive(boolean checkActive); TokenVerifier checkRealm(boolean checkRealmUrl); TokenVerifier parse(); AccessToken getToken(); JWSHeader getHeader(); static String getRealm(String tokenString); TokenVerifier verify(); }
TokenVerifier { public static String getRealm(String tokenString) { JWSInput jwtInput; AccessToken token = null; try { jwtInput = new JWSInput(tokenString); token = jwtInput.readJsonContent(AccessToken.class); } catch (Exception e) { logger.error(e.getMessage(), e); return null; } String issuer = token.getIssuer(); Matcher matcher = realmPattern.matcher(issuer); if (matcher.find()) { return matcher.group(1); } return null; } protected  TokenVerifier(String tokenString); static TokenVerifier create(String tokenString); TokenVerifier publicKey(PublicKey publicKey); TokenVerifier secretKey(SecretKey secretKey); TokenVerifier realm(String realm); TokenVerifier checkTokenType(boolean checkTokenType); TokenVerifier checkActive(boolean checkActive); TokenVerifier checkRealm(boolean checkRealmUrl); TokenVerifier parse(); AccessToken getToken(); JWSHeader getHeader(); static String getRealm(String tokenString); TokenVerifier verify();  }