You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2009/04/21 23:32:50 UTC
svn commit: r767305 [3/5] - in /ofbiz/trunk/specialpurpose: ./ crowd/
crowd/config/ crowd/src/ crowd/src/com/ crowd/src/com/atlassian/
crowd/src/com/atlassian/crowd/ crowd/src/com/atlassian/crowd/integration/
crowd/src/com/atlassian/crowd/integration/a...
Added: ofbiz/trunk/specialpurpose/crowd/src/com/atlassian/crowd/integration/soap/SOAPRole.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/crowd/src/com/atlassian/crowd/integration/soap/SOAPRole.java?rev=767305&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/crowd/src/com/atlassian/crowd/integration/soap/SOAPRole.java (added)
+++ ofbiz/trunk/specialpurpose/crowd/src/com/atlassian/crowd/integration/soap/SOAPRole.java Tue Apr 21 21:32:49 2009
@@ -0,0 +1,452 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+/**
+ * SOAPRole.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
+ */
+
+package com.atlassian.crowd.integration.soap;
+
+public class SOAPRole implements java.io.Serializable {
+ private java.lang.Long ID;
+
+ private java.lang.Boolean active;
+
+ private com.atlassian.crowd.integration.soap.SOAPAttribute[] attributes;
+
+ private java.util.Calendar conception;
+
+ private java.lang.String description;
+
+ private java.lang.Long directoryID;
+
+ private java.util.Calendar lastModified;
+
+ private java.lang.String[] members;
+
+ private java.lang.String name;
+
+ public SOAPRole() {
+ }
+
+ public SOAPRole(
+ java.lang.Long ID,
+ java.lang.Boolean active,
+ com.atlassian.crowd.integration.soap.SOAPAttribute[] attributes,
+ java.util.Calendar conception,
+ java.lang.String description,
+ java.lang.Long directoryID,
+ java.util.Calendar lastModified,
+ java.lang.String[] members,
+ java.lang.String name) {
+ this.ID = ID;
+ this.active = active;
+ this.attributes = attributes;
+ this.conception = conception;
+ this.description = description;
+ this.directoryID = directoryID;
+ this.lastModified = lastModified;
+ this.members = members;
+ this.name = name;
+ }
+
+
+ /**
+ * Gets the ID value for this SOAPRole.
+ *
+ * @return ID
+ */
+ public java.lang.Long getID() {
+ return ID;
+ }
+
+
+ /**
+ * Sets the ID value for this SOAPRole.
+ *
+ * @param ID
+ */
+ public void setID(java.lang.Long ID) {
+ this.ID = ID;
+ }
+
+
+ /**
+ * Gets the active value for this SOAPRole.
+ *
+ * @return active
+ */
+ public java.lang.Boolean getActive() {
+ return active;
+ }
+
+
+ /**
+ * Sets the active value for this SOAPRole.
+ *
+ * @param active
+ */
+ public void setActive(java.lang.Boolean active) {
+ this.active = active;
+ }
+
+
+ /**
+ * Gets the attributes value for this SOAPRole.
+ *
+ * @return attributes
+ */
+ public com.atlassian.crowd.integration.soap.SOAPAttribute[] getAttributes() {
+ return attributes;
+ }
+
+
+ /**
+ * Sets the attributes value for this SOAPRole.
+ *
+ * @param attributes
+ */
+ public void setAttributes(com.atlassian.crowd.integration.soap.SOAPAttribute[] attributes) {
+ this.attributes = attributes;
+ }
+
+
+ /**
+ * Gets the conception value for this SOAPRole.
+ *
+ * @return conception
+ */
+ public java.util.Calendar getConception() {
+ return conception;
+ }
+
+
+ /**
+ * Sets the conception value for this SOAPRole.
+ *
+ * @param conception
+ */
+ public void setConception(java.util.Calendar conception) {
+ this.conception = conception;
+ }
+
+
+ /**
+ * Gets the description value for this SOAPRole.
+ *
+ * @return description
+ */
+ public java.lang.String getDescription() {
+ return description;
+ }
+
+
+ /**
+ * Sets the description value for this SOAPRole.
+ *
+ * @param description
+ */
+ public void setDescription(java.lang.String description) {
+ this.description = description;
+ }
+
+
+ /**
+ * Gets the directoryID value for this SOAPRole.
+ *
+ * @return directoryID
+ */
+ public java.lang.Long getDirectoryID() {
+ return directoryID;
+ }
+
+
+ /**
+ * Sets the directoryID value for this SOAPRole.
+ *
+ * @param directoryID
+ */
+ public void setDirectoryID(java.lang.Long directoryID) {
+ this.directoryID = directoryID;
+ }
+
+
+ /**
+ * Gets the lastModified value for this SOAPRole.
+ *
+ * @return lastModified
+ */
+ public java.util.Calendar getLastModified() {
+ return lastModified;
+ }
+
+
+ /**
+ * Sets the lastModified value for this SOAPRole.
+ *
+ * @param lastModified
+ */
+ public void setLastModified(java.util.Calendar lastModified) {
+ this.lastModified = lastModified;
+ }
+
+
+ /**
+ * Gets the members value for this SOAPRole.
+ *
+ * @return members
+ */
+ public java.lang.String[] getMembers() {
+ return members;
+ }
+
+
+ /**
+ * Sets the members value for this SOAPRole.
+ *
+ * @param members
+ */
+ public void setMembers(java.lang.String[] members) {
+ this.members = members;
+ }
+
+
+ /**
+ * Gets the name value for this SOAPRole.
+ *
+ * @return name
+ */
+ public java.lang.String getName() {
+ return name;
+ }
+
+
+ /**
+ * Sets the name value for this SOAPRole.
+ *
+ * @param name
+ */
+ public void setName(java.lang.String name) {
+ this.name = name;
+ }
+
+ private java.lang.Object __equalsCalc = null;
+ public synchronized boolean equals(java.lang.Object obj) {
+ if (!(obj instanceof SOAPRole)) return false;
+ SOAPRole other = (SOAPRole) obj;
+ if (obj == null) return false;
+ if (this == obj) return true;
+ if (__equalsCalc != null) {
+ return (__equalsCalc == obj);
+ }
+ __equalsCalc = obj;
+ boolean _equals;
+ _equals = true &&
+ ((this.ID==null && other.getID()==null) ||
+ (this.ID!=null &&
+ this.ID.equals(other.getID()))) &&
+ ((this.active==null && other.getActive()==null) ||
+ (this.active!=null &&
+ this.active.equals(other.getActive()))) &&
+ ((this.attributes==null && other.getAttributes()==null) ||
+ (this.attributes!=null &&
+ java.util.Arrays.equals(this.attributes, other.getAttributes()))) &&
+ ((this.conception==null && other.getConception()==null) ||
+ (this.conception!=null &&
+ this.conception.equals(other.getConception()))) &&
+ ((this.description==null && other.getDescription()==null) ||
+ (this.description!=null &&
+ this.description.equals(other.getDescription()))) &&
+ ((this.directoryID==null && other.getDirectoryID()==null) ||
+ (this.directoryID!=null &&
+ this.directoryID.equals(other.getDirectoryID()))) &&
+ ((this.lastModified==null && other.getLastModified()==null) ||
+ (this.lastModified!=null &&
+ this.lastModified.equals(other.getLastModified()))) &&
+ ((this.members==null && other.getMembers()==null) ||
+ (this.members!=null &&
+ java.util.Arrays.equals(this.members, other.getMembers()))) &&
+ ((this.name==null && other.getName()==null) ||
+ (this.name!=null &&
+ this.name.equals(other.getName())));
+ __equalsCalc = null;
+ return _equals;
+ }
+
+ private boolean __hashCodeCalc = false;
+ public synchronized int hashCode() {
+ if (__hashCodeCalc) {
+ return 0;
+ }
+ __hashCodeCalc = true;
+ int _hashCode = 1;
+ if (getID() != null) {
+ _hashCode += getID().hashCode();
+ }
+ if (getActive() != null) {
+ _hashCode += getActive().hashCode();
+ }
+ if (getAttributes() != null) {
+ for (int i=0;
+ i<java.lang.reflect.Array.getLength(getAttributes());
+ i++) {
+ java.lang.Object obj = java.lang.reflect.Array.get(getAttributes(), i);
+ if (obj != null &&
+ !obj.getClass().isArray()) {
+ _hashCode += obj.hashCode();
+ }
+ }
+ }
+ if (getConception() != null) {
+ _hashCode += getConception().hashCode();
+ }
+ if (getDescription() != null) {
+ _hashCode += getDescription().hashCode();
+ }
+ if (getDirectoryID() != null) {
+ _hashCode += getDirectoryID().hashCode();
+ }
+ if (getLastModified() != null) {
+ _hashCode += getLastModified().hashCode();
+ }
+ if (getMembers() != null) {
+ for (int i=0;
+ i<java.lang.reflect.Array.getLength(getMembers());
+ i++) {
+ java.lang.Object obj = java.lang.reflect.Array.get(getMembers(), i);
+ if (obj != null &&
+ !obj.getClass().isArray()) {
+ _hashCode += obj.hashCode();
+ }
+ }
+ }
+ if (getName() != null) {
+ _hashCode += getName().hashCode();
+ }
+ __hashCodeCalc = false;
+ return _hashCode;
+ }
+
+ // Type metadata
+ private static org.apache.axis.description.TypeDesc typeDesc =
+ new org.apache.axis.description.TypeDesc(SOAPRole.class, true);
+
+ static {
+ typeDesc.setXmlType(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "SOAPRole"));
+ org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("ID");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "ID"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "long"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(false);
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("active");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "active"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(false);
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("attributes");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "attributes"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "SOAPAttribute"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(true);
+ elemField.setItemQName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "SOAPAttribute"));
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("conception");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "conception"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "dateTime"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(false);
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("description");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "description"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(true);
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("directoryID");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "directoryID"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "long"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(false);
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("lastModified");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "lastModified"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "dateTime"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(false);
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("members");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "members"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(true);
+ elemField.setItemQName(new javax.xml.namespace.QName("urn:SecurityServer", "string"));
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("name");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "name"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(true);
+ typeDesc.addFieldDesc(elemField);
+ }
+
+ /**
+ * Return type metadata object
+ */
+ public static org.apache.axis.description.TypeDesc getTypeDesc() {
+ return typeDesc;
+ }
+
+ /**
+ * Get Custom Serializer
+ */
+ public static org.apache.axis.encoding.Serializer getSerializer(
+ java.lang.String mechType,
+ java.lang.Class _javaType,
+ javax.xml.namespace.QName _xmlType) {
+ return
+ new org.apache.axis.encoding.ser.BeanSerializer(
+ _javaType, _xmlType, typeDesc);
+ }
+
+ /**
+ * Get Custom Deserializer
+ */
+ public static org.apache.axis.encoding.Deserializer getDeserializer(
+ java.lang.String mechType,
+ java.lang.Class _javaType,
+ javax.xml.namespace.QName _xmlType) {
+ return
+ new org.apache.axis.encoding.ser.BeanDeserializer(
+ _javaType, _xmlType, typeDesc);
+ }
+
+}
Added: ofbiz/trunk/specialpurpose/crowd/src/com/atlassian/crowd/integration/soap/SearchRestriction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/crowd/src/com/atlassian/crowd/integration/soap/SearchRestriction.java?rev=767305&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/crowd/src/com/atlassian/crowd/integration/soap/SearchRestriction.java (added)
+++ ofbiz/trunk/specialpurpose/crowd/src/com/atlassian/crowd/integration/soap/SearchRestriction.java Tue Apr 21 21:32:49 2009
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+/**
+ * SearchRestriction.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
+ */
+
+package com.atlassian.crowd.integration.soap;
+
+public class SearchRestriction implements java.io.Serializable {
+ private java.lang.String name;
+
+ private java.lang.String value;
+
+ public SearchRestriction() {
+ }
+
+ public SearchRestriction(
+ java.lang.String name,
+ java.lang.String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+
+ /**
+ * Gets the name value for this SearchRestriction.
+ *
+ * @return name
+ */
+ public java.lang.String getName() {
+ return name;
+ }
+
+
+ /**
+ * Sets the name value for this SearchRestriction.
+ *
+ * @param name
+ */
+ public void setName(java.lang.String name) {
+ this.name = name;
+ }
+
+
+ /**
+ * Gets the value value for this SearchRestriction.
+ *
+ * @return value
+ */
+ public java.lang.String getValue() {
+ return value;
+ }
+
+
+ /**
+ * Sets the value value for this SearchRestriction.
+ *
+ * @param value
+ */
+ public void setValue(java.lang.String value) {
+ this.value = value;
+ }
+
+ private java.lang.Object __equalsCalc = null;
+ public synchronized boolean equals(java.lang.Object obj) {
+ if (!(obj instanceof SearchRestriction)) return false;
+ SearchRestriction other = (SearchRestriction) obj;
+ if (obj == null) return false;
+ if (this == obj) return true;
+ if (__equalsCalc != null) {
+ return (__equalsCalc == obj);
+ }
+ __equalsCalc = obj;
+ boolean _equals;
+ _equals = true &&
+ ((this.name==null && other.getName()==null) ||
+ (this.name!=null &&
+ this.name.equals(other.getName()))) &&
+ ((this.value==null && other.getValue()==null) ||
+ (this.value!=null &&
+ this.value.equals(other.getValue())));
+ __equalsCalc = null;
+ return _equals;
+ }
+
+ private boolean __hashCodeCalc = false;
+ public synchronized int hashCode() {
+ if (__hashCodeCalc) {
+ return 0;
+ }
+ __hashCodeCalc = true;
+ int _hashCode = 1;
+ if (getName() != null) {
+ _hashCode += getName().hashCode();
+ }
+ if (getValue() != null) {
+ _hashCode += getValue().hashCode();
+ }
+ __hashCodeCalc = false;
+ return _hashCode;
+ }
+
+ // Type metadata
+ private static org.apache.axis.description.TypeDesc typeDesc =
+ new org.apache.axis.description.TypeDesc(SearchRestriction.class, true);
+
+ static {
+ typeDesc.setXmlType(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "SearchRestriction"));
+ org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("name");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "name"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(true);
+ typeDesc.addFieldDesc(elemField);
+ elemField = new org.apache.axis.description.ElementDesc();
+ elemField.setFieldName("value");
+ elemField.setXmlName(new javax.xml.namespace.QName("http://soap.integration.crowd.atlassian.com", "value"));
+ elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
+ elemField.setMinOccurs(0);
+ elemField.setNillable(true);
+ typeDesc.addFieldDesc(elemField);
+ }
+
+ /**
+ * Return type metadata object
+ */
+ public static org.apache.axis.description.TypeDesc getTypeDesc() {
+ return typeDesc;
+ }
+
+ /**
+ * Get Custom Serializer
+ */
+ public static org.apache.axis.encoding.Serializer getSerializer(
+ java.lang.String mechType,
+ java.lang.Class _javaType,
+ javax.xml.namespace.QName _xmlType) {
+ return
+ new org.apache.axis.encoding.ser.BeanSerializer(
+ _javaType, _xmlType, typeDesc);
+ }
+
+ /**
+ * Get Custom Deserializer
+ */
+ public static org.apache.axis.encoding.Deserializer getDeserializer(
+ java.lang.String mechType,
+ java.lang.Class _javaType,
+ javax.xml.namespace.QName _xmlType) {
+ return
+ new org.apache.axis.encoding.ser.BeanDeserializer(
+ _javaType, _xmlType, typeDesc);
+ }
+
+}
Added: ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdAuthenticator.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdAuthenticator.java?rev=767305&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdAuthenticator.java (added)
+++ ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdAuthenticator.java Tue Apr 21 21:32:49 2009
@@ -0,0 +1,288 @@
+/*******************************************************************************
+ * 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.ofbiz.crowd;
+
+import java.rmi.RemoteException;
+import java.util.Map;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+import javax.transaction.Transaction;
+
+import org.ofbiz.common.authentication.api.Authenticator;
+import org.ofbiz.common.authentication.api.AuthenticatorException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.ServiceUtil;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.transaction.TransactionUtil;
+import org.ofbiz.entity.transaction.GenericTransactionException;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.crowd.user.UserWrapper;
+import javolution.util.FastMap;
+
+/**
+ * CrowdAuthenticator
+ */
+public class CrowdAuthenticator extends CrowdWorker implements Authenticator {
+
+ private static final String module = CrowdAuthenticator.class.getName();
+ private static final String props = "crowd.properties";
+
+ protected LocalDispatcher dispatcher;
+ protected GenericDelegator delegator;
+
+ /**
+ * Method called when authenticator is first initialized (the delegator
+ * object can be obtained from the LocalDispatcher)
+ *
+ * @param dispatcher The ServiceDispatcher to use for this Authenticator
+ */
+ public void initialize(LocalDispatcher dispatcher) {
+ this.dispatcher = dispatcher;
+ this.delegator = dispatcher.getDelegator();
+ }
+
+ /**
+ * Method to authenticate a user
+ *
+ * @param username User's username
+ * @param password User's password
+ * @param isServiceAuth true if authentication is for a service call
+ * @return true if the user is authenticated
+ * @throws org.ofbiz.common.authentication.api.AuthenticatorException
+ * when a fatal error occurs during authentication
+ */
+ public boolean authenticate(String username, String password, boolean isServiceAuth) throws AuthenticatorException {
+ String token;
+ try {
+ token = callAuthenticate(username, password);
+ } catch (RemoteException e) {
+ throw new AuthenticatorException(e.getMessage(), e);
+ }
+ Debug.logInfo("Crowd auth called; returned token: " + token, module);
+ return token != null;
+ }
+
+ /**
+ * Logs a user out
+ *
+ * @param username User's username
+ * @throws org.ofbiz.common.authentication.api.AuthenticatorException
+ * when logout fails
+ */
+ public void logout(String username) throws AuthenticatorException {
+ }
+
+ /**
+ * Reads user information and syncs it to OFBiz (i.e. UserLogin, Person, etc)
+ *
+ * @param username User's username
+ * @throws org.ofbiz.common.authentication.api.AuthenticatorException
+ * user synchronization fails
+ */
+ public void syncUser(String username) throws AuthenticatorException {
+ UserWrapper user;
+ try {
+ user = callGetUser(username);
+ } catch (RemoteException e) {
+ throw new AuthenticatorException(e.getMessage(), e);
+ }
+
+ GenericValue system;
+ try {
+ system = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "system"), true);
+ } catch (GenericEntityException e) {
+ throw new AuthenticatorException(e.getMessage(), e);
+ }
+
+ GenericValue userLogin;
+ try {
+ userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", user.getName()), false);
+ } catch (GenericEntityException e) {
+ throw new AuthenticatorException(e.getMessage(), e);
+ }
+
+ // suspend the current transaction and load the user
+ Transaction parentTx = null;
+ boolean beganTransaction = false;
+
+ try {
+ try {
+ parentTx = TransactionUtil.suspend();
+ } catch (GenericTransactionException e) {
+ Debug.logError(e, "Could not suspend transaction: " + e.getMessage(), module);
+ }
+
+ try {
+ beganTransaction = TransactionUtil.begin();
+
+ if (userLogin == null) {
+ // create the user
+ createUser(user, system);
+ } else {
+ // update the user information
+ updateUser(user, system, userLogin);
+ }
+
+ } catch (GenericTransactionException e) {
+ Debug.logError(e, "Could not suspend transaction: " + e.getMessage(), module);
+ } finally {
+ try {
+ TransactionUtil.commit(beganTransaction);
+ } catch (GenericTransactionException e) {
+ Debug.logError(e, "Could not commit nested transaction: " + e.getMessage(), module);
+ }
+ }
+ } finally {
+ // resume/restore parent transaction
+ if (parentTx != null) {
+ try {
+ TransactionUtil.resume(parentTx);
+ Debug.logVerbose("Resumed the parent transaction.", module);
+ } catch (GenericTransactionException e) {
+ Debug.logError(e, "Could not resume parent nested transaction: " + e.getMessage(), module);
+ }
+ }
+ }
+ }
+
+ private void createUser(UserWrapper user, GenericValue system) throws AuthenticatorException {
+ // create person + userLogin
+ Map<String, Serializable> createPersonUlMap = FastMap.newInstance();
+ createPersonUlMap.put("firstName", user.getUserAttributeMapper().getFirstName());
+ createPersonUlMap.put("lastName", user.getUserAttributeMapper().getLastName());
+ createPersonUlMap.put("externalAuthId", user.getName());
+ createPersonUlMap.put("externalId", user.getName());
+ createPersonUlMap.put("userLoginId", user.getName());
+ createPersonUlMap.put("currentPassword", "[EXTERNAL]");
+ createPersonUlMap.put("currentPasswordVerify", "[EXTERNAL]");
+ createPersonUlMap.put("userLogin", system);
+ Map<String, Object> createPersonResult;
+ try {
+ createPersonResult = dispatcher.runSync("createPersonAndUserLogin", createPersonUlMap);
+ } catch (GenericServiceException e) {
+ throw new AuthenticatorException(e.getMessage(), e);
+ }
+ if (ServiceUtil.isError(createPersonResult)) {
+ throw new AuthenticatorException(ServiceUtil.getErrorMessage(createPersonResult));
+ }
+ String partyId = (String) createPersonResult.get("partyId");
+
+ // create email
+ Map<String, Serializable> createEmailMap = FastMap.newInstance();
+ createEmailMap.put("emailAddress", user.getUserAttributeMapper().getEmail());
+ createEmailMap.put("contactMechPurposeTypeId", "PRIMARY_EMAIL");
+ createEmailMap.put("partyId", partyId);
+ createEmailMap.put("userLogin", system);
+ Map<String, Object> createEmailResult;
+ try {
+ createEmailResult = dispatcher.runSync("createPartyEmailAddress", createEmailMap);
+ } catch (GenericServiceException e) {
+ throw new AuthenticatorException(e.getMessage(), e);
+ }
+ if (ServiceUtil.isError(createEmailResult)) {
+ throw new AuthenticatorException(ServiceUtil.getErrorMessage(createEmailResult));
+ }
+
+ // create security group(s)
+ Timestamp now = UtilDateTime.nowTimestamp();
+ for (String securityGroup : user.getUserGroupMapper().getSecurityGroups()) {
+ Map<String, Serializable> createSecGrpMap = FastMap.newInstance();
+ createSecGrpMap.put("userLoginId", user.getName());
+ createSecGrpMap.put("groupId", securityGroup);
+ createSecGrpMap.put("fromDate", now);
+ createSecGrpMap.put("userLogin", system);
+
+ Map<String, Object> createSecGrpResult;
+ try {
+ createSecGrpResult = dispatcher.runSync("addUserLoginToSecurityGroup", createSecGrpMap);
+ } catch (GenericServiceException e) {
+ throw new AuthenticatorException(e.getMessage(), e);
+ }
+ if (ServiceUtil.isError(createSecGrpResult)) {
+ throw new AuthenticatorException(ServiceUtil.getErrorMessage(createSecGrpResult));
+ }
+ }
+ }
+
+ private void updateUser(UserWrapper user, GenericValue system, GenericValue userLogin) throws AuthenticatorException {
+ // TODO implement me
+ }
+
+ /**
+ * Updates a user's password
+ *
+ * @param username User's username
+ * @param password User's current password
+ * @param newPassword User's new password
+ * @throws org.ofbiz.common.authentication.api.AuthenticatorException
+ * when update password fails
+ */
+ public void updatePassword(String username, String password, String newPassword) throws AuthenticatorException {
+ Debug.logInfo("Calling Crowd:updatePassword() - " + newPassword, module);
+ try {
+ callUpdatePassword(username, newPassword);
+ } catch (RemoteException e) {
+ throw new AuthenticatorException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Weight of this authenticator (lower weights are run first)
+ *
+ * @return the weight of this Authenicator
+ */
+ public float getWeight() {
+ return 0;
+ }
+
+ /**
+ * Is the user synchronzied back to OFBiz
+ *
+ * @return true if the user record is copied to the OFB database
+ */
+ public boolean isUserSynchronized() {
+ return true;
+ }
+
+ /**
+ * Is this expected to be the only authenticator, if so errors will be thrown when users cannot be found
+ *
+ * @return true if this is expected to be the only Authenticator
+ */
+ public boolean isSingleAuthenticator() {
+ return false;
+ }
+
+ /**
+ * Flag to test if this Authenticator is enabled
+ *
+ * @return true if the Authenticator is enabled
+ */
+ public boolean isEnabled() {
+ return "true".equalsIgnoreCase(UtilProperties.getPropertyValue(props, "crowd.authenticator.enabled", "false"));
+ }
+}
Added: ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdWorker.java?rev=767305&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdWorker.java (added)
+++ ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/CrowdWorker.java Tue Apr 21 21:32:49 2009
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * 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.ofbiz.crowd;
+
+import java.rmi.RemoteException;
+import javax.xml.rpc.ServiceException;
+
+import org.ofbiz.crowd.security.SecurityServerHttpBindingStub;
+import org.ofbiz.crowd.security.SecurityServerLocator;
+import org.ofbiz.crowd.user.UserWrapper;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+import com.atlassian.crowd.integration.authentication.AuthenticatedToken;
+import com.atlassian.crowd.integration.authentication.ApplicationAuthenticationContext;
+import com.atlassian.crowd.integration.authentication.PasswordCredential;
+import com.atlassian.crowd.integration.authentication.ValidationFactor;
+import com.atlassian.crowd.integration.soap.SOAPPrincipal;
+import com.atlassian.crowd.integration.exception.InvalidAuthorizationTokenException;
+import com.atlassian.crowd.integration.exception.ObjectNotFoundException;
+import com.atlassian.crowd.integration.exception.InvalidAuthenticationException;
+import com.atlassian.crowd.integration.exception.InactiveAccountException;
+import com.atlassian.crowd.integration.exception.ApplicationAccessDeniedException;
+
+/**
+ * CrowdWorker
+ */
+public abstract class CrowdWorker {
+
+ private static final String module = CrowdWorker.class.getName();
+
+ protected String callAuthenticate(String user, String password) throws RemoteException {
+ SecurityServerHttpBindingStub stub = getStub();
+ AuthenticatedToken token = getToken(stub);
+
+ // auth the user
+ String userToken;
+ try {
+ userToken = stub.authenticatePrincipalSimple(token, user, password);
+ } catch (InvalidAuthenticationException e) {
+ return null;
+ } catch (InvalidAuthorizationTokenException e) {
+ Debug.logError(e, module);
+ throw e;
+ } catch (ApplicationAccessDeniedException e) {
+ Debug.logError(e, module);
+ throw e;
+ } catch (InactiveAccountException e) {
+ return null;
+ } catch (RemoteException e) {
+ Debug.logError(e, module);
+ throw e;
+ }
+
+ return userToken;
+ }
+
+ protected UserWrapper callGetUser(String user) throws RemoteException {
+ SecurityServerHttpBindingStub stub = getStub();
+ AuthenticatedToken token = getToken(stub);
+
+ SOAPPrincipal principal;
+ try {
+ principal = stub.findPrincipalByName(token, user);
+ } catch (InvalidAuthorizationTokenException e) {
+ Debug.logError(e, module);
+ throw e;
+ } catch (ObjectNotFoundException e) {
+ Debug.logError(e, module);
+ throw e;
+ } catch (RemoteException e) {
+ Debug.logError(e, module);
+ throw e;
+ }
+
+ String[] groups;
+ try {
+ groups = stub.findGroupMemberships(token, user);
+ } catch (InvalidAuthorizationTokenException e) {
+ Debug.logError(e, module);
+ throw e;
+ } catch (ObjectNotFoundException e) {
+ groups = new String[0];
+ } catch (RemoteException e) {
+ Debug.logError(e, module);
+ throw e;
+ }
+
+ return new UserWrapper(principal, groups);
+ }
+
+ protected void callUpdatePassword(String user, String password) throws RemoteException {
+ PasswordCredential credential = new PasswordCredential();
+ credential.setCredential(password);
+ credential.setEncryptedCredential(false);
+
+ SecurityServerHttpBindingStub stub = getStub();
+ AuthenticatedToken token = getToken(stub);
+
+ try {
+ stub.updatePrincipalCredential(token, user, credential);
+ } catch (RemoteException e) {
+ Debug.logError(e, module);
+ throw e;
+ }
+ }
+
+ private AuthenticatedToken getToken(SecurityServerHttpBindingStub stub) {
+ String appName = UtilProperties.getPropertyValue("crowd.properties", "crowd.application.name");
+ String appPass = UtilProperties.getPropertyValue("crowd.properties", "crowd.application.pass");
+
+ // authenticate the integrated crowd application
+ if (stub == null) {
+ stub = getStub();
+ }
+ if (stub != null) {
+ try {
+ return stub.authenticateApplication(new ApplicationAuthenticationContext(
+ new PasswordCredential(appPass, Boolean.FALSE), appName, new ValidationFactor[0]));
+ } catch (RemoteException e) {
+ Debug.logError(e, module);
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ private SecurityServerHttpBindingStub getStub() {
+ try {
+ SecurityServerLocator secServer = new SecurityServerLocator();
+ secServer.setSecurityServerHttpPortEndpointAddress(secServer.getSecurityServerHttpPortAddress());
+ return (SecurityServerHttpBindingStub) secServer.getSecurityServerHttpPort();
+ } catch (ServiceException e) {
+ Debug.logError(e, module);
+ return null;
+ }
+ }
+}
Added: ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/security/SecurityServer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/security/SecurityServer.java?rev=767305&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/security/SecurityServer.java (added)
+++ ofbiz/trunk/specialpurpose/crowd/src/org/ofbiz/crowd/security/SecurityServer.java Tue Apr 21 21:32:49 2009
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+/**
+ * SecurityServer.java
+ *
+ * This file was auto-generated from WSDL
+ * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
+ */
+
+package org.ofbiz.crowd.security;
+
+public interface SecurityServer extends javax.xml.rpc.Service {
+ public java.lang.String getSecurityServerHttpPortAddress();
+
+ public org.ofbiz.crowd.security.SecurityServerPortType getSecurityServerHttpPort() throws javax.xml.rpc.ServiceException;
+
+ public org.ofbiz.crowd.security.SecurityServerPortType getSecurityServerHttpPort(java.net.URL portAddress) throws javax.xml.rpc.ServiceException;
+}