View Javadoc

1   /**
2    *       Copyright 2010 Newcastle University
3    *
4    *          http://research.ncl.ac.uk/smart/
5    *
6    * Licensed to the Apache Software Foundation (ASF) under one or more
7    * contributor license agreements.  See the NOTICE file distributed with
8    * this work for additional information regarding copyright ownership.
9    * The ASF licenses this file to You under the Apache License, Version 2.0
10   * (the "License"); you may not use this file except in compliance with
11   * the License.  You may obtain a copy of the License at
12   *
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   */
21  
22  package org.apache.amber.oauth2.ext.dynamicreg.server.request;
23  
24  import javax.servlet.http.HttpServletRequest;
25  
26  import org.apache.amber.oauth2.common.exception.OAuthSystemException;
27  import org.apache.amber.oauth2.common.validators.OAuthValidator;
28  import org.apache.amber.oauth2.ext.dynamicreg.common.OAuthRegistration;
29  import org.apache.amber.oauth2.as.request.OAuthRequest;
30  import org.apache.amber.oauth2.common.exception.OAuthProblemException;
31  import org.apache.amber.oauth2.ext.dynamicreg.server.validator.PushPullValidator;
32  
33  
34  /**
35   *
36   *
37   *
38   */
39  public class OAuthServerRegistrationRequest extends OAuthRequest {
40  
41      private String type;
42  
43      private boolean isDiscovered;
44  
45      public OAuthServerRegistrationRequest(JSONHttpServletRequestWrapper request)
46          throws OAuthSystemException, OAuthProblemException {
47          this(request, false);
48      }
49  
50      public OAuthServerRegistrationRequest(JSONHttpServletRequestWrapper request, boolean discover)
51          throws OAuthSystemException, OAuthProblemException {
52          super(request);
53          if (discover) {
54              discover();
55          }
56      }
57  
58      @Override
59      protected OAuthValidator initValidator() throws OAuthProblemException, OAuthSystemException {
60          return new PushPullValidator();
61      }
62  
63      public void discover() throws OAuthSystemException {
64          if (OAuthRegistration.Type.PULL.equals(type)) {
65              // discover            
66          }
67          isDiscovered = true;
68      }
69  
70      public String getType() {
71          return getParam(OAuthRegistration.Request.TYPE);
72      }
73  
74      public String getClientName() {
75          return getParam(OAuthRegistration.Request.CLIENT_NAME);
76      }
77  
78      public String getClientUrl() {
79          return getParam(OAuthRegistration.Request.CLIENT_URL);
80      }
81  
82      public String getClientDescription() {
83          return getParam(OAuthRegistration.Request.CLIENT_DESCRIPTION);
84      }
85  
86      public String getClientIcon() {
87          return getParam(OAuthRegistration.Request.CLIENT_ICON);
88      }
89  
90      public String getRedirectURI() {
91          return getParam(OAuthRegistration.Request.REDIRECT_URL);
92      }
93  
94      public boolean isDiscovered() {
95          return isDiscovered;
96      }
97  
98  }