-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
92 changed files
with
3,083 additions
and
630 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
/bin |
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
9 changes: 9 additions & 0 deletions
9
...c/main/java/org/cloudfoundry/identity/uaa/authentication/AccountNotVerifiedException.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,9 @@ | ||
package org.cloudfoundry.identity.uaa.authentication; | ||
|
||
import org.springframework.security.authentication.AccountStatusException; | ||
|
||
public class AccountNotVerifiedException extends AccountStatusException { | ||
public AccountNotVerifiedException(String msg) { | ||
super(msg); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...a/org/cloudfoundry/identity/uaa/authentication/AccountNotVerifiedExceptionTranslator.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,52 @@ | ||
package org.cloudfoundry.identity.uaa.authentication; | ||
|
||
import org.cloudfoundry.identity.uaa.authentication.AccountNotVerifiedException; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; | ||
import org.springframework.security.oauth2.provider.error.DefaultWebResponseExceptionTranslator; | ||
|
||
import java.io.IOException; | ||
|
||
public class AccountNotVerifiedExceptionTranslator extends DefaultWebResponseExceptionTranslator{ | ||
|
||
@Override | ||
public ResponseEntity<OAuth2Exception> translate(Exception e) throws Exception { | ||
if (e instanceof AccountNotVerifiedException) { | ||
return handleOAuth2Exception(new ForbiddenException(e.getMessage(), e)); | ||
} | ||
|
||
return super.translate(e); | ||
} | ||
|
||
private ResponseEntity<OAuth2Exception> handleOAuth2Exception(OAuth2Exception e) throws IOException { | ||
|
||
int status = e.getHttpErrorCode(); | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.set("Cache-Control", "no-store"); | ||
headers.set("Pragma", "no-cache"); | ||
|
||
ResponseEntity<OAuth2Exception> response = new ResponseEntity<OAuth2Exception>(e, headers, | ||
HttpStatus.valueOf(status)); | ||
|
||
return response; | ||
|
||
} | ||
|
||
private static class ForbiddenException extends OAuth2Exception { | ||
|
||
public ForbiddenException(String msg, Throwable t) { | ||
super(msg, t); | ||
} | ||
|
||
public String getOAuth2ErrorCode() { | ||
return "access_denied"; | ||
} | ||
|
||
public int getHttpErrorCode() { | ||
return 403; | ||
} | ||
|
||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...org/cloudfoundry/identity/uaa/authentication/event/UnverifiedUserAuthenticationEvent.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,28 @@ | ||
package org.cloudfoundry.identity.uaa.authentication.event; | ||
|
||
import org.cloudfoundry.identity.uaa.audit.AuditEvent; | ||
import org.cloudfoundry.identity.uaa.audit.AuditEventType; | ||
import org.cloudfoundry.identity.uaa.user.UaaUser; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.util.Assert; | ||
|
||
public class UnverifiedUserAuthenticationEvent extends AbstractUaaAuthenticationEvent { | ||
|
||
private final UaaUser user; | ||
|
||
public UnverifiedUserAuthenticationEvent(UaaUser user, Authentication authentication) { | ||
super(authentication); | ||
Assert.notNull(user, "UaaUser object cannot be null"); | ||
this.user = user; | ||
} | ||
|
||
@Override | ||
public AuditEvent getAuditEvent() { | ||
return createAuditRecord(user.getId(), AuditEventType.UnverifiedUserAuthentication, getOrigin(getAuthenticationDetails()), | ||
user.getUsername()); | ||
} | ||
|
||
public UaaUser getUser() { | ||
return user; | ||
} | ||
} |
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
Oops, something went wrong.