You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oltu.apache.org by to...@apache.org on 2010/12/18 18:00:29 UTC
svn commit: r1050670 - in
/incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/amber/ src/main/java/org/apache/amber/oauth2/
src/main/java/org/...
Author: tommaso
Date: Sat Dec 18 17:00:28 2010
New Revision: 1050670
URL: http://svn.apache.org/viewvc?rev=1050670&view=rev
Log:
[AMBER-12] - import of Leelo OAuth 2.0 implementation - dynamicreg-server module
Added:
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/ (with props)
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/pom.xml (with props)
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/request/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/request/OAuthServerRegistrationRequest.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/response/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/response/OAuthServerRegistrationResponse.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PullValidator.java (with props)
incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PushValidator.java (with props)
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 18 17:00:28 2010
@@ -0,0 +1 @@
+target
Added: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/pom.xml?rev=1050670&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/pom.xml (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/pom.xml Sat Dec 18 17:00:28 2010
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2010 Newcastle University
+
+ http://research.ncl.ac.uk/smart/
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF 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.
+
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>oauth2-dynamicreg-server</artifactId>
+ <name>Apache Amber: OAuth 2.0 Implementation - Dynamic Registration Server</name>
+ <packaging>jar</packaging>
+ <version>0.2-SNAPSHOT</version>
+
+ <parent>
+ <artifactId>amber-oauth2-parent</artifactId>
+ <groupId>org.apache.amber</groupId>
+ <version>0.2-SNAPSHOT</version>
+ </parent>
+
+ <build>
+ <finalName>oauth2-dynamicreg-server</finalName>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.amber</groupId>
+ <artifactId>oauth2-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.amber</groupId>
+ <artifactId>oauth2-authzserver</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.amber</groupId>
+ <artifactId>oauth2-dynamicreg-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
+
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/request/OAuthServerRegistrationRequest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/request/OAuthServerRegistrationRequest.java?rev=1050670&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/request/OAuthServerRegistrationRequest.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/request/OAuthServerRegistrationRequest.java Sat Dec 18 17:00:28 2010
@@ -0,0 +1,110 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.amber.oauth2.ext.dynamicreg.server.request;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.apache.amber.oauth2.common.utils.OAuthUtils;
+import org.apache.amber.oauth2.common.validators.OAuthValidator;
+import org.apache.amber.oauth2.ext.dynamicreg.common.OAuthRegistration;
+import org.apache.amber.oauth2.as.request.OAuthRequest;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.apache.amber.oauth2.ext.dynamicreg.server.validator.PullValidator;
+import org.apache.amber.oauth2.ext.dynamicreg.server.validator.PushValidator;
+
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+public class OAuthServerRegistrationRequest extends OAuthRequest {
+
+ private String type;
+
+ private boolean isDiscovered;
+
+ public OAuthServerRegistrationRequest(HttpServletRequest request)
+ throws OAuthSystemException, OAuthProblemException {
+ this(request, false);
+ }
+
+ public OAuthServerRegistrationRequest(HttpServletRequest request, boolean discover)
+ throws OAuthSystemException, OAuthProblemException {
+ super(request);
+ if (discover) {
+ discover();
+ }
+ }
+
+ @Override
+ protected OAuthValidator initValidator() throws OAuthProblemException, OAuthSystemException {
+ validators.put(OAuthRegistration.Type.PULL, PullValidator.class);
+ validators.put(OAuthRegistration.Type.PUSH, PushValidator.class);
+ type = getParam(OAuthRegistration.Request.TYPE);
+ if (OAuthUtils.isEmpty(type)) {
+ throw OAuthUtils.handleOAuthProblemException("Missing type parameter value");
+ }
+ Class clazz = validators.get(type);
+ if (clazz == null) {
+ throw OAuthUtils.handleOAuthProblemException("Invalid type parameter value");
+ }
+ return (OAuthValidator)OAuthUtils.instantiateClass(clazz);
+ }
+
+ public void discover() throws OAuthSystemException {
+ if (OAuthRegistration.Type.PULL.equals(type)) {
+ // discover
+ }
+ isDiscovered = true;
+ }
+
+ public String getType() {
+ return getParam(OAuthRegistration.Request.TYPE);
+ }
+
+ public String getName() {
+ return getParam(OAuthRegistration.Request.NAME);
+ }
+
+ public String getUrl() {
+ return getParam(OAuthRegistration.Request.URL);
+ }
+
+ public String getDescription() {
+ return getParam(OAuthRegistration.Request.DESCRIPTION);
+ }
+
+ public String getIcon() {
+ return getParam(OAuthRegistration.Request.ICON);
+ }
+
+ public String getRedirectURI() {
+ return getParam(OAuthRegistration.Request.REDIRECT_URI);
+ }
+
+ public boolean isDiscovered() {
+ return isDiscovered;
+ }
+
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/request/OAuthServerRegistrationRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/response/OAuthServerRegistrationResponse.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/response/OAuthServerRegistrationResponse.java?rev=1050670&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/response/OAuthServerRegistrationResponse.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/response/OAuthServerRegistrationResponse.java Sat Dec 18 17:00:28 2010
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.amber.oauth2.ext.dynamicreg.server.response;
+
+import org.apache.amber.oauth2.as.response.OAuthASResponse;
+import org.apache.amber.oauth2.ext.dynamicreg.common.OAuthRegistration;
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+public class OAuthServerRegistrationResponse extends OAuthASResponse {
+
+ protected OAuthServerRegistrationResponse(String url, int responseStatus) {
+ super(url, responseStatus);
+ }
+
+ public static OAuthRegistrationResponseBuilder status(int code) {
+ return new OAuthRegistrationResponseBuilder(code);
+ }
+
+ public static class OAuthRegistrationResponseBuilder extends OAuthResponseBuilder {
+
+ public OAuthRegistrationResponseBuilder(int responseCode) {
+ super(responseCode);
+ }
+
+ public OAuthRegistrationResponseBuilder setClientId(String value) {
+ this.parameters.put(OAuthRegistration.Response.CLIENT_ID, value);
+ return this;
+ }
+
+ public OAuthRegistrationResponseBuilder setClientSecret(String value) {
+ this.parameters.put(OAuthRegistration.Response.CLIENT_SECRET, value);
+ return this;
+ }
+
+ public OAuthRegistrationResponseBuilder setIssuedAt(String value) {
+ this.parameters.put(OAuthRegistration.Response.ISSUED_AT, value);
+ return this;
+ }
+
+ public OAuthRegistrationResponseBuilder setExpiresIn(String value) {
+ this.parameters.put(OAuthRegistration.Response.EXPIRES_IN, value);
+ return this;
+ }
+
+ public OAuthRegistrationResponseBuilder setParam(String key, String value) {
+ this.parameters.put(key, value);
+ return this;
+ }
+
+ public OAuthRegistrationResponseBuilder location(String location) {
+ this.location = location;
+ return this;
+ }
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/response/OAuthServerRegistrationResponse.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PullValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PullValidator.java?rev=1050670&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PullValidator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PullValidator.java Sat Dec 18 17:00:28 2010
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.amber.oauth2.ext.dynamicreg.server.validator;
+
+import org.apache.amber.oauth2.ext.dynamicreg.common.OAuthRegistration;
+import org.apache.amber.oauth2.common.validators.AbstractValidator;
+
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+public class PullValidator extends AbstractValidator {
+
+ public PullValidator() {
+ requiredParams.add(OAuthRegistration.Request.TYPE);
+ requiredParams.add(OAuthRegistration.Request.URL);
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PullValidator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PushValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PushValidator.java?rev=1050670&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PushValidator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PushValidator.java Sat Dec 18 17:00:28 2010
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2010 Newcastle University
+ *
+ * http://research.ncl.ac.uk/smart/
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.apache.amber.oauth2.ext.dynamicreg.server.validator;
+
+import org.apache.amber.oauth2.ext.dynamicreg.common.OAuthRegistration;
+import org.apache.amber.oauth2.common.validators.AbstractValidator;
+
+/**
+ * @author Maciej Machulak (m.p.machulak@ncl.ac.uk)
+ * @author Lukasz Moren (lukasz.moren@ncl.ac.uk)
+ * @author Aad van Moorsel (aad.vanmoorsel@ncl.ac.uk)
+ */
+public class PushValidator extends AbstractValidator {
+
+ public PushValidator() {
+ requiredParams.add(OAuthRegistration.Request.TYPE);
+ requiredParams.add(OAuthRegistration.Request.NAME);
+ requiredParams.add(OAuthRegistration.Request.URL);
+ requiredParams.add(OAuthRegistration.Request.DESCRIPTION);
+ }
+}
Propchange: incubator/amber/trunk/oauth-2.0/oauth2-dynamicreg-server/src/main/java/org/apache/amber/oauth2/ext/dynamicreg/server/validator/PushValidator.java
------------------------------------------------------------------------------
svn:eol-style = native