incubator-amber-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmo...@apache.org
Subject svn commit: r1153818 - in /incubator/amber/trunk/oauth-2.0/oauth2-common/src: main/java/org/apache/amber/oauth2/common/domain/ main/java/org/apache/amber/oauth2/common/domain/client/ main/java/org/apache/amber/oauth2/common/domain/credentials/ test/jav...
Date Thu, 04 Aug 2011 10:00:58 GMT
Author: lmoren
Date: Thu Aug  4 10:00:56 2011
New Revision: 1153818

URL: http://svn.apache.org/viewvc?rev=1153818&view=rev
Log:
- added domain classes used by dynamic registration

Added:
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfo.java
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfoBuilder.java
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/ClientInfo.java
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentials.java
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentialsBuilder.java
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/Credentials.java
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/test/java/org/apache/amber/oauth2/common/domain/
    incubator/amber/trunk/oauth-2.0/oauth2-common/src/test/java/org/apache/amber/oauth2/common/domain/BasicClientInfoBuilderTest.java

Added: incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfo.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfo.java?rev=1153818&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfo.java
(added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfo.java
Thu Aug  4 10:00:56 2011
@@ -0,0 +1,175 @@
+/**
+ *       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.common.domain.client;
+
+/**
+ * @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 BasicClientInfo implements ClientInfo {
+
+    protected String name;
+    protected String clientId;
+    protected String clientSecret;
+    protected String redirectUri;
+    protected String clientUri;
+    protected String iconUri;
+    protected Long issuedAt;
+    protected Long expiresIn;
+
+    BasicClientInfo() {
+
+    }
+
+    protected BasicClientInfo(String clientId, String clientSecret, String redirectUri) {
+        this.clientId = clientId;
+        this.clientSecret = clientSecret;
+        this.redirectUri = redirectUri;
+    }
+
+    protected BasicClientInfo(String name, String clientId, String clientSecret, String redirectUri,
+                           String iconUri) {
+        this.name = name;
+        this.clientId = clientId;
+        this.clientSecret = clientSecret;
+        this.redirectUri = redirectUri;
+        this.iconUri = iconUri;
+    }
+
+    @Override
+    public String getClientId() {
+        return clientId;
+    }
+
+    @Override
+    public String getClientSecret() {
+        return clientSecret;
+    }
+
+    @Override
+    public String getRedirectUri() {
+        return redirectUri;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getIconUri() {
+        return iconUri;
+    }
+
+    @Override
+    public String getClientUri() {
+        return clientUri;
+    }
+
+    public void setClientUri(String clientUri) {
+        this.clientUri = clientUri;
+    }
+
+    public Long getIssuedAt() {
+        return issuedAt;
+    }
+
+    public void setIssuedAt(Long issuedAt) {
+        this.issuedAt = issuedAt;
+    }
+
+    public Long getExpiresIn() {
+        return expiresIn;
+    }
+
+    public void setExpiresIn(Long expiresIn) {
+        this.expiresIn = expiresIn;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public void setClientSecret(String clientSecret) {
+        this.clientSecret = clientSecret;
+    }
+
+    public void setRedirectUri(String redirectUri) {
+        this.redirectUri = redirectUri;
+    }
+
+    public void setIconUri(String iconUri) {
+        this.iconUri = iconUri;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        BasicClientInfo that = (BasicClientInfo)o;
+
+        if (clientId != null ? !clientId.equals(that.clientId) : that.clientId != null) {
+            return false;
+        }
+        if (clientSecret != null ? !clientSecret.equals(that.clientSecret) : that.clientSecret
!= null) {
+            return false;
+        }
+        if (expiresIn != null ? !expiresIn.equals(that.expiresIn) : that.expiresIn != null)
{
+            return false;
+        }
+        if (iconUri != null ? !iconUri.equals(that.iconUri) : that.iconUri != null) {
+            return false;
+        }
+        if (issuedAt != null ? !issuedAt.equals(that.issuedAt) : that.issuedAt != null) {
+            return false;
+        }
+        if (name != null ? !name.equals(that.name) : that.name != null) {
+            return false;
+        }
+        if (redirectUri != null ? !redirectUri.equals(that.redirectUri) : that.redirectUri
!= null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = name != null ? name.hashCode() : 0;
+        result = 31 * result + (clientId != null ? clientId.hashCode() : 0);
+        result = 31 * result + (clientSecret != null ? clientSecret.hashCode() : 0);
+        result = 31 * result + (redirectUri != null ? redirectUri.hashCode() : 0);
+        result = 31 * result + (iconUri != null ? iconUri.hashCode() : 0);
+        result = 31 * result + (issuedAt != null ? issuedAt.hashCode() : 0);
+        result = 31 * result + (expiresIn != null ? expiresIn.hashCode() : 0);
+        return result;
+    }
+}

Added: incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfoBuilder.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfoBuilder.java?rev=1153818&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfoBuilder.java
(added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/BasicClientInfoBuilder.java
Thu Aug  4 10:00:56 2011
@@ -0,0 +1,82 @@
+/**
+ *       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.common.domain.client;
+
+/**
+ * @author Maciej Machulak
+ */
+public class BasicClientInfoBuilder {
+
+    private BasicClientInfo info;
+
+    private BasicClientInfoBuilder() {
+        info = new BasicClientInfo();
+    }
+
+    public static BasicClientInfoBuilder clientInfo() {
+        return new BasicClientInfoBuilder();
+    }
+
+    public BasicClientInfo build() {
+        return info;
+    }
+
+    public BasicClientInfoBuilder setName(String value) {
+        info.setName(value);
+        return this;
+    }
+
+    public BasicClientInfoBuilder setClientId(String value) {
+        info.setClientId(value);
+        return this;
+    }
+
+    public BasicClientInfoBuilder setClientUrl(String value) {
+        info.setClientUri(value);
+        return this;
+    }
+
+    public BasicClientInfoBuilder setClientSecret(String value) {
+        info.setClientSecret(value);
+        return this;
+    }
+
+    public BasicClientInfoBuilder setIconUri(String value) {
+        info.setIconUri(value);
+        return this;
+    }
+
+    public BasicClientInfoBuilder setRedirectUri(String value) {
+        info.setRedirectUri(value);
+        return this;
+    }
+
+    public BasicClientInfoBuilder setExpiresIn(Long value) {
+        info.setExpiresIn(value);
+        return this;
+    }
+
+    public BasicClientInfoBuilder setIssuedAt(Long value) {
+        info.setIssuedAt(value);
+        return this;
+    }
+
+}

Added: incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/ClientInfo.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/ClientInfo.java?rev=1153818&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/ClientInfo.java
(added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/client/ClientInfo.java
Thu Aug  4 10:00:56 2011
@@ -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.common.domain.client;
+
+/**
+ * @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 ClientInfo {
+
+    String getClientId();
+
+    String getClientSecret();
+
+    Long getIssuedAt();
+
+    Long getExpiresIn();
+
+    String getRedirectUri();
+
+    String getClientUri();
+
+    String getName();
+
+    String getIconUri();
+}

Added: incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentials.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentials.java?rev=1153818&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentials.java
(added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentials.java
Thu Aug  4 10:00:56 2011
@@ -0,0 +1,105 @@
+/**
+ * Copyright 2011 Newcastle University. All rights reserved.
+ * Maciej Machulak, Lukasz Moren, Aad van Moorsel
+ *
+ * http://research.ncl.ac.uk/smart/
+ */
+
+package org.apache.amber.oauth2.common.domain.credentials;
+
+import java.lang.Long;import java.lang.Object;import java.lang.Override;import java.lang.String;
/**
+ * @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 BasicCredentials implements Credentials {
+
+
+    private String clientId;
+    private String clientSecret;
+    private Long issuedAt;
+    private Long expiresIn;
+
+    BasicCredentials() {
+
+    }
+
+    public BasicCredentials(String clientId, String clientSecret, Long issuedAt, Long expiresIn)
{
+        this.clientId = clientId;
+        this.clientSecret = clientSecret;
+        this.issuedAt = issuedAt;
+        this.expiresIn = expiresIn;
+    }
+
+    @Override
+    public String getClientId() {
+        return clientId;
+    }
+
+    @Override
+    public String getClientSecret() {
+        return clientSecret;
+    }
+
+    @Override
+    public Long getIssuedAt() {
+        return issuedAt;
+    }
+
+    @Override
+    public Long getExpiresIn() {
+        return expiresIn;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
+    public void setClientSecret(String clientSecret) {
+        this.clientSecret = clientSecret;
+    }
+
+    public void setIssuedAt(Long issuedAt) {
+        this.issuedAt = issuedAt;
+    }
+
+    public void setExpiresIn(Long expiresIn) {
+        this.expiresIn = expiresIn;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        BasicCredentials that = (BasicCredentials)o;
+
+        if (clientId != null ? !clientId.equals(that.clientId) : that.clientId != null) {
+            return false;
+        }
+        if (clientSecret != null ? !clientSecret.equals(that.clientSecret) : that.clientSecret
!= null) {
+            return false;
+        }
+        if (expiresIn != null ? !expiresIn.equals(that.expiresIn) : that.expiresIn != null)
{
+            return false;
+        }
+        if (issuedAt != null ? !issuedAt.equals(that.issuedAt) : that.issuedAt != null) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = clientId != null ? clientId.hashCode() : 0;
+        result = 31 * result + (clientSecret != null ? clientSecret.hashCode() : 0);
+        result = 31 * result + (issuedAt != null ? issuedAt.hashCode() : 0);
+        result = 31 * result + (expiresIn != null ? expiresIn.hashCode() : 0);
+        return result;
+    }
+}

Added: incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentialsBuilder.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentialsBuilder.java?rev=1153818&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentialsBuilder.java
(added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/BasicCredentialsBuilder.java
Thu Aug  4 10:00:56 2011
@@ -0,0 +1,41 @@
+package org.apache.amber.oauth2.common.domain.credentials;
+
+/**
+ * @author Maciej Machulak
+ */
+public class BasicCredentialsBuilder {
+
+    protected BasicCredentials credentials;
+
+    private BasicCredentialsBuilder() {
+        credentials = new BasicCredentials();
+    }
+
+    public static BasicCredentialsBuilder credentials() {
+        return new BasicCredentialsBuilder();
+    }
+
+    public BasicCredentials build() {
+        return credentials;
+    }
+
+    public BasicCredentialsBuilder setClientId(String value) {
+        credentials.setClientId(value);
+        return this;
+    }
+
+    public BasicCredentialsBuilder setClientSecret(String value) {
+        credentials.setClientSecret(value);
+        return this;
+    }
+
+    public BasicCredentialsBuilder setExpiresIn(Long value) {
+        credentials.setExpiresIn(value);
+        return this;
+    }
+
+    public BasicCredentialsBuilder setIssuedAt(Long value) {
+        credentials.setIssuedAt(value);
+        return this;
+    }
+}

Added: incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/Credentials.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/Credentials.java?rev=1153818&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/Credentials.java
(added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-common/src/main/java/org/apache/amber/oauth2/common/domain/credentials/Credentials.java
Thu Aug  4 10:00:56 2011
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2011 Newcastle University. All rights reserved.
+ * Maciej Machulak, Lukasz Moren, Aad van Moorsel
+ *
+ * http://research.ncl.ac.uk/smart/
+ */
+
+package org.apache.amber.oauth2.common.domain.credentials;
+
+import java.lang.Long;import java.lang.String; /**
+ * @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 Credentials {
+
+    String getClientId();
+
+    String getClientSecret();
+
+    Long getIssuedAt();
+
+    Long getExpiresIn();
+}

Added: incubator/amber/trunk/oauth-2.0/oauth2-common/src/test/java/org/apache/amber/oauth2/common/domain/BasicClientInfoBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/oauth-2.0/oauth2-common/src/test/java/org/apache/amber/oauth2/common/domain/BasicClientInfoBuilderTest.java?rev=1153818&view=auto
==============================================================================
--- incubator/amber/trunk/oauth-2.0/oauth2-common/src/test/java/org/apache/amber/oauth2/common/domain/BasicClientInfoBuilderTest.java
(added)
+++ incubator/amber/trunk/oauth-2.0/oauth2-common/src/test/java/org/apache/amber/oauth2/common/domain/BasicClientInfoBuilderTest.java
Thu Aug  4 10:00:56 2011
@@ -0,0 +1,44 @@
+package org.apache.amber.oauth2.common.domain;
+
+import org.apache.amber.oauth2.common.domain.client.BasicClientInfo;
+import org.apache.amber.oauth2.common.domain.client.BasicClientInfoBuilder;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Lukasz Moren
+ */
+public class BasicClientInfoBuilderTest {
+
+    public static final String CLIENT_ID = "client_id";
+    public static final String CLIENT_SECRET = "client_secret";
+    public static final String REDIRECT_URI = "redirect_uri";
+    public static final String NAME = "name";
+    public static final String ICON_URI = "icon_uri";
+    public static final Long EXPIRES_IN = 1L;
+    public static final Long ISSUED_AT = 2L;
+
+    @Test
+    public void testNewClientInfo() throws Exception {
+
+        BasicClientInfo basicClientInfo = BasicClientInfoBuilder.clientInfo()
+            .setClientId(CLIENT_ID)
+            .setClientSecret(CLIENT_SECRET)
+            .setRedirectUri(REDIRECT_URI)
+            .setName(NAME)
+            .setIconUri(ICON_URI)
+            .setExpiresIn(EXPIRES_IN)
+            .setIssuedAt(ISSUED_AT)
+            .build();
+
+        Assert.assertNotNull(basicClientInfo);
+
+        Assert.assertEquals(CLIENT_ID, basicClientInfo.getClientId());
+        Assert.assertEquals(CLIENT_SECRET, basicClientInfo.getClientSecret());
+        Assert.assertEquals(REDIRECT_URI, basicClientInfo.getRedirectUri());
+        Assert.assertEquals(NAME, basicClientInfo.getName());
+        Assert.assertEquals(ICON_URI, basicClientInfo.getIconUri());
+        Assert.assertEquals(EXPIRES_IN, basicClientInfo.getExpiresIn());
+        Assert.assertEquals(ISSUED_AT, basicClientInfo.getIssuedAt());
+    }
+}



Mime
View raw message