-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jaadds/openkm
Regenerating Application Access Tokens without Accessing Database.
- Loading branch information
Showing
10 changed files
with
746 additions
and
76 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
119 changes: 119 additions & 0 deletions
119
...so2.carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/AccessTokenInfo.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,119 @@ | ||
/* | ||
* | ||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.apimgt.api.model; | ||
|
||
import org.json.simple.JSONObject; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* Details about an Access Token. | ||
*/ | ||
public class AccessTokenInfo { | ||
|
||
private String consumerKey; | ||
|
||
private String[] scope; | ||
|
||
private String tokenState; | ||
|
||
private String accessToken; | ||
|
||
private long issuedTime; | ||
|
||
private long validityPeriod; | ||
|
||
public String[] getScope() { | ||
return scope; | ||
} | ||
|
||
public void setScope(String[] scope) { | ||
this.scope = scope; | ||
} | ||
|
||
public String getTokenState() { | ||
return tokenState; | ||
} | ||
|
||
public void setTokenState(String tokenState) { | ||
this.tokenState = tokenState; | ||
} | ||
|
||
public String getAccessToken() { | ||
return accessToken; | ||
} | ||
|
||
public void setAccessToken(String accessToken) { | ||
this.accessToken = accessToken; | ||
} | ||
|
||
public long getIssuedTime() { | ||
return issuedTime; | ||
} | ||
|
||
public long getValidityPeriod() { | ||
return validityPeriod; | ||
} | ||
|
||
private HashMap<String,Object> parameters = new HashMap<String, Object>(); | ||
|
||
public String getConsumerKey() { | ||
return consumerKey; | ||
} | ||
|
||
public void setConsumerKey(String consumerKey) { | ||
this.consumerKey = consumerKey; | ||
} | ||
|
||
public void setIssuedTime(long issuedTime) { | ||
this.issuedTime = issuedTime; | ||
} | ||
|
||
public void setValidityPeriod(long validityPeriod) { | ||
this.validityPeriod = validityPeriod; | ||
} | ||
|
||
public void addParameter(String paramName, Object paramValue){ | ||
parameters.put(paramName,paramName); | ||
} | ||
|
||
public Object getParameter(String paramName){ | ||
return parameters.get(paramName); | ||
} | ||
|
||
/** | ||
* Sending additional properties as a JSON String. | ||
*/ | ||
public String getJSONString(){ | ||
|
||
if(!parameters.containsKey("scopes")){ | ||
parameters.put("scopes",scope); | ||
} | ||
|
||
if(!parameters.containsKey("tokenState")){ | ||
parameters.put("tokenState",tokenState); | ||
} | ||
|
||
return JSONObject.toJSONString(parameters); | ||
} | ||
|
||
} |
145 changes: 145 additions & 0 deletions
145
....carbon.apimgt.api/src/main/java/org/wso2/carbon/apimgt/api/model/AccessTokenRequest.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,145 @@ | ||
/* | ||
* | ||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you 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.wso2.carbon.apimgt.api.model; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Representation of a Token Generation Request. | ||
*/ | ||
public class AccessTokenRequest { | ||
private String clientId; | ||
private String clientSecret; | ||
private String grantType; | ||
private String[] scope; | ||
private String callbackURI; | ||
private String resourceOwnerUsername; | ||
private String resourceOwnerPassword; | ||
private String refreshToken; | ||
private String tenantDomain; | ||
private long validityPeriod; | ||
private String tokenToRevoke; | ||
|
||
// This map can be used to store additional properties not captured by above list of fields. | ||
private HashMap<String,Object> requestParameters = new HashMap<String, Object>(); | ||
|
||
|
||
public String getTokenToRevoke() { | ||
return tokenToRevoke; | ||
} | ||
|
||
public void setTokenToRevoke(String tokenToRevoke) { | ||
this.tokenToRevoke = tokenToRevoke; | ||
} | ||
|
||
public String getClientId() { | ||
return clientId; | ||
} | ||
|
||
public void setClientId(String clientId) { | ||
this.clientId = clientId; | ||
} | ||
|
||
public String getClientSecret() { | ||
return clientSecret; | ||
} | ||
|
||
public void setClientSecret(String clientSecret) { | ||
this.clientSecret = clientSecret; | ||
} | ||
|
||
public String getGrantType() { | ||
return grantType; | ||
} | ||
|
||
public void setGrantType(String grantType) { | ||
this.grantType = grantType; | ||
} | ||
|
||
public String[] getScope() { | ||
return scope; | ||
} | ||
|
||
public void setScope(String[] scope) { | ||
this.scope = scope; | ||
} | ||
|
||
public String getCallbackURI() { | ||
return callbackURI; | ||
} | ||
|
||
public void setCallbackURI(String callbackURI) { | ||
this.callbackURI = callbackURI; | ||
} | ||
|
||
public long getValidityPeriod(){ | ||
return this.validityPeriod; | ||
} | ||
|
||
public void setValidityPeriod(long validityPeriod){ | ||
this.validityPeriod = validityPeriod; | ||
} | ||
|
||
public String getResourceOwnerUsername() { | ||
return resourceOwnerUsername; | ||
} | ||
|
||
public void setResourceOwnerUsername(String resourceOwnerUsername) { | ||
this.resourceOwnerUsername = resourceOwnerUsername; | ||
} | ||
|
||
public String getResourceOwnerPassword() { | ||
return resourceOwnerPassword; | ||
} | ||
|
||
public void setResourceOwnerPassword(String resourceOwnerPassword) { | ||
this.resourceOwnerPassword = resourceOwnerPassword; | ||
} | ||
|
||
public String getRefreshToken() { | ||
return refreshToken; | ||
} | ||
|
||
public void setRefreshToken(String refreshToken) { | ||
this.refreshToken = refreshToken; | ||
} | ||
|
||
|
||
public String getTenantDomain() { | ||
return tenantDomain; | ||
} | ||
|
||
public void setTenantDomain(String tenantDomain) { | ||
this.tenantDomain = tenantDomain; | ||
} | ||
|
||
public void addRequestParam(String paramName, Object paramValue){ | ||
requestParameters.put(paramName,paramValue); | ||
} | ||
|
||
public Object getRequestParam(String key){ | ||
return requestParameters.get(key); | ||
} | ||
|
||
|
||
} | ||
|
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.