Author: sergeyb
Date: Sun Mar 3 19:00:46 2013
New Revision: 1452102
URL: http://svn.apache.org/r1452102
Log:
Minor update to OAuth2 Saml code
Added:
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/AbstractSaml2BearerGrant.java
(with props)
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/SamlBearerClientCredentialsGrant.java
(with props)
Modified:
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/Saml2BearerGrant.java
Added:
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/AbstractSaml2BearerGrant.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/AbstractSaml2BearerGrant.java?rev=1452102&view=auto
==============================================================================
---
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/AbstractSaml2BearerGrant.java
(added)
+++
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/AbstractSaml2BearerGrant.java
Sun Mar 3 19:00:46 2013
@@ -0,0 +1,68 @@
+/**
+ * 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.cxf.rs.security.oauth2.grants.saml;
+
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.rs.security.oauth2.common.AccessTokenGrant;
+import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException;
+import org.apache.cxf.rs.security.oauth2.saml.Base64UrlUtility;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
+
+public abstract class AbstractSaml2BearerGrant implements AccessTokenGrant {
+ private String assertion;
+ private String scope;
+ private boolean encoded;
+ private String grantType;
+ protected AbstractSaml2BearerGrant(String grantType, String assertion,
boolean encoded, String scope) {
+ this.grantType = grantType;
+ this.assertion = assertion;
+ this.encoded = encoded;
+ this.scope = scope;
+ }
+
+ public String getType() {
+ return grantType;
+ }
+
+ protected MultivaluedMap<String, String> initMap() {
+ MultivaluedMap<String, String> map = new MetadataMap<String, String>();
+ map.putSingle(OAuthConstants.GRANT_TYPE, grantType);
+ return map;
+ }
+
+ protected void addScope(MultivaluedMap<String, String> map) {
+ if (scope != null) {
+ map.putSingle(OAuthConstants.SCOPE, scope);
+ }
+ }
+
+ protected String encodeAssertion() {
+ if (encoded) {
+ return assertion;
+ }
+
+ try {
+ return Base64UrlUtility.encode(assertion);
+ } catch (Exception ex) {
+ throw new OAuthServiceException(ex.getMessage(), ex);
+ }
+ }
+}
Propchange:
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/AbstractSaml2BearerGrant.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/AbstractSaml2BearerGrant.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/Saml2BearerGrant.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/Saml2BearerGrant.java?rev=1452102&r1=1452101&r2=1452102&view=diff
==============================================================================
---
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/Saml2BearerGrant.java
(original)
+++
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/Saml2BearerGrant.java
Sun Mar 3 19:00:46 2013
@@ -20,18 +20,9 @@ package org.apache.cxf.rs.security.oauth
import javax.ws.rs.core.MultivaluedMap;
-import org.apache.cxf.jaxrs.impl.MetadataMap;
-import org.apache.cxf.rs.security.oauth2.common.AccessTokenGrant;
-import org.apache.cxf.rs.security.oauth2.provider.OAuthServiceException;
-import org.apache.cxf.rs.security.oauth2.saml.Base64UrlUtility;
import org.apache.cxf.rs.security.oauth2.saml.Constants;
-import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
-public class Saml2BearerGrant implements AccessTokenGrant {
- private String assertion;
- private String scope;
- private boolean encoded;
-
+public class Saml2BearerGrant extends AbstractSaml2BearerGrant {
public Saml2BearerGrant(String assertion) {
this(assertion, false);
}
@@ -45,34 +36,13 @@ public class Saml2BearerGrant implements
}
public Saml2BearerGrant(String assertion, boolean encoded, String scope) {
- this.assertion = assertion;
- this.encoded = encoded;
- this.scope = scope;
+ super(Constants.SAML2_BEARER_GRANT, assertion, encoded, scope);
}
- public String getType() {
- return Constants.SAML2_BEARER_GRANT;
- }
-
public MultivaluedMap<String, String> toMap() {
- MultivaluedMap<String, String> map = new MetadataMap<String, String>();
- map.putSingle(OAuthConstants.GRANT_TYPE, Constants.SAML2_BEARER_GRANT);
+ MultivaluedMap<String, String> map = initMap();
map.putSingle(Constants.CLIENT_GRANT_ASSERTION_PARAM,
encodeAssertion());
- if (scope != null) {
- map.putSingle(OAuthConstants.SCOPE, scope);
- }
+ addScope(map);
return map;
}
-
- protected String encodeAssertion() {
- if (encoded) {
- return assertion;
- }
-
- try {
- return Base64UrlUtility.encode(assertion);
- } catch (Exception ex) {
- throw new OAuthServiceException(ex.getMessage(), ex);
- }
- }
}
Added:
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/SamlBearerClientCredentialsGrant.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/SamlBearerClientCredentialsGrant.java?rev=1452102&view=auto
==============================================================================
---
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/SamlBearerClientCredentialsGrant.java
(added)
+++
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/SamlBearerClientCredentialsGrant.java
Sun Mar 3 19:00:46 2013
@@ -0,0 +1,40 @@
+/**
+ * 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.cxf.rs.security.oauth2.grants.saml;
+
+import javax.ws.rs.core.MultivaluedMap;
+
+import org.apache.cxf.rs.security.oauth2.saml.Constants;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
+
+public class SamlBearerClientCredentialsGrant extends AbstractSaml2BearerGrant
{
+
+ public SamlBearerClientCredentialsGrant(String assertion, boolean encoded,
String scope) {
+ super(OAuthConstants.CLIENT_CREDENTIALS_GRANT, assertion, encoded,
scope);
+ }
+
+ public MultivaluedMap<String, String> toMap() {
+ MultivaluedMap<String, String> map = initMap();
+ map.putSingle(Constants.CLIENT_AUTH_ASSERTION_TYPE,
Constants.CLIENT_AUTH_SAML2_BEARER);
+ map.putSingle(Constants.CLIENT_AUTH_ASSERTION_PARAM,
encodeAssertion());
+ addScope(map);
+ return map;
+ }
+
+}
Propchange:
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/SamlBearerClientCredentialsGrant.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/rs/security/oauth-parent/oauth2-saml/src/main/java/org/apache/cxf/rs/security/oauth2/grants/saml/SamlBearerClientCredentialsGrant.java
------------------------------------------------------------------------------
svn:keywords = Rev Date