You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oltu.apache.org by si...@apache.org on 2010/07/08 21:55:09 UTC
svn commit: r961909 - in
/incubator/amber/trunk/spec-api/src/main/java/org/apache/amber:
AbstractParameter.java OAuthMessageParameter.java OAuthRequestParameter.java
Author: simonetripodi
Date: Thu Jul 8 19:55:08 2010
New Revision: 961909
URL: http://svn.apache.org/viewvc?rev=961909&view=rev
Log:
added OAuth request message and aux request message implementation
Added:
incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/AbstractParameter.java (with props)
incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthMessageParameter.java (with props)
incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthRequestParameter.java (with props)
Added: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/AbstractParameter.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/AbstractParameter.java?rev=961909&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/AbstractParameter.java (added)
+++ incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/AbstractParameter.java Thu Jul 8 19:55:08 2010
@@ -0,0 +1,159 @@
+/*
+ * 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;
+
+import java.util.Map.Entry;
+
+/**
+ *
+ *
+ * @version $Id$
+ * @param <K>
+ */
+abstract class AbstractParameter<N>
+ implements Entry<N, String>, Comparable<AbstractParameter<N>> {
+
+ /**
+ * A non-zero, odd number used as the initial value.
+ */
+ private final static int INITIAL_ODD_NUMBER = 1;
+
+ /**
+ * A non-zero, odd number used as the multiplier.
+ */
+ private static final int MULTIPLIER_ODD_NUMBER = 31;
+
+ /**
+ * The parameter key.
+ */
+ private final N key;
+
+ /**
+ * The parameter value.
+ */
+ private final String value;
+
+ /**
+ * Creates a new parameter by his key and value.
+ *
+ * @param key the parameter key.
+ * @param value the parameter value.
+ */
+ public AbstractParameter(N key, String value) {
+ if (key == null) {
+ throw new IllegalArgumentException("Paramater 'key' must not be null");
+ }
+ if (value == null) {
+ throw new IllegalArgumentException("Paramater 'value' must not be null");
+ }
+ this.key = key;
+ this.value = value;
+ }
+
+ public final int compareTo(AbstractParameter<N> parameter) {
+ int nameComparison = String.valueOf(this.key).compareTo(String.valueOf(parameter.getKey()));
+ if (nameComparison == 0) {
+ return this.value.compareTo(parameter.getValue());
+ }
+ return nameComparison;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final N getKey() {
+ return this.key;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final String getValue() {
+ return this.value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final String setValue(String value) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public final int hashCode() {
+ int result = INITIAL_ODD_NUMBER;
+ result = MULTIPLIER_ODD_NUMBER * result + ((this.key == null) ? 0 : this.key.hashCode());
+ result = MULTIPLIER_ODD_NUMBER * result + ((this.value == null) ? 0 : this.value.hashCode());
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public final boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (this.getClass() != obj.getClass()) {
+ return false;
+ }
+
+ @SuppressWarnings({ "rawtypes" })
+ AbstractParameter other = (AbstractParameter) obj;
+
+ if (this.key == null) {
+ if (other.getKey() != null) {
+ return false;
+ }
+ } else if (!String.valueOf(this.key).equals(String.valueOf(other.getKey()))) {
+ return false;
+ }
+
+ if (this.value == null) {
+ if (other.getValue() != null) {
+ return false;
+ }
+ } else if (!this.value.equals(other.getValue())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return new StringBuilder("Parameter { key=")
+ .append(this.key)
+ .append(", value=")
+ .append(this.value)
+ .append(" }")
+ .toString();
+ }
+
+}
Propchange: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/AbstractParameter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/AbstractParameter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/AbstractParameter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthMessageParameter.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthMessageParameter.java?rev=961909&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthMessageParameter.java (added)
+++ incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthMessageParameter.java Thu Jul 8 19:55:08 2010
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * Identifier for the OAuth Authorization message parameter.
+ *
+ * @version $Id$
+ */
+public final class OAuthMessageParameter extends AbstractParameter<OAuthParameter> {
+
+ public OAuthMessageParameter(OAuthParameter key, String value) {
+ super(key, value);
+ }
+
+}
Propchange: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthMessageParameter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthMessageParameter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthMessageParameter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthRequestParameter.java
URL: http://svn.apache.org/viewvc/incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthRequestParameter.java?rev=961909&view=auto
==============================================================================
--- incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthRequestParameter.java (added)
+++ incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthRequestParameter.java Thu Jul 8 19:55:08 2010
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ * Identifier for the auxiliar OAuth server required parameter.
+ *
+ * @version $Id$
+ */
+public class OAuthRequestParameter extends AbstractParameter<String> {
+
+ public OAuthRequestParameter(String key, String value) {
+ super(key, value);
+ }
+
+}
Propchange: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthRequestParameter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthRequestParameter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: incubator/amber/trunk/spec-api/src/main/java/org/apache/amber/OAuthRequestParameter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain