Synch with new profile handler class hierarchy
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 22 May 2007 13:53:29 +0000 (13:53 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 22 May 2007 13:53:29 +0000 (13:53 +0000)
Add simple status profile handler

git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@2208 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

resources/classpath/schema/shibboleth-2.0-idp-profile.xsd
resources/conf/protocol.xml
src/edu/internet2/middleware/shibboleth/idp/config/profile/AbstractSAMLProfileHandlerBeanDefinitionParser.java
src/edu/internet2/middleware/shibboleth/idp/config/profile/IdPProfileHandlerNamespaceHandler.java
src/edu/internet2/middleware/shibboleth/idp/config/profile/StatusHandlerBeanDefinitionParser.java [new file with mode: 0644]
src/edu/internet2/middleware/shibboleth/idp/profile/AbstractSAMLProfileHandler.java
src/edu/internet2/middleware/shibboleth/idp/profile/StatusProfileHandler.java [new file with mode: 0644]

index 737c503..dda6eac 100644 (file)
@@ -6,13 +6,22 @@
 
     <import namespace="urn:mace:shibboleth:2.0:profile-handler"
         schemaLocation="classpath:/schema/shibboleth-2.0-profile-handler.xsd" />
-        
+
     <annotation>
         <documentation>
             This schema specifies the configuration options for Shibboleth IdP profile handlers.
         </documentation>
     </annotation>
 
+    <complexType name="Status">
+        <annotation>
+            <documentation>Basic handler that returns a general status of the IdP.</documentation>
+        </annotation>
+        <complexContent>
+            <extension base="ph:ProfileHandlerType" />
+        </complexContent>
+    </complexType>
+
     <complexType name="SAML2SSO">
         <annotation>
             <documentation>Configuration type for SAML 2 Attribute Query profile handlers.</documentation>
index cf4c320..bdf9f5b 100644 (file)
@@ -8,6 +8,10 @@
 
     <ErrorHandler xsi:type="JSPErrorHandler" jspPagePath="/error.jsp" />
 
+    <ProfileHandler xsi:type="idpProfile:Status">
+        <RequestPath>/shibboleth/IdP/status</RequestPath>
+    </ProfileHandler>
+
     <ProfileHandler xsi:type="idpProfile:SAML2SSO">
         <RequestPath>/shibboleth/IdP/saml2/HTTP/SSO</RequestPath>
     </ProfileHandler>
index 9fdeec8..e19346b 100644 (file)
@@ -19,13 +19,13 @@ package edu.internet2.middleware.shibboleth.idp.config.profile;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.w3c.dom.Element;
 
-import edu.internet2.middleware.shibboleth.common.config.profile.AbstractProfileHandlerBeanDefinitionParser;
+import edu.internet2.middleware.shibboleth.common.config.profile.AbstractShibbolethProfileHandlerBeanDefinitionParser;
 
 /**
  * Base class for SAML profile handler configuration parsers.
  */
 public abstract class AbstractSAMLProfileHandlerBeanDefinitionParser extends
-        AbstractProfileHandlerBeanDefinitionParser {
+        AbstractShibbolethProfileHandlerBeanDefinitionParser {
 
     /** {@inheritDoc} */
     protected void doParse(Element config, BeanDefinitionBuilder builder) {
index 6dcc6ff..2c20001 100644 (file)
@@ -28,6 +28,9 @@ public class IdPProfileHandlerNamespaceHandler extends BaseSpringNamespaceHandle
 
     /** {@inheritDoc} */
     public void init() {
+        registerBeanDefinitionParser(StatusHandlerBeanDefinitionParser.SCHEMA_TYPE,
+                new StatusHandlerBeanDefinitionParser());
+
         registerBeanDefinitionParser(SAML2AttributeQueryProfileHandlerBeanDefinitionParser.SCHEMA_TYPE,
                 new SAML2AttributeQueryProfileHandlerBeanDefinitionParser());
 
diff --git a/src/edu/internet2/middleware/shibboleth/idp/config/profile/StatusHandlerBeanDefinitionParser.java b/src/edu/internet2/middleware/shibboleth/idp/config/profile/StatusHandlerBeanDefinitionParser.java
new file mode 100644 (file)
index 0000000..3fad3f7
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
+ *
+ * Licensed 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 edu.internet2.middleware.shibboleth.idp.config.profile;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import edu.internet2.middleware.shibboleth.common.config.profile.AbstractRequestURIMappedProfileHandlerBeanDefinitionParser;
+import edu.internet2.middleware.shibboleth.idp.profile.StatusProfileHandler;
+
+/**
+ * Spring bean definition parser for {@link StatusProfileHandler}s.
+ */
+public class StatusHandlerBeanDefinitionParser extends AbstractRequestURIMappedProfileHandlerBeanDefinitionParser {
+    
+    /** Schema type. */
+    public static final QName SCHEMA_TYPE = new QName(IdPProfileHandlerNamespaceHandler.NAMESPACE, "Status");
+
+    /** {@inheritDoc} */
+    protected Class getBeanClass(Element arg0) {
+        return StatusProfileHandler.class;
+    }
+
+    /** {@inheritDoc} */
+    protected boolean shouldGenerateId() {
+        return true;
+    }
+}
\ No newline at end of file
index 81832a2..f4f5de6 100644 (file)
@@ -27,8 +27,8 @@ import org.opensaml.common.impl.SecureRandomIdentifierGenerator;
 import org.opensaml.saml2.metadata.provider.MetadataProvider;
 
 import edu.internet2.middleware.shibboleth.common.log.AuditLogEntry;
-import edu.internet2.middleware.shibboleth.common.profile.AbstractProfileHandler;
 import edu.internet2.middleware.shibboleth.common.profile.ProfileRequest;
+import edu.internet2.middleware.shibboleth.common.profile.provider.AbstractShibbolethProfileHandler;
 import edu.internet2.middleware.shibboleth.common.relyingparty.provider.SAMLMDRelyingPartyConfigurationManager;
 import edu.internet2.middleware.shibboleth.idp.session.Session;
 
@@ -36,7 +36,7 @@ import edu.internet2.middleware.shibboleth.idp.session.Session;
  * Base class for SAML profile handlers.
  */
 public abstract class AbstractSAMLProfileHandler extends
-        AbstractProfileHandler<SAMLMDRelyingPartyConfigurationManager, Session> {
+        AbstractShibbolethProfileHandler<SAMLMDRelyingPartyConfigurationManager, Session> {
 
     /** SAML message audit log. */
     private final Logger auditLog = Logger.getLogger(AuditLogEntry.AUDIT_LOGGER_NAME);
diff --git a/src/edu/internet2/middleware/shibboleth/idp/profile/StatusProfileHandler.java b/src/edu/internet2/middleware/shibboleth/idp/profile/StatusProfileHandler.java
new file mode 100644 (file)
index 0000000..7865802
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright [2007] [University Corporation for Advanced Internet Development, Inc.]
+ *
+ * Licensed 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 edu.internet2.middleware.shibboleth.idp.profile;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.log4j.Logger;
+
+import edu.internet2.middleware.shibboleth.common.profile.ProfileException;
+import edu.internet2.middleware.shibboleth.common.profile.ProfileRequest;
+import edu.internet2.middleware.shibboleth.common.profile.ProfileResponse;
+import edu.internet2.middleware.shibboleth.common.profile.provider.AbstractRequestURIMappedProfileHandler;
+
+/**
+ * A simple profile handler that returns the string "ok" if the IdP is able to answer the request. This may be used for
+ * very basic monitoring of the IdP.
+ */
+public class StatusProfileHandler extends AbstractRequestURIMappedProfileHandler {
+
+    /** Class logger. */
+    private final Logger log = Logger.getLogger(StatusProfileHandler.class);
+
+    /** {@inheritDoc} */
+    public String getProfileId() {
+        return "urn:mace:shibboleth:2.0:idp:profiles:status";
+    }
+
+    /** {@inheritDoc} */
+    public void processRequest(ProfileRequest<ServletRequest> request, ProfileResponse<ServletResponse> response)
+            throws ProfileException {
+        try {
+            PrintWriter out = response.getRawResponse().getWriter();
+            out.write("ok");
+        } catch (IOException e) {
+            log.error("Unable to write response", e);
+        }
+    }
+}
\ No newline at end of file