This repository has been archived by the owner on Jul 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
66d1687
commit 7160e86
Showing
41 changed files
with
272 additions
and
207 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
47 changes: 47 additions & 0 deletions
47
src/main/java/org/proshin/finapi/accesstoken/FpClientAccessToken.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,47 @@ | ||
/* | ||
* Copyright 2018 Roman Proshin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.proshin.finapi.accesstoken; | ||
|
||
import org.json.JSONObject; | ||
|
||
public final class FpClientAccessToken implements ClientAccessToken { | ||
|
||
private final JSONObject origin; | ||
|
||
public FpClientAccessToken(final JSONObject origin) { | ||
this.origin = origin; | ||
} | ||
|
||
@Override | ||
public String accessToken() { | ||
return this.origin.getString("access_token"); | ||
} | ||
|
||
@Override | ||
public String tokenType() { | ||
return this.origin.getString("token_type"); | ||
} | ||
|
||
@Override | ||
public int expiresIn() { | ||
return this.origin.getInt("expires_in"); | ||
} | ||
|
||
@Override | ||
public String scope() { | ||
return this.origin.getString("scope"); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/org/proshin/finapi/accesstoken/FpUserAccessToken.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,59 @@ | ||
/* | ||
* Copyright 2018 Roman Proshin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.proshin.finapi.accesstoken; | ||
|
||
import java.util.Optional; | ||
import org.json.JSONObject; | ||
import org.proshin.finapi.exception.NoFieldException; | ||
|
||
public final class FpUserAccessToken implements UserAccessToken { | ||
|
||
private final JSONObject origin; | ||
|
||
public FpUserAccessToken(final JSONObject origin) { | ||
this.origin = origin; | ||
} | ||
|
||
@Override | ||
public String accessToken() { | ||
return this.origin.getString("access_token"); | ||
} | ||
|
||
@Override | ||
public String tokenType() { | ||
return this.origin.getString("token_type"); | ||
} | ||
|
||
@Override | ||
public Optional<String> refreshToken() { | ||
final String name = "refresh_token"; | ||
if (this.origin.isNull(name)) { | ||
throw new NoFieldException("Field 'refresh_token' may not be null for user's access token"); | ||
} else { | ||
return Optional.of(this.origin.getString(name)); | ||
} | ||
} | ||
|
||
@Override | ||
public int expiresIn() { | ||
return this.origin.getInt("expires_in"); | ||
} | ||
|
||
@Override | ||
public String scope() { | ||
return this.origin.getString("scope"); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/org/proshin/finapi/accesstoken/SimpleAccessToken.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,30 @@ | ||
/* | ||
* Copyright 2019 Roman Proshin | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.proshin.finapi.accesstoken; | ||
|
||
public class SimpleAccessToken implements AccessToken { | ||
|
||
private final String token; | ||
|
||
public SimpleAccessToken(final String token) { | ||
this.token = token; | ||
} | ||
|
||
@Override | ||
public String accessToken() { | ||
return this.token; | ||
} | ||
} |
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.