forked from apereo/cas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up log config; ensure ATs can be encoded correctly
- Loading branch information
Showing
66 changed files
with
238 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ps/src/test/java/org/apereo/cas/support/geo/google/GoogleMapsGeoLocationServiceTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.apereo.cas.support.geo.google; | ||
|
||
import org.apereo.cas.authentication.adaptive.geo.GeoLocationService; | ||
import org.apereo.cas.support.geo.config.GoogleMapsGeoCodingConfiguration; | ||
|
||
import lombok.val; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* This is {@link GoogleMapsGeoLocationServiceTests}. | ||
* | ||
* @author Misagh Moayyed | ||
* @since 6.1.0 | ||
*/ | ||
@SpringBootTest(classes = { | ||
RefreshAutoConfiguration.class, | ||
GoogleMapsGeoCodingConfiguration.class | ||
}) | ||
@TestPropertySource(properties = "cas.googleMaps.apiKey=AIzaSyCea6zDOkwJVIOm0vZyAI5eHYrz9Vzlhi9") | ||
public class GoogleMapsGeoLocationServiceTests { | ||
@Autowired | ||
@Qualifier("geoLocationService") | ||
private GeoLocationService geoLocationService; | ||
|
||
@Test | ||
public void verifyOperation() { | ||
assertNotNull(geoLocationService); | ||
val resp = geoLocationService.locate(40.689060, -74.044636); | ||
assertEquals(40.689060, resp.getLatitude()); | ||
assertEquals(-74.044636, resp.getLongitude()); | ||
assertTrue(resp.getAddresses().isEmpty()); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
support/cas-server-support-geolocation-googlemaps/src/test/resources/log4j2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<Configuration shutdownHook="disable"> | ||
<Appenders> | ||
<Console name="console" target="SYSTEM_OUT"> | ||
<PatternLayout pattern="%highlight{%d %p [%c] - <%m>%n}" /> | ||
</Console> | ||
</Appenders> | ||
<Loggers> | ||
<Logger name="org.apereo" level="warn" additivity="false"> | ||
<AppenderRef ref="console"/> | ||
</Logger> | ||
<Root level="off"> | ||
<AppenderRef ref="console"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...reo/cas/support/oauth/web/response/accesstoken/response/OAuth20JwtAccessTokenEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.apereo.cas.support.oauth.web.response.accesstoken.response; | ||
|
||
import org.apereo.cas.authentication.principal.Service; | ||
import org.apereo.cas.services.RegisteredService; | ||
import org.apereo.cas.support.oauth.services.OAuthRegisteredService; | ||
import org.apereo.cas.ticket.accesstoken.AccessToken; | ||
import org.apereo.cas.token.JwtBuilder; | ||
import org.apereo.cas.util.DateTimeUtils; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.val; | ||
|
||
import java.time.ZoneOffset; | ||
import java.time.ZonedDateTime; | ||
|
||
/** | ||
* This is {@link OAuth20JwtAccessTokenEncoder}. | ||
* | ||
* @author Misagh Moayyed | ||
* @since 6.1.0 | ||
*/ | ||
@Builder | ||
@Getter | ||
public class OAuth20JwtAccessTokenEncoder { | ||
private final JwtBuilder accessTokenJwtBuilder; | ||
private final AccessToken accessToken; | ||
private final RegisteredService registeredService; | ||
private final Service service; | ||
|
||
public String encode() { | ||
val oAuthRegisteredService = OAuthRegisteredService.class.cast(this.registeredService); | ||
val authentication = accessToken.getAuthentication(); | ||
if (oAuthRegisteredService != null && oAuthRegisteredService.isJwtAccessToken()) { | ||
val dt = ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(accessToken.getExpirationPolicy().getTimeToLive()); | ||
val builder = JwtBuilder.JwtRequest.builder(); | ||
|
||
val request = builder | ||
.serviceAudience(service.getId()) | ||
.issueDate(DateTimeUtils.dateOf(authentication.getAuthenticationDate())) | ||
.jwtId(accessToken.getId()) | ||
.subject(authentication.getPrincipal().getId()) | ||
.validUntilDate(DateTimeUtils.dateOf(dt)) | ||
.attributes(authentication.getAttributes()) | ||
.build(); | ||
return accessTokenJwtBuilder.build(request); | ||
} | ||
|
||
return accessToken.getId(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.