fixed the issues in rest connector

revert-dabc3590
lakshani 8 years ago
parent ffdcd2b217
commit fff1a3f168

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

@ -43,7 +43,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
private static final String DEVICE_MANAGEMENT_SERVICE_TAG[] = {"device_management"}; private static final String DEVICE_MANAGEMENT_SERVICE_TAG[] = {"device_management"};
private static final String APPLICATION_NAME = "appm_restconnector_application"; private static final String APPLICATION_NAME = "appm_restconnector_application";
private static final String PASSWORD_GRANT_TYPE = "password"; 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 ApiApplicationRegistrationService apiApplicationRegistrationService;
private TokenIssuerService tokenIssuerService; private TokenIssuerService tokenIssuerService;
@ -74,7 +74,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
if (tokenInfo == null) { if (tokenInfo == null) {
ApiRegistrationProfile apiRegistrationProfile = new ApiRegistrationProfile(); ApiRegistrationProfile apiRegistrationProfile = new ApiRegistrationProfile();
apiRegistrationProfile.setApplicationName(APPLICATION_NAME); apiRegistrationProfile.setApplicationName(APPLICATION_NAME);
apiRegistrationProfile.setIsAllowedToAllDomains(true); apiRegistrationProfile.setIsAllowedToAllDomains(false);
apiRegistrationProfile.setIsMappingAnExistingOAuthApp(false); apiRegistrationProfile.setIsMappingAnExistingOAuthApp(false);
apiRegistrationProfile.setTags(DEVICE_MANAGEMENT_SERVICE_TAG); apiRegistrationProfile.setTags(DEVICE_MANAGEMENT_SERVICE_TAG);
ApiApplicationKey apiApplicationKey = apiApplicationRegistrationService.register(apiRegistrationProfile); ApiApplicationKey apiApplicationKey = apiApplicationRegistrationService.register(apiRegistrationProfile);
@ -87,15 +87,15 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
.contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder())
.target(TokenIssuerService.class, AuthorizationConfigurationManager.getInstance().getTokenApiURL()); .target(TokenIssuerService.class, AuthorizationConfigurationManager.getInstance().getTokenApiURL());
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password); tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password);
tokenInfo.setExpiresIn(System.currentTimeMillis() + tokenInfo.getExpiresIn()); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
} }
synchronized (this) { synchronized (this) {
if (System.currentTimeMillis() + Long.parseLong(refreshTimeOffset) > tokenInfo.getExpiresIn()) { if (System.currentTimeMillis() + Long.parseLong(refreshTimeOffset) > tokenInfo.getExpires_in()) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefreshToken()); tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token());
tokenInfo.setExpiresIn(System.currentTimeMillis() + tokenInfo.getExpiresIn()); 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); 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. * This hold access token info that returned from the api call.
*/ */
public class AccessTokenInfo { public class AccessTokenInfo {
public String tokenType; public String token_type;
public long expiresIn; public long expires_in;
public String refreshToken; public String refresh_token;
public String accessToken; public String access_token;
public String getTokenType() { public String getToken_type() {
return tokenType; return token_type;
} }
public void setTokenType(String tokenType) { public void setToken_type(String token_type) {
this.tokenType = tokenType; this.token_type = token_type;
} }
public long getExpiresIn() { public long getExpires_in() {
return expiresIn; return expires_in;
} }
public void setExpiresIn(long expiresIn) { public void setExpires_in(long expires_in) {
this.expiresIn = expiresIn; this.expires_in = expires_in;
} }
public String getRefreshToken() { public String getRefresh_token() {
return refreshToken; return refresh_token;
} }
public void setRefreshToken(String refreshToken) { public void setRefresh_token(String refresh_token) {
this.refreshToken = refreshToken; this.refresh_token = refresh_token;
} }
public String getAccessToken() { public String getAccess_token() {
return accessToken; return access_token;
} }
public void setAccessToken(String accessToken) { public void setAccess_token(String access_token) {
this.accessToken = accessToken; 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. * This holds api application consumer key and secret.
*/ */
public class ApiApplicationKey { public class ApiApplicationKey {
private String clientId; private String client_id;
private String clientSecret; private String client_secret;
public String getConsumerKey() { public String getConsumerKey() {
return this.clientId; return this.client_id;
} }
public void setClientId(String consumerKey) { public void setClient_id(String consumerKey) {
this.clientId = consumerKey; this.client_id = consumerKey;
} }
public String getConsumerSecret() { public String getConsumerSecret() {
return this.clientSecret; return this.client_secret;
} }
public void setClientSecret(String consumerSecret) { public void setClient_secret(String consumerSecret) {
this.clientSecret = consumerSecret; this.client_secret = consumerSecret;
} }
} }

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

Loading…
Cancel
Save