fixed the issues in rest connector

revert-dabc3590
lakshani 8 years ago
parent ffdcd2b217
commit fff1a3f168

@ -85,7 +85,8 @@
feign,
feign.auth,
feign.codec,
feign.gson
feign.gson,
*;resolution:=optional
</Import-Package>
<Export-Package>
!org.wso2.carbon.appmgt.mdm.restconnector.internal,
@ -93,7 +94,8 @@
</Export-Package>
<Embed-Dependency>
jsr311-api,
feign-jaxrs
feign-jaxrs,
org.wso2.carbon.device.mgt.common
</Embed-Dependency>
</instructions>
</configuration>

@ -43,7 +43,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
private static final String DEVICE_MANAGEMENT_SERVICE_TAG[] = {"device_management"};
private static final String APPLICATION_NAME = "appm_restconnector_application";
private static final String PASSWORD_GRANT_TYPE = "password";
private static final String REFRESH_GRANT_TYPE = "refreshToken";
private static final String REFRESH_GRANT_TYPE = "refresh_token";
private ApiApplicationRegistrationService apiApplicationRegistrationService;
private TokenIssuerService tokenIssuerService;
@ -74,7 +74,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
if (tokenInfo == null) {
ApiRegistrationProfile apiRegistrationProfile = new ApiRegistrationProfile();
apiRegistrationProfile.setApplicationName(APPLICATION_NAME);
apiRegistrationProfile.setIsAllowedToAllDomains(true);
apiRegistrationProfile.setIsAllowedToAllDomains(false);
apiRegistrationProfile.setIsMappingAnExistingOAuthApp(false);
apiRegistrationProfile.setTags(DEVICE_MANAGEMENT_SERVICE_TAG);
ApiApplicationKey apiApplicationKey = apiApplicationRegistrationService.register(apiRegistrationProfile);
@ -87,15 +87,15 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
.contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder())
.target(TokenIssuerService.class, AuthorizationConfigurationManager.getInstance().getTokenApiURL());
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password);
tokenInfo.setExpiresIn(System.currentTimeMillis() + tokenInfo.getExpiresIn());
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
}
synchronized (this) {
if (System.currentTimeMillis() + Long.parseLong(refreshTimeOffset) > tokenInfo.getExpiresIn()) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefreshToken());
tokenInfo.setExpiresIn(System.currentTimeMillis() + tokenInfo.getExpiresIn());
if (System.currentTimeMillis() + Long.parseLong(refreshTimeOffset) > tokenInfo.getExpires_in()) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token());
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
}
}
String headerValue = Constants.RestConstants.BEARER + tokenInfo.getAccessToken();
String headerValue = Constants.RestConstants.BEARER + tokenInfo.getAccess_token();
template.header(Constants.RestConstants.AUTHORIZATION, headerValue);
}
}

@ -21,40 +21,40 @@ package org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto;
* This hold access token info that returned from the api call.
*/
public class AccessTokenInfo {
public String tokenType;
public long expiresIn;
public String refreshToken;
public String accessToken;
public String token_type;
public long expires_in;
public String refresh_token;
public String access_token;
public String getTokenType() {
return tokenType;
public String getToken_type() {
return token_type;
}
public void setTokenType(String tokenType) {
this.tokenType = tokenType;
public void setToken_type(String token_type) {
this.token_type = token_type;
}
public long getExpiresIn() {
return expiresIn;
public long getExpires_in() {
return expires_in;
}
public void setExpiresIn(long expiresIn) {
this.expiresIn = expiresIn;
public void setExpires_in(long expires_in) {
this.expires_in = expires_in;
}
public String getRefreshToken() {
return refreshToken;
public String getRefresh_token() {
return refresh_token;
}
public void setRefreshToken(String refreshToken) {
this.refreshToken = refreshToken;
public void setRefresh_token(String refresh_token) {
this.refresh_token = refresh_token;
}
public String getAccessToken() {
return accessToken;
public String getAccess_token() {
return access_token;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
public void setAccess_token(String access_token) {
this.access_token = access_token;
}
}

@ -21,22 +21,22 @@ package org.wso2.carbon.appmgt.mdm.restconnector.authorization.client.dto;
* This holds api application consumer key and secret.
*/
public class ApiApplicationKey {
private String clientId;
private String clientSecret;
private String client_id;
private String client_secret;
public String getConsumerKey() {
return this.clientId;
return this.client_id;
}
public void setClientId(String consumerKey) {
this.clientId = consumerKey;
public void setClient_id(String consumerKey) {
this.client_id = consumerKey;
}
public String getConsumerSecret() {
return this.clientSecret;
return this.client_secret;
}
public void setClientSecret(String consumerSecret) {
this.clientSecret = consumerSecret;
public void setClient_secret(String consumerSecret) {
this.client_secret = consumerSecret;
}
}

@ -1244,7 +1244,7 @@
<javax.ws.rs.version>1.1.1</javax.ws.rs.version>
<!-- Carbon Device Management -->
<carbon.devicemgt.version>2.0.11</carbon.devicemgt.version>
<carbon.devicemgt.version>2.0.13</carbon.devicemgt.version>
<carbon.devicemgt.version.range>[2.0.0, 3.0.0)</carbon.devicemgt.version.range>
<!-- Carbon App Management -->

Loading…
Cancel
Save