Example usage for org.springframework.boot.actuate.autoconfigure.cloudfoundry Token Token

List of usage examples for org.springframework.boot.actuate.autoconfigure.cloudfoundry Token Token

Introduction

In this page you can find the example usage for org.springframework.boot.actuate.autoconfigure.cloudfoundry Token Token.

Prototype

public Token(String encoded) 

Source Link

Usage

From source file:org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.TokenValidatorTests.java

@Test
public void validateTokenWhenExpiredShouldThrowException() throws Exception {
    given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
    given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
    String header = "{ \"alg\": \"RS256\",  \"kid\": \"valid-key\", \"typ\": \"JWT\"}";
    String claims = "{ \"jti\": \"0236399c350c47f3ae77e67a75e75e7d\", \"exp\": 1477509977, \"scope\": [\"actuator.read\"]}";
    this.thrown.expect(AuthorizationExceptionMatcher.withReason(Reason.TOKEN_EXPIRED));
    this.tokenValidator.validate(new Token(getSignedToken(header.getBytes(), claims.getBytes())));
}

From source file:org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.TokenValidatorTests.java

@Test
public void validateTokenWhenIssuerIsNotValidShouldThrowException() throws Exception {
    given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
    given(this.securityService.getUaaUrl()).willReturn("http://other-uaa.com");
    String header = "{ \"alg\": \"RS256\",  \"kid\": \"valid-key\", \"typ\": \"JWT\", \"scope\": [\"actuator.read\"]}";
    String claims = "{ \"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\"}";
    this.thrown.expect(AuthorizationExceptionMatcher.withReason(Reason.INVALID_ISSUER));
    this.tokenValidator.validate(new Token(getSignedToken(header.getBytes(), claims.getBytes())));
}

From source file:org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.TokenValidatorTests.java

@Test
public void validateTokenWhenAudienceIsNotValidShouldThrowException() throws Exception {
    given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
    given(this.securityService.getUaaUrl()).willReturn("http://localhost:8080/uaa");
    String header = "{ \"alg\": \"RS256\",  \"kid\": \"valid-key\", \"typ\": \"JWT\"}";
    String claims = "{ \"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"foo.bar\"]}";
    this.thrown.expect(AuthorizationExceptionMatcher.withReason(Reason.INVALID_AUDIENCE));
    this.tokenValidator.validate(new Token(getSignedToken(header.getBytes(), claims.getBytes())));
}