forked from openMF/mifosx
-
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.
add source for individual lending app.
- Loading branch information
1 parent
54189a8
commit ceb30e8
Showing
833 changed files
with
186,628 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...-lending-app/src/main/java/org/mifosng/configuration/ApplicationConfigurationService.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.mifosng.configuration; | ||
|
||
public interface ApplicationConfigurationService { | ||
|
||
OAuthProviderDetails retrieveOAuthProviderDetails(); | ||
|
||
void update(OAuthProviderDetails newDetails); | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...-app/src/main/java/org/mifosng/configuration/InMemoryApplicationConfigurationService.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.mifosng.configuration; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* When application goes down or rebooted, configuration values return to defaults provided here. | ||
*/ | ||
@Service | ||
public class InMemoryApplicationConfigurationService implements | ||
ApplicationConfigurationService { | ||
|
||
private String oauthProviderUrl = "http://localhost:8085/mifosng-provider/"; | ||
private String requestTokenURL = "oauth/request_token"; | ||
private String userAuthorizationURL = "oauth/confirm_access"; | ||
private String accessTokenURL = "oauth/access_token"; | ||
|
||
private String individualLendingResourceConsumerkey = "mifosng-ui-consumer-key"; | ||
private String individualLendingConsumerSharedSecret = "testmifosng"; | ||
|
||
public InMemoryApplicationConfigurationService() { | ||
// | ||
} | ||
|
||
@Override | ||
public OAuthProviderDetails retrieveOAuthProviderDetails() { | ||
|
||
String requestTokenFullUrl = this.oauthProviderUrl | ||
.concat(this.requestTokenURL); | ||
String userAuthorizationFullURL = this.oauthProviderUrl | ||
.concat(this.userAuthorizationURL); | ||
String accessTokenFullURL = this.oauthProviderUrl | ||
.concat(this.accessTokenURL); | ||
|
||
return new OAuthProviderDetails(this.oauthProviderUrl, requestTokenFullUrl, | ||
userAuthorizationFullURL, accessTokenFullURL, | ||
this.individualLendingResourceConsumerkey, | ||
this.individualLendingConsumerSharedSecret); | ||
} | ||
|
||
@Override | ||
public void update(OAuthProviderDetails newDetails) { | ||
this.oauthProviderUrl = newDetails.getProviderBaseUrl(); | ||
if (!this.oauthProviderUrl.endsWith("/")) { | ||
this.oauthProviderUrl = this.oauthProviderUrl.concat("/"); | ||
} | ||
|
||
this.individualLendingResourceConsumerkey = newDetails.getConsumerkey(); | ||
this.individualLendingConsumerSharedSecret = newDetails.getSharedSecret(); | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...-individual-lending-app/src/main/java/org/mifosng/configuration/OAuthProviderDetails.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,56 @@ | ||
package org.mifosng.configuration; | ||
|
||
public class OAuthProviderDetails { | ||
|
||
private final String requestTokenUrl; | ||
private final String userAuthorizationUrl; | ||
private final String accessTokenUrl; | ||
private final String sharedSecret; | ||
private final String consumerkey; | ||
private final String providerBaseUrl; | ||
|
||
public OAuthProviderDetails(String providerBaseUrl, String requestTokenUrl, | ||
String userAuthorizationUrl, String accessTokenUrl, | ||
String consumerkey, String sharedSecret) { | ||
this.providerBaseUrl = providerBaseUrl; | ||
this.requestTokenUrl = requestTokenUrl; | ||
this.userAuthorizationUrl = userAuthorizationUrl; | ||
this.accessTokenUrl = accessTokenUrl; | ||
this.consumerkey = consumerkey; | ||
this.sharedSecret = sharedSecret; | ||
} | ||
|
||
public OAuthProviderDetails(String oauthProviderUrl, String consumerkey, | ||
String sharedSecret) { | ||
this.providerBaseUrl = oauthProviderUrl; | ||
this.consumerkey = consumerkey; | ||
this.sharedSecret = sharedSecret; | ||
this.accessTokenUrl = ""; | ||
this.userAuthorizationUrl = ""; | ||
this.requestTokenUrl = ""; | ||
} | ||
|
||
public String getRequestTokenUrl() { | ||
return requestTokenUrl; | ||
} | ||
|
||
public String getUserAuthorizationUrl() { | ||
return userAuthorizationUrl; | ||
} | ||
|
||
public String getAccessTokenUrl() { | ||
return accessTokenUrl; | ||
} | ||
|
||
public String getSharedSecret() { | ||
return sharedSecret; | ||
} | ||
|
||
public String getConsumerkey() { | ||
return consumerkey; | ||
} | ||
|
||
public String getProviderBaseUrl() { | ||
return providerBaseUrl; | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
mifosng-individual-lending-app/src/main/java/org/mifosng/oauth/ConsumerUserDetails.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,93 @@ | ||
package org.mifosng.oauth; | ||
|
||
import java.util.Collection; | ||
|
||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
|
||
public class ConsumerUserDetails implements UserDetails { | ||
|
||
private final String username; | ||
private final Collection<GrantedAuthority> authorities; | ||
|
||
public ConsumerUserDetails(String username, Collection<GrantedAuthority> authorities) { | ||
this.username = username; | ||
this.authorities = authorities; | ||
} | ||
|
||
@Override | ||
public Collection<? extends GrantedAuthority> getAuthorities() { | ||
return authorities; | ||
} | ||
|
||
@Override | ||
public String getPassword() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
@Override | ||
public boolean isAccountNonExpired() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isAccountNonLocked() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isCredentialsNonExpired() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return true; | ||
} | ||
|
||
public boolean hasNoReportingAuthority() { | ||
return !hasReportingAuthority(); | ||
} | ||
|
||
private boolean hasReportingAuthority() { | ||
SimpleGrantedAuthority reportingAuthority = new SimpleGrantedAuthority("REPORTING_SUPER_USER_ROLE"); | ||
return this.authorities.contains(reportingAuthority); | ||
} | ||
|
||
public boolean hasNoAuthorityToSumitLoanApplication() { | ||
return !hasAuthorityToSumitLoanApplication(); | ||
} | ||
|
||
private boolean hasAuthorityToSumitLoanApplication() { | ||
return containsAnyOf(portfolioAllAuthority(), sumbitLoanApplicationAuthority(), sumbitHistoricLoanApplicationAuthority()); | ||
} | ||
|
||
private boolean containsAnyOf(SimpleGrantedAuthority... authorities) { | ||
boolean match = false; | ||
for (SimpleGrantedAuthority authority : authorities) { | ||
match = this.authorities.contains(authority); | ||
if (match) { | ||
break; | ||
} | ||
} | ||
return match; | ||
} | ||
|
||
private SimpleGrantedAuthority portfolioAllAuthority() { | ||
return new SimpleGrantedAuthority("PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE"); | ||
} | ||
|
||
private SimpleGrantedAuthority sumbitLoanApplicationAuthority() { | ||
return new SimpleGrantedAuthority("CAN_SUBMIT_NEW_LOAN_APPLICATION_ROLE"); | ||
} | ||
|
||
private SimpleGrantedAuthority sumbitHistoricLoanApplicationAuthority() { | ||
return new SimpleGrantedAuthority("CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE"); | ||
} | ||
} |
Oops, something went wrong.