Skip to content

Commit a490519

Browse files
committed
Simplify BasicAuth.parseCredentials()
1 parent beecd39 commit a490519

File tree

1 file changed

+6
-9
lines changed
  • oauth2-server-core/src/main/java/nl/myndocs/oauth2/request/auth

1 file changed

+6
-9
lines changed

oauth2-server-core/src/main/java/nl/myndocs/oauth2/request/auth/BasicAuth.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ object BasicAuth {
88
var password: String? = null
99

1010
if (authorization.startsWith("basic ", true)) {
11+
val basicAuthorizationString = String(Base64.getDecoder().decode(authorization.substring(6)))
1112

12-
val basicAuthorizationString = String(
13-
Base64.getDecoder().decode(authorization.substring(6))
14-
)
15-
16-
val splittedString = basicAuthorizationString.split(":")
17-
18-
if (splittedString.size == 2) {
19-
username = splittedString[0]
20-
password = splittedString[1]
13+
with(basicAuthorizationString.split(":")) {
14+
if (this.size == 2) {
15+
username = this[0]
16+
password = this[1]
17+
}
2118
}
2219
}
2320

0 commit comments

Comments
 (0)