incubator-stonehenge-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shan...@apache.org
Subject svn commit: r890680 - in /incubator/stonehenge/trunk/stocktrader/wsas/identity: ./ lib/ org.wso2.carbon.identity.stonehenge.attributeservice/ src/ src/org/ src/org/apache/ src/org/apache/stonehenge/ src/org/apache/stonehenge/stocktrader/ src/org/apache...
Date Tue, 15 Dec 2009 08:07:29 GMT
Author: shankar
Date: Tue Dec 15 08:07:28 2009
New Revision: 890680

URL: http://svn.apache.org/viewvc?rev=890680&view=rev
Log:
Changing namespaces

Added:
    incubator/stonehenge/trunk/stocktrader/wsas/identity/src/
    incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/
    incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/
    incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/
    incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/
    incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/
    incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/StonehengeAttributeService.java
    incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/internal/
    incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/internal/CustomAttributeServiceComponent.java
Removed:
    incubator/stonehenge/trunk/stocktrader/wsas/identity/lib/
    incubator/stonehenge/trunk/stocktrader/wsas/identity/org.wso2.carbon.identity.stonehenge.attributeservice/
Modified:
    incubator/stonehenge/trunk/stocktrader/wsas/identity/pom.xml

Modified: incubator/stonehenge/trunk/stocktrader/wsas/identity/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/wsas/identity/pom.xml?rev=890680&r1=890679&r2=890680&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/wsas/identity/pom.xml (original)
+++ incubator/stonehenge/trunk/stocktrader/wsas/identity/pom.xml Tue Dec 15 08:07:28 2009
@@ -1,104 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	~ 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.
+-->
+        
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
-    <groupId>org.wso2.carbon.identity.stonehenge</groupId>
-    <artifactId>identity-stonehenge-parent</artifactId>
-    <packaging>pom</packaging>
-    <version>2.0.0.SNAPSHOT</version>
-    <name>WSO2 Identity Server Stonehenge - Parent Maven Module</name>
-    <description>identity-stonehenge-parent</description>
-    <url>http://wso2.org</url>
-
-    <repositories>
-        <repository>
-            <id>wso2-maven2-repository</id>
-            <url>http://dist.wso2.org/maven2</url>
-        </repository>
-        <repository>
-            <id>wso2-maven2-repository-snapshot</id>
-            <url>http://dist.wso2.org/snapshots/maven2</url>
-        </repository>
-        <repository>
-            <id>apache-Incubating-repo</id>
-            <name>Maven Incubating Repository</name>
-            <url>http://people.apache.org/repo/m2-incubating-repository</url>
-        </repository>
-        <repository>
-            <id>apache-maven2-repo</id>
-            <name>Apache Maven2 Repository</name>
-            <url>http://repo1.maven.org/maven2/</url>
-        </repository>
-    </repositories>
-
-    <pluginRepositories>
-        <pluginRepository>
-            <id>wso2-maven2-repository</id>
-            <url>http://dist.wso2.org/maven2</url>
-        </pluginRepository>
-    </pluginRepositories>
+    <groupId>org.apache.stonehenge.stocktrader.identity</groupId>
+    <artifactId>attributeservice</artifactId>
+	<!--packaging>bundle</packaging>-->
+    <version>m2</version>
+    <name>WSO2 Identity Attribute Service for Stonehenge</name>
 
     <build>
-        <pluginManagement>
-            <plugins>
-                <plugin>
-                    <groupId>org.apache.felix</groupId>
-                    <artifactId>maven-scr-plugin</artifactId>
-                    <version>1.0.10</version>
-                    <executions>
-                        <execution>
-                            <id>generate-scr-scrdescriptor</id>
-                            <goals>
-                                <goal>scr</goal>
-                            </goals>
-                        </execution>
-                    </executions>
-                </plugin>
-            </plugins>
-        </pluginManagement>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.0</version>
                 <configuration>
                     <source>1.5</source>
                     <target>1.5</target>
                 </configuration>
             </plugin>
+            <!--plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>1.4.0</version>
+                <extensions>true</extensions>
+                 <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Name>${pom.artifactId}</Bundle-Name>
+                        <Private-Package>org.wso2.carbon.identity.stonehenge.attributeservice.internal</Private-Package>
+                        <Export-Package>
+                            org.wso2.carbon.identity.stonehenge.attributeservice,
+                        </Export-Package>
+                        <Import-Package>
+                            !org.wso2.carbon.identity.stonehenge.attributeservice,
+                            org.wso2.carbon.identity.provider.*,
+                            org.osgi.framework,
+                            org.apache.axis2.*; version="${axis2.osgi.version.range}",
+                        </Import-Package>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin-->
         </plugins>
     </build>
 
-    <modules>
-       <module>org.wso2.carbon.identity.stonehenge.attributeservice</module>
-    </modules>
-
-    <properties>
-        <wso2carbon.version>${pom.version}</wso2carbon.version>
-        <server.name>WSO2Carbon</server.name>
-        <server.version>${pom.version}</server.version>        
-        <axis2.transport.version>1.0.0.wso2v1</axis2.transport.version>
-        <axiom.version>1.2.7</axiom.version>
-        <tomcat.version>6.0.16</tomcat.version>
-        <jakarta.taglib.version>1.1.2</jakarta.taglib.version>
-        <sourceforge.ajaxtags.version>1.3.0.beta-rc7</sourceforge.ajaxtags.version>
-        <addressing.version>1.5</addressing.version>
-        <rampart.mar.version>1.41</rampart.mar.version>
-        <axis2.osgi.version>1.4.1.wso2</axis2.osgi.version>
-        <wss4j.version>1.5.4</wss4j.version>
-        <derby.version>10.2.2.0</derby.version>
-        <neethi.version>2.0.4</neethi.version>
-        <stax.version>1.0.1</stax.version>
-        <spring.version>2.5.1</spring.version>
-        <h2.engine.version>1.1.112</h2.engine.version>
-        <wso2.h2.orbit.version>${h2.engine.version}.wso2v1</wso2.h2.orbit.version>
-
-        <axis2.version>1.5-wso2v1</axis2.version>
-        <axis2.orbit.version>1.5.0.wso2v1</axis2.orbit.version>
-        <axis2.osgi.version.range>[1.5.0.wso2, 1.6.0)</axis2.osgi.version.range>
-        <axiom.osgi.version.range>[1.2.8, 1.3.0)</axiom.osgi.version.range>
-        <neethi.osgi.version.range>[2.0.4, 3.0.0)</neethi.osgi.version.range>
-    </properties>
+    <dependencies>
+
+	  <dependency>
+	    <groupId>opensaml.wso2</groupId>
+	    <artifactId>opensaml2</artifactId>
+	    <version>2.0.1.alpha1-wso2v1</version>
+	  </dependency>
+           
+	  <dependency>
+              <groupId>org.apache.ws.commons.axiom.wso2</groupId>
+              <artifactId>axiom</artifactId>
+              <version>1.2.9.wso2v1-SNAPSHOT</version>
+          </dependency>
+
+           <dependency>
+              <groupId>org.apache.axis2.wso2</groupId>
+              <artifactId>axis2</artifactId>
+              <version>1.5.0.wso2v3</version>
+           </dependency>
+
+          <dependency>
+             <groupId>org.wso2.carbon</groupId>
+             <artifactId>org.wso2.carbon.security.rahas</artifactId>
+             <version>2.0.1</version>
+          </dependency>
+
+          <dependency>
+             <groupId>org.wso2.carbon</groupId>
+             <artifactId>org.wso2.carbon.identity.provider</artifactId>
+             <version>2.0.0</version>
+          </dependency>
 
+    </dependencies>
 
 </project>

Added: incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/StonehengeAttributeService.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/StonehengeAttributeService.java?rev=890680&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/StonehengeAttributeService.java
(added)
+++ incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/StonehengeAttributeService.java
Tue Dec 15 08:07:28 2009
@@ -0,0 +1,113 @@
+package org.apache.stonehenge.stocktrader.attributeservice;
+
+import java.util.Arrays;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.rahas.RahasConstants;
+import org.apache.rahas.RahasData;
+import org.apache.rahas.impl.util.SAMLAttributeCallback;
+import org.opensaml.Configuration;
+import org.opensaml.SAMLAttribute;
+import org.opensaml.SAMLException;
+import org.opensaml.common.SAMLObjectBuilder;
+import org.opensaml.saml2.core.Attribute;
+import org.opensaml.saml2.core.AttributeValue;
+import org.opensaml.xml.XMLObjectBuilderFactory;
+import org.opensaml.xml.schema.XSString;
+import org.opensaml.xml.schema.impl.XSStringBuilder;
+import org.wso2.carbon.identity.provider.IdentityAttributeService;
+
+public class StonehengeAttributeService implements IdentityAttributeService {
+
+    private static final String WSSE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
+    private static final String WSSE_LN = "Security";
+    private static final String USERNAME_TOKEN_LN = "UsernameToken";
+    private static final String PASSWORD_LN = "Password";
+    private static final QName SEC_HEADER = new QName(WSSE_NS, WSSE_LN);
+    private static final QName USERNAME_TOKEN = new QName(WSSE_NS, USERNAME_TOKEN_LN);
+    private static final QName PASSWORD = new QName(WSSE_NS, PASSWORD_LN);
+
+    private static Log log = LogFactory.getLog(StonehengeAttributeService.class);
+
+    public void handle(SAMLAttributeCallback attrCallback) throws SAMLException {
+        log.info("StonehengeAttributeService being called");
+        RahasData data = null;
+        String userIdentifier = null;
+        String password = null;
+
+        try {
+            data = attrCallback.getData();
+
+            // we're cheating and hardcoding the ppid value.
+            // TODO: take it from the database
+            if (RahasConstants.TOK_TYPE_SAML_20.equals(data.getTokenType())) {
+                attrCallback.addAttributes(getSAML2Attribute("privatepersonalidentifier",
"08C648FA-5C0E-4092-ABF8-E71785373CE8", "http://schemas.xmlsoap.org/ws/2005/05/identity/claims"));
+            } else {
+            SAMLAttribute attribute = null;
+            attribute = new SAMLAttribute("privatepersonalidentifier",
+                    "http://schemas.xmlsoap.org/ws/2005/05/identity/claims", null, -1, Arrays
+                            .asList(new String[]{"uid:0"}));
+            attrCallback.addAttributes(attribute);
+            }            
+        } catch (Exception e) {
+            log.error("Error occuerd while populating claim data", e);
+        }
+    }
+
+    private Attribute getSAML2Attribute(String name, String value, String namespace) {
+        XMLObjectBuilderFactory builderFactory = null;
+        SAMLObjectBuilder<Attribute> attrBuilder = null;
+        Attribute attribute = null;
+        XSStringBuilder attributeValueBuilder = null;
+        XSString stringValue = null;
+
+        builderFactory = Configuration.getBuilderFactory();
+        attrBuilder = (SAMLObjectBuilder<Attribute>) builderFactory
+                .getBuilder(Attribute.DEFAULT_ELEMENT_NAME);
+        attribute = attrBuilder.buildObject();
+        attribute.setName(name);
+        attribute.setNameFormat(namespace);
+
+        attributeValueBuilder = (XSStringBuilder) builderFactory.getBuilder(XSString.TYPE_NAME);
+        stringValue = attributeValueBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME,
+                XSString.TYPE_NAME);
+        stringValue.setValue(value);
+        attribute.getAttributeValues().add(stringValue);
+        return attribute;
+    }
+
+    private String getUserCredentials(SOAPEnvelope envelope) {
+        SOAPHeaderBlock secHeader = null;
+        OMElement usernameToken = null;
+
+        secHeader = getSecHeader(envelope);
+        if (secHeader == null) {
+            return null;
+        }
+
+        usernameToken = secHeader.getFirstChildWithName(USERNAME_TOKEN);
+        if (usernameToken != null) {
+            OMElement userElem = usernameToken.getFirstChildWithName(PASSWORD);
+            if (userElem != null) {
+                return userElem.getText().trim();
+            }
+        }
+        return null;
+    }
+
+    private SOAPHeaderBlock getSecHeader(SOAPEnvelope envelope) {
+        SOAPHeader header = envelope.getHeader();
+        if (header != null) {
+            return (SOAPHeaderBlock) header.getFirstChildWithName(SEC_HEADER);
+        }
+        return null;
+    }
+}

Added: incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/internal/CustomAttributeServiceComponent.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/internal/CustomAttributeServiceComponent.java?rev=890680&view=auto
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/internal/CustomAttributeServiceComponent.java
(added)
+++ incubator/stonehenge/trunk/stocktrader/wsas/identity/src/org/apache/stonehenge/stocktrader/attributeservice/internal/CustomAttributeServiceComponent.java
Tue Dec 15 08:07:28 2009
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * 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 org.apache.stonehenge.stocktrader.attributeservice.internal;
+
+import org.wso2.carbon.identity.provider.IdentityAttributeService;
+import org.wso2.carbon.identity.stonehenge.attributeservice.StonehengeAttributeService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.osgi.service.component.ComponentContext;
+
+import java.util.Properties;
+
+/**
+ * @scr.component name="org.wso2.carbon.identity.samples.attributeservice" immediate="true"
+ */
+public class CustomAttributeServiceComponent {
+    private static Log log = LogFactory.getLog(CustomAttributeServiceComponent.class);
+
+    public CustomAttributeServiceComponent() {
+    }
+
+    protected void activate(ComponentContext ctxt) {
+        Properties props;
+
+        try {
+            // This should ideally contain properties of MailTransportService as
+            // a collection of key/value pair. Here we do not require to add any elements.
+            props = new Properties();
+            // Register the StonehengeAttributeService under IdentityAttributeService interface.
+            ctxt.getBundleContext().registerService(IdentityAttributeService.class.getName(),
+                    new StonehengeAttributeService(), props);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Successfully registered the StonehengeAttributeService service");
+            }
+        } catch (Throwable e) {
+            String message = null;
+            message = "Error while activating the org.wso2.carbon.identity.stonehenge.attributeservice
bundle";
+            log.error(message, e);
+        }
+    }
+
+    protected void deactivate(ComponentContext ctxt) {
+        if (log.isDebugEnabled()) {
+            log.debug("org.wso2.carbon.identity.stonehenge.attributeservice bundle is deactivated");
+        }
+    }
+}
\ No newline at end of file



Mime
View raw message