incubator-amber-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1050669 [1/2] - in /incubator/amber/trunk/oauth-2.0/oauth2-authzserver: ./ 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/...
Date Sat, 18 Dec 2010 16:58:50 GMT
Author: tommaso
Date: Sat Dec 18 16:58:49 2010
New Revision: 1050669

URL: http://svn.apache.org/viewvc?rev=1050669&view=rev
Log:
[AMBER-12] - import of Leelo OAuth 2.0 implementation - oauthzserver module

Added:
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/pom.xml   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/MD5Generator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuer.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuerImpl.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/UUIDValueGenerator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/ValueGenerator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthAuthzRequest.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthRequest.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthTokenRequest.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/response/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/response/OAuthASResponse.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AssertionValidator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AuthorizationCodeValidator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeTokenValidator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeValidator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/PasswordValidator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/RefreshTokenValidator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/TokenValidator.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/MD5GeneratorTest.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/OAuthIssuerImplTest.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/OAuthRequestTest.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/UUIDValueGeneratorTest.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/response/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/response/OAuthASResponseTest.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/validator/
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/validator/CodeTokenValidatorTest.java   (with props)
    incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/validator/TokenValidatorTest.java   (with props)

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 18 16:58:49 2010
@@ -0,0 +1 @@
+target

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/pom.xml
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/pom.xml?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/pom.xml (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/pom.xml Sat Dec 18 16:58:49 2010
@@ -0,0 +1,74 @@
+<?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">
+    <parent>
+        <groupId>org.apache.amber</groupId>
+        <artifactId>amber-oauth2-parent</artifactId>
+       <version>0.2-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>oauth2-authzserver</artifactId>
+   <version>0.2-SNAPSHOT</version>
+    <name>Apache Amber: OAuth 2.0 Implementation - Authorization Server</name>
+    <packaging>jar</packaging>
+
+    <build>
+        <finalName>oauth2-authzserver</finalName>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.amber</groupId>
+            <artifactId>oauth2-common</artifactId>
+           <version>0.2-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.jettison</groupId>
+            <artifactId>jettison</artifactId>
+            <version>${jettison.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>stax</groupId>
+                    <artifactId>stax-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+            <version>${cxf.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-testutils</artifactId>
+            <version>${cxf.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/MD5Generator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/MD5Generator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/MD5Generator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/MD5Generator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,61 @@
+/**
+ *       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.as.issuer;
+
+import java.security.MessageDigest;
+import java.util.UUID;
+
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+
+
+/**
+ * Exemplar OAuth Token Generator
+ *
+ * @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 MD5Generator implements ValueGenerator {
+
+    @Override
+    public String generateValue() throws OAuthSystemException {
+        return generateValue(UUID.randomUUID().toString());
+    }
+
+    @Override
+    public String generateValue(String param) throws OAuthSystemException {
+        try {
+            MessageDigest algorithm = MessageDigest.getInstance("MD5");
+            algorithm.reset();
+            algorithm.update(param.getBytes());
+            byte[] messageDigest = algorithm.digest();
+            StringBuffer hexString = new StringBuffer();
+            for (int i = 0; i < messageDigest.length; i++) {
+                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
+            }
+
+            return hexString.toString();
+        } catch (Exception e) {
+            throw new OAuthSystemException("OAuth Token cannot be generated.", e);
+        }
+    }
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/MD5Generator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuer.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuer.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuer.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuer.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,37 @@
+/**
+ *       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.as.issuer;
+
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+
+/**
+ * @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 interface OAuthIssuer {
+    public String accessToken() throws OAuthSystemException;
+
+    public String authorizationCode() throws OAuthSystemException;
+
+    public String refreshToken() throws OAuthSystemException;
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuerImpl.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuerImpl.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuerImpl.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuerImpl.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,51 @@
+/**
+ *       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.as.issuer;
+
+
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+
+/**
+ * @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 OAuthIssuerImpl implements OAuthIssuer {
+
+    private ValueGenerator vg;
+
+    public OAuthIssuerImpl(ValueGenerator vg) {
+        this.vg = vg;
+    }
+
+    public String accessToken() throws OAuthSystemException {
+        return vg.generateValue();
+    }
+
+    public String refreshToken() throws OAuthSystemException {
+        return vg.generateValue();
+    }
+
+    public String authorizationCode() throws OAuthSystemException {
+        return vg.generateValue();
+    }
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/OAuthIssuerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/UUIDValueGenerator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/UUIDValueGenerator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/UUIDValueGenerator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/UUIDValueGenerator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,46 @@
+/**
+ *       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.as.issuer;
+
+import java.util.UUID;
+
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+
+/**
+ * Exemplar OAuth Token Generator
+ *
+ * @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 UUIDValueGenerator implements ValueGenerator {
+
+    @Override
+    public String generateValue() throws OAuthSystemException {
+        return generateValue(UUID.randomUUID().toString());
+    }
+
+    @Override
+    public String generateValue(String param) throws OAuthSystemException {
+        return UUID.fromString(UUID.nameUUIDFromBytes(param.getBytes()).toString()).toString();
+    }
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/UUIDValueGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/ValueGenerator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/ValueGenerator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/ValueGenerator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/ValueGenerator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,36 @@
+/**
+ *       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.as.issuer;
+
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+
+
+/**
+ * @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 interface ValueGenerator {
+    public String generateValue() throws OAuthSystemException;
+
+    public String generateValue(String param) throws OAuthSystemException;
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/issuer/ValueGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthAuthzRequest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthAuthzRequest.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthAuthzRequest.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthAuthzRequest.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,66 @@
+/**
+ *       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.as.request;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.as.validator.CodeTokenValidator;
+import org.apache.amber.oauth2.as.validator.CodeValidator;
+import org.apache.amber.oauth2.as.validator.TokenValidator;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.apache.amber.oauth2.common.message.types.ResponseType;
+import org.apache.amber.oauth2.common.utils.OAuthUtils;
+import org.apache.amber.oauth2.common.validators.OAuthValidator;
+import org.apache.amber.oauth2.common.OAuth;
+
+/**
+ * @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 OAuthAuthzRequest extends OAuthRequest {
+
+    public OAuthAuthzRequest(HttpServletRequest request) throws OAuthSystemException, OAuthProblemException {
+        super(request);
+    }
+
+    @Override
+    protected OAuthValidator initValidator() throws OAuthProblemException, OAuthSystemException {
+        //end user authorization validators
+        validators.put(ResponseType.CODE.toString(), CodeValidator.class);
+        validators.put(ResponseType.TOKEN.toString(), TokenValidator.class);
+        validators.put(ResponseType.CODE_AND_TOKEN.toString(), CodeTokenValidator.class);
+        String requestTypeValue = getParam(OAuth.OAUTH_RESPONSE_TYPE);
+        if (OAuthUtils.isEmpty(requestTypeValue)) {
+            throw OAuthUtils.handleOAuthProblemException("Missing response_type parameter value");
+        }
+        Class clazz = validators.get(requestTypeValue);
+        if (clazz == null) {
+            throw OAuthUtils.handleOAuthProblemException("Invalid response_type parameter value");
+        }
+        return (OAuthValidator)OAuthUtils.instantiateClass(clazz);
+
+    }
+
+
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthAuthzRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthRequest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthRequest.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthRequest.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthRequest.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,98 @@
+/**
+ *       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.as.request;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.common.OAuth;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.apache.amber.oauth2.common.utils.OAuthUtils;
+import org.apache.amber.oauth2.common.validators.OAuthValidator;
+
+/**
+ * @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 abstract class OAuthRequest {
+
+    protected HttpServletRequest request;
+    protected OAuthValidator validator;
+    protected Map<String, Class> validators = new HashMap<String, Class>();
+
+    public OAuthRequest(HttpServletRequest request) throws OAuthSystemException, OAuthProblemException {
+        this.request = request;
+        validate();
+    }
+
+    public OAuthRequest() {
+    }
+
+    protected void validate() throws OAuthSystemException, OAuthProblemException {
+        try {
+            validator = initValidator();
+            validator.validateMethod(request);
+            validator.validateContentType(request);
+            validator.validateRequiredParameters(request);
+        } catch (OAuthProblemException e) {
+            String redirectUri = request.getParameter(OAuth.OAUTH_REDIRECT_URI);
+            if (!OAuthUtils.isEmpty(redirectUri)) {
+                e.setRedirectUri(redirectUri);
+            }
+
+            throw e;
+        }
+
+    }
+
+    protected abstract OAuthValidator initValidator() throws OAuthProblemException, OAuthSystemException;
+
+    public String getParam(String name) {
+        return request.getParameter(name);
+    }
+
+    public String getRefreshToken() {
+        return getParam(OAuth.OAUTH_REFRESH_TOKEN);
+    }
+
+    public String getClientId() {
+        return getParam(OAuth.OAUTH_CLIENT_ID);
+    }
+
+    public String getRedirectURI() {
+        return getParam(OAuth.OAUTH_REDIRECT_URI);
+    }
+
+    public String getClientSecret() {
+        return getParam(OAuth.OAUTH_CLIENT_SECRET);
+    }
+
+    public Set<String> getScopes() {
+        String scopes = getParam(OAuth.OAUTH_SCOPE);
+        return OAuthUtils.decodeScopes(scopes);
+    }
+
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthTokenRequest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthTokenRequest.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthTokenRequest.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthTokenRequest.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,91 @@
+/**
+ *       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.as.request;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.as.validator.AuthorizationCodeValidator;
+import org.apache.amber.oauth2.as.validator.AssertionValidator;
+import org.apache.amber.oauth2.as.validator.PasswordValidator;
+import org.apache.amber.oauth2.as.validator.RefreshTokenValidator;
+import org.apache.amber.oauth2.common.OAuth;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.apache.amber.oauth2.common.message.types.GrantType;
+import org.apache.amber.oauth2.common.utils.OAuthUtils;
+import org.apache.amber.oauth2.common.validators.OAuthValidator;
+
+
+/**
+ * @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 OAuthTokenRequest extends OAuthRequest {
+
+
+    public OAuthTokenRequest(HttpServletRequest request) throws OAuthSystemException, OAuthProblemException {
+        super(request);
+    }
+
+    @Override
+    protected OAuthValidator initValidator() throws OAuthProblemException, OAuthSystemException {
+        validators.put(GrantType.PASSWORD.toString(), PasswordValidator.class);
+        validators.put(GrantType.ASSERTION.toString(), AssertionValidator.class);
+        validators.put(GrantType.AUTHORIZATION_CODE.toString(), AuthorizationCodeValidator.class);
+        validators.put(GrantType.REFRESH_TOKEN.toString(), RefreshTokenValidator.class);
+        String requestTypeValue = getParam(OAuth.OAUTH_GRANT_TYPE);
+        if (OAuthUtils.isEmpty(requestTypeValue)) {
+            throw OAuthUtils.handleOAuthProblemException("Missing grant_type parameter value");
+        }
+        Class clazz = validators.get(requestTypeValue);
+        if (clazz == null) {
+            throw OAuthUtils.handleOAuthProblemException("Invalid grant_type parameter value");
+        }
+        return (OAuthValidator)OAuthUtils.instantiateClass(clazz);
+    }
+
+    public String getPassword() {
+        return getParam(OAuth.OAUTH_PASSWORD);
+    }
+
+    public String getUsername() {
+        return getParam(OAuth.OAUTH_USERNAME);
+    }
+
+    public String getAssertion() {
+        return getParam(OAuth.OAUTH_ASSERTION);
+    }
+
+    public String getAssertionType() {
+        return getParam(OAuth.OAUTH_ASSERTION_TYPE);
+    }
+
+    public String getCode() {
+        return getParam(OAuth.OAUTH_CODE);
+    }
+
+    public String getGrantType() {
+        return getParam(OAuth.OAUTH_GRANT_TYPE);
+    }
+
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/request/OAuthTokenRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/response/OAuthASResponse.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/response/OAuthASResponse.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/response/OAuthASResponse.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/response/OAuthASResponse.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,117 @@
+/**
+ *       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.as.response;
+
+
+import org.apache.amber.oauth2.common.OAuth;
+import org.apache.amber.oauth2.common.message.OAuthResponse;
+
+/**
+ * @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 OAuthASResponse extends OAuthResponse {
+
+    protected OAuthASResponse(String uri, int responseStatus) {
+        super(uri, responseStatus);
+    }
+
+    public static OAuthAuthorizationResponseBuilder authorizationResponse(int code) {
+        return new OAuthAuthorizationResponseBuilder(code);
+    }
+
+    public static OAuthTokenResponseBuilder tokenResponse(int code) {
+        return new OAuthTokenResponseBuilder(code);
+    }
+
+    public static class OAuthAuthorizationResponseBuilder extends OAuthResponseBuilder {
+
+        public OAuthAuthorizationResponseBuilder(int responseCode) {
+            super(responseCode);
+        }
+
+        public OAuthAuthorizationResponseBuilder setState(String state) {
+            this.parameters.put(OAuth.OAUTH_STATE, state);
+            return this;
+        }
+
+        public OAuthAuthorizationResponseBuilder setCode(String code) {
+            this.parameters.put(OAuth.OAUTH_CODE, code);
+            return this;
+        }
+
+        public OAuthAuthorizationResponseBuilder setAccessToken(String token) {
+            this.parameters.put(OAuth.OAUTH_ACCESS_TOKEN, token);
+            return this;
+        }
+
+        public OAuthAuthorizationResponseBuilder setExpiresIn(String expiresIn) {
+            this.parameters.put(OAuth.OAUTH_EXPIRES_IN, expiresIn);
+            return this;
+        }
+
+        public OAuthAuthorizationResponseBuilder location(String location) {
+            this.location = location;
+            return this;
+        }
+
+        public OAuthAuthorizationResponseBuilder setParam(String key, String value) {
+            this.parameters.put(key, value);
+            return this;
+        }
+    }
+
+
+    public static class OAuthTokenResponseBuilder extends OAuthResponseBuilder {
+
+        public OAuthTokenResponseBuilder(int responseCode) {
+            super(responseCode);
+        }
+
+        public OAuthTokenResponseBuilder setAccessToken(String token) {
+            this.parameters.put(OAuth.OAUTH_ACCESS_TOKEN, token);
+            return this;
+        }
+
+        public OAuthTokenResponseBuilder setExpiresIn(String expiresIn) {
+            this.parameters.put(OAuth.OAUTH_EXPIRES_IN, expiresIn);
+            return this;
+        }
+
+        public OAuthTokenResponseBuilder setRefreshToken(String refreshToken) {
+            this.parameters.put(OAuth.OAUTH_REFRESH_TOKEN, refreshToken);
+            return this;
+        }
+
+        public OAuthTokenResponseBuilder setParam(String key, String value) {
+            this.parameters.put(key, value);
+            return this;
+        }
+
+        public OAuthTokenResponseBuilder location(String location) {
+            this.location = location;
+            return this;
+        }
+    }
+
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/response/OAuthASResponse.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AssertionValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AssertionValidator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AssertionValidator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AssertionValidator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,42 @@
+/**
+ *       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.as.validator;
+
+
+import org.apache.amber.oauth2.common.OAuth;
+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 AssertionValidator extends AbstractValidator {
+
+    public AssertionValidator() {
+        requiredParams.add(OAuth.OAUTH_GRANT_TYPE);
+        requiredParams.add(OAuth.OAUTH_ASSERTION_TYPE);
+        requiredParams.add(OAuth.OAUTH_ASSERTION);
+    }
+
+
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AssertionValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AuthorizationCodeValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AuthorizationCodeValidator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AuthorizationCodeValidator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AuthorizationCodeValidator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,43 @@
+/**
+ *       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.as.validator;
+
+import org.apache.amber.oauth2.common.OAuth;
+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 AuthorizationCodeValidator extends AbstractValidator {
+
+    public AuthorizationCodeValidator() {
+        requiredParams.add(OAuth.OAUTH_GRANT_TYPE);
+        requiredParams.add(OAuth.OAUTH_CLIENT_ID);
+        requiredParams.add(OAuth.OAUTH_CODE);
+        requiredParams.add(OAuth.OAUTH_REDIRECT_URI);
+        requiredParams.add(OAuth.OAUTH_CLIENT_SECRET);
+    }
+
+
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/AuthorizationCodeValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeTokenValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeTokenValidator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeTokenValidator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeTokenValidator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,58 @@
+/**
+ *       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.as.validator;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.common.OAuth;
+import org.apache.amber.oauth2.common.error.OAuthError;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+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 CodeTokenValidator extends AbstractValidator {
+
+    public CodeTokenValidator() {
+        requiredParams.add(OAuth.OAUTH_RESPONSE_TYPE);
+        requiredParams.add(OAuth.OAUTH_CLIENT_ID);
+        requiredParams.add(OAuth.OAUTH_REDIRECT_URI);
+    }
+
+    @Override
+    public void validateMethod(HttpServletRequest request) throws OAuthProblemException {
+        String method = request.getMethod();
+        if (!method.equals(OAuth.HttpMethod.GET) && !method.equals(OAuth.HttpMethod.POST)) {
+            throw OAuthProblemException.error(OAuthError.CodeResponse.INVALID_REQUEST)
+                .description("Method not correct.");
+        }
+    }
+
+    @Override
+    public void validateContentType(HttpServletRequest request) throws OAuthProblemException {
+    }
+}
+

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeTokenValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeValidator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeValidator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeValidator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,57 @@
+/**
+ *       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.as.validator;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.common.OAuth;
+import org.apache.amber.oauth2.common.error.OAuthError;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+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 CodeValidator extends AbstractValidator {
+
+    public CodeValidator() {
+        requiredParams.add(OAuth.OAUTH_RESPONSE_TYPE);
+        requiredParams.add(OAuth.OAUTH_CLIENT_ID);
+        requiredParams.add(OAuth.OAUTH_REDIRECT_URI);
+    }
+
+    @Override
+    public void validateMethod(HttpServletRequest request) throws OAuthProblemException {
+        String method = request.getMethod();
+        if (!OAuth.HttpMethod.GET.equals(method) && !OAuth.HttpMethod.POST.equals(method)) {
+            throw OAuthProblemException.error(OAuthError.CodeResponse.INVALID_REQUEST)
+                .description("Method not correct.");
+        }
+    }
+
+    @Override
+    public void validateContentType(HttpServletRequest request) throws OAuthProblemException {
+    }
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/CodeValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/PasswordValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/PasswordValidator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/PasswordValidator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/PasswordValidator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,42 @@
+/**
+ *       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.as.validator;
+
+import org.apache.amber.oauth2.common.OAuth;
+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 PasswordValidator extends AbstractValidator {
+
+    public PasswordValidator() {
+
+        requiredParams.add(OAuth.OAUTH_GRANT_TYPE);
+        requiredParams.add(OAuth.OAUTH_CLIENT_ID);
+        requiredParams.add(OAuth.OAUTH_USERNAME);
+        requiredParams.add(OAuth.OAUTH_PASSWORD);
+    }
+
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/PasswordValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/RefreshTokenValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/RefreshTokenValidator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/RefreshTokenValidator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/RefreshTokenValidator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,42 @@
+/**
+ *       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.as.validator;
+
+
+import org.apache.amber.oauth2.common.OAuth;
+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 RefreshTokenValidator extends AbstractValidator {
+
+    public RefreshTokenValidator() {
+        requiredParams.add(OAuth.OAUTH_GRANT_TYPE);
+        requiredParams.add(OAuth.OAUTH_CLIENT_ID);
+        requiredParams.add(OAuth.OAUTH_REFRESH_TOKEN);
+        requiredParams.add(OAuth.OAUTH_CLIENT_SECRET);
+    }
+
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/RefreshTokenValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/TokenValidator.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/TokenValidator.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/TokenValidator.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/TokenValidator.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,56 @@
+/**
+ *       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.as.validator;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.amber.oauth2.common.OAuth;
+import org.apache.amber.oauth2.common.error.OAuthError;
+import org.apache.amber.oauth2.common.exception.OAuthProblemException;
+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 TokenValidator extends AbstractValidator {
+
+    public TokenValidator() {
+        requiredParams.add(OAuth.OAUTH_RESPONSE_TYPE);
+        requiredParams.add(OAuth.OAUTH_CLIENT_ID);
+        requiredParams.add(OAuth.OAUTH_REDIRECT_URI);
+    }
+
+    @Override
+    public void validateMethod(HttpServletRequest request) throws OAuthProblemException {
+        String method = request.getMethod();
+        if (!method.equals(OAuth.HttpMethod.GET) && !method.equals(OAuth.HttpMethod.POST)) {
+            throw OAuthProblemException.error(OAuthError.CodeResponse.INVALID_REQUEST)
+                .description("Method not correct.");
+        }
+    }
+
+    @Override
+    public void validateContentType(HttpServletRequest request) throws OAuthProblemException {
+    }
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/main/java/org/apache/amber/oauth2/as/validator/TokenValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/MD5GeneratorTest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/MD5GeneratorTest.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/MD5GeneratorTest.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/MD5GeneratorTest.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,52 @@
+/**
+ *       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.as;
+
+import junit.framework.Assert;
+
+import org.apache.amber.oauth2.as.issuer.MD5Generator;
+import org.apache.amber.oauth2.as.issuer.ValueGenerator;
+import org.apache.amber.oauth2.common.exception.OAuthSystemException;
+import org.junit.Test;
+
+
+/**
+ * @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 MD5GeneratorTest extends Assert {
+    @Test
+    public void testGenerateValue() throws Exception {
+        ValueGenerator g = new MD5Generator();
+        Assert.assertNotNull(g.generateValue());
+
+        Assert.assertNotNull(g.generateValue("test"));
+
+        try {
+            g.generateValue(null);
+            fail("Exception not thrown");
+        } catch (OAuthSystemException e) {
+            //ok
+        }
+    }
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/MD5GeneratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/OAuthIssuerImplTest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/OAuthIssuerImplTest.java?rev=1050669&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/OAuthIssuerImplTest.java (added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/OAuthIssuerImplTest.java Sat Dec 18 16:58:49 2010
@@ -0,0 +1,53 @@
+/**
+ *       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.as;
+
+import junit.framework.Assert;
+
+import org.apache.amber.oauth2.as.issuer.MD5Generator;
+import org.junit.Test;
+import org.apache.amber.oauth2.as.issuer.OAuthIssuer;
+import org.apache.amber.oauth2.as.issuer.OAuthIssuerImpl;
+
+/**
+ * @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 OAuthIssuerImplTest {
+    private OAuthIssuer issuer = new OAuthIssuerImpl(new MD5Generator());
+
+    @Test
+    public void testAccessToken() throws Exception {
+        Assert.assertNotNull(issuer.accessToken());
+    }
+
+    @Test
+    public void testRefreshToken() throws Exception {
+        Assert.assertNotNull(issuer.refreshToken());
+    }
+
+    @Test
+    public void testAuthorizationCode() throws Exception {
+        Assert.assertNotNull(issuer.authorizationCode());
+    }
+}

Propchange: incubator/amber/trunk/oauth-2.0/oauth2-authzserver/src/test/java/org/apache/amber/oauth2/as/OAuthIssuerImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message