-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/821 bb rest 3lo try2 (#1781)
* #821 MVP code for 3LO auth * Three legged authentication for Blackboard. (Incomplete) * #819 - Courses now cache Co-authored-by: Diego del Blanco <ddelblanco@unicon.net>
- Loading branch information
1 parent
4f76863
commit a04be04
Showing
20 changed files
with
896 additions
and
264 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
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
80 changes: 80 additions & 0 deletions
80
...ore/com.equella.core/src/com/tle/core/connectors/blackboard/BlackboardRestAppContext.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,80 @@ | ||
/* | ||
* Licensed to The Apereo Foundation under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* The Apereo Foundation 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 com.tle.core.connectors.blackboard; | ||
|
||
import com.tle.annotation.Nullable; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URLEncoder; | ||
|
||
public class BlackboardRestAppContext { | ||
private static final String STATE_PARAMETER = "state"; | ||
private static final String FIELD_REDIRECT_URI = "redirect_uri"; | ||
private static final String KEY_VALUE_RESPONSE_TYPE_CODE = "response_type=code"; | ||
private static final String FIELD_CLIENT_ID = "client_id"; | ||
private static final String FIELD_SCOPE = "scope"; | ||
private static final String VALUE_READ_WRITE_DELETE = "read write delete"; | ||
|
||
private final String _appId; | ||
private final String _appKey; | ||
private String _url; | ||
|
||
/** | ||
* Constructs a BlackboardRestAppContext with the provided application values | ||
* | ||
* @param appId The application ID provided by the key tool | ||
* @param appKey The application key provided by the key tool | ||
* @param url The url of the Bb instance | ||
*/ | ||
public BlackboardRestAppContext(String appId, String appKey, String url) { | ||
_appId = appId; | ||
_appKey = appKey; | ||
if (url != null && url.endsWith("/")) { | ||
_url = url.substring(0, url.lastIndexOf("/")); | ||
} else { | ||
_url = url; | ||
} | ||
} | ||
|
||
public URI createWebUrlForAuthentication(URI redirectUrl, @Nullable String state) { | ||
try { | ||
URI uri = | ||
new URI( | ||
_url | ||
+ BlackboardRESTConnectorConstants.AUTHENTICATIONCODE_SERVICE_URI_PATH | ||
+ "?" | ||
+ buildAuthenticationCodeUriQueryString(redirectUrl, state)); | ||
return uri; | ||
} catch (URISyntaxException e) { | ||
return null; | ||
} | ||
} | ||
|
||
private String buildAuthenticationCodeUriQueryString(URI callbackUri, @Nullable String state) { | ||
String callbackUriString = callbackUri.toString(); | ||
String result = KEY_VALUE_RESPONSE_TYPE_CODE; | ||
result += "&" + FIELD_REDIRECT_URI + "=" + callbackUriString; | ||
result += "&" + FIELD_CLIENT_ID + "=" + _appId; | ||
result += "&" + FIELD_SCOPE + "=" + URLEncoder.encode(VALUE_READ_WRITE_DELETE); | ||
if (state != null) { | ||
result += "&" + STATE_PARAMETER + "=" + URLEncoder.encode(state); | ||
} | ||
return result; | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...gins/Core/com.equella.core/src/com/tle/core/connectors/blackboard/beans/CourseByUser.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,34 @@ | ||
/* | ||
* Licensed to The Apereo Foundation under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* The Apereo Foundation 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 com.tle.core.connectors.blackboard.beans; | ||
|
||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement | ||
public class CourseByUser { | ||
private Course course; | ||
|
||
public Course getCourse() { | ||
return course; | ||
} | ||
|
||
public void setCourse(Course course) { | ||
this.course = course; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ins/Core/com.equella.core/src/com/tle/core/connectors/blackboard/beans/CoursesByUser.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,24 @@ | ||
/* | ||
* Licensed to The Apereo Foundation under one or more contributor license | ||
* agreements. See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* The Apereo Foundation 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 com.tle.core.connectors.blackboard.beans; | ||
|
||
import javax.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement | ||
public class CoursesByUser extends PagedResults<CourseByUser> {} |
Oops, something went wrong.