-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intial commit of connector for Federation Manager
- Loading branch information
Showing
13 changed files
with
468 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2016 Evolveum | ||
~ | ||
~ 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. | ||
--> | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>polygon</artifactId> | ||
<groupId>com.evolveum.polygon</groupId> | ||
<version>1.5.0.0</version> | ||
</parent> | ||
|
||
<groupId>edu.unc.polygon</groupId> | ||
<artifactId>connector-federation-manager</artifactId> | ||
<version>.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>Federation Manager Connector</name> | ||
|
||
<properties> | ||
<connectorPackage>edu.unc.polygon.connector.federationManager</connectorPackage> | ||
<connectorClass>FederationManagerConnector</connectorClass> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>evolveum-nexus-releases</id> | ||
<name>Internal Releases</name> | ||
<url>http://nexus.evolveum.com/nexus/content/repositories/releases/</url> | ||
</repository> | ||
<repository> | ||
<id>evolveum-nexus-snapshots</id> | ||
<name>Internal Releases</name> | ||
<url>http://nexus.evolveum.com/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
<repository> | ||
<id>apache-snapshots</id> | ||
<name>Apache Snapshots</name> | ||
<url>http://repository.apache.org/snapshots/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<artifactId>connector-rest</artifactId> | ||
<groupId>com.evolveum.polygon</groupId> | ||
<version>1.4.2.14-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.json</groupId> | ||
<artifactId>json</artifactId> | ||
<version>20190722</version> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
</project> |
30 changes: 30 additions & 0 deletions
30
...main/java/edu/unc/polygon/connector/federationManager/FederationManagerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package edu.unc.polygon.connector.federationManager; | ||
|
||
import com.evolveum.polygon.rest.AbstractRestConfiguration; | ||
import org.identityconnectors.common.logging.Log; | ||
import org.identityconnectors.framework.common.exceptions.ConfigurationException; | ||
import org.identityconnectors.framework.common.objects.ObjectClass; | ||
import org.identityconnectors.framework.spi.AbstractConfiguration; | ||
import org.identityconnectors.framework.spi.ConfigurationProperty; | ||
|
||
import java.io.*; | ||
import java.nio.charset.Charset; | ||
import java.util.*; | ||
|
||
|
||
/** | ||
* @author ekromhout@gmail.com | ||
* | ||
*/ | ||
public class FederationManagerConfiguration extends AbstractRestConfiguration { | ||
|
||
private static final Log LOG = Log.getLog(FederationManagerConfiguration.class); | ||
|
||
@Override | ||
public void validate() { | ||
// TODO | ||
} | ||
|
||
} | ||
|
||
|
248 changes: 248 additions & 0 deletions
248
...src/main/java/edu/unc/polygon/connector/federationManager/FederationManagerConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,248 @@ | ||
package edu.unc.polygon.connector.federationManager; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.apache.http.client.methods.CloseableHttpResponse; | ||
import org.apache.http.HttpEntity; | ||
import org.apache.http.HttpRequest; | ||
import org.apache.http.entity.ByteArrayEntity; | ||
import org.apache.http.NameValuePair; | ||
import org.apache.http.client.entity.UrlEncodedFormEntity; | ||
import org.apache.http.client.methods.CloseableHttpResponse; | ||
import org.apache.http.client.methods.HttpGet; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.client.methods.HttpPatch; | ||
import org.apache.http.impl.client.CloseableHttpClient; | ||
import org.apache.http.impl.client.HttpClients; | ||
import org.apache.http.impl.client.HttpClientBuilder; | ||
import org.apache.http.util.EntityUtils; | ||
import org.apache.http.entity.StringEntity; | ||
import org.apache.http.auth.AuthenticationException; | ||
import org.apache.http.client.utils.URIBuilder; | ||
import org.apache.http.client.methods.*; | ||
import org.apache.http.annotation.NotThreadSafe; | ||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
import org.json.JSONException; | ||
import org.identityconnectors.common.Base64; | ||
import org.identityconnectors.common.StringUtil; | ||
import org.identityconnectors.framework.common.objects.ObjectClassInfoBuilder; | ||
import org.identityconnectors.framework.common.objects.Schema; | ||
import org.identityconnectors.framework.common.objects.SchemaBuilder; | ||
import org.identityconnectors.framework.spi.Configuration; | ||
import org.identityconnectors.framework.spi.Connector; | ||
import org.identityconnectors.framework.spi.PoolableConnector; | ||
import org.identityconnectors.framework.spi.ConnectorClass; | ||
import org.identityconnectors.framework.spi.operations.*; | ||
import org.identityconnectors.framework.common.exceptions.*; | ||
import org.identityconnectors.framework.common.exceptions.ConfigurationException; | ||
import org.identityconnectors.framework.common.exceptions.ConnectorException; | ||
import org.identityconnectors.framework.common.objects.*; | ||
import org.identityconnectors.common.logging.Log; | ||
import org.identityconnectors.common.security.GuardedString; | ||
import org.identityconnectors.framework.common.objects.filter.FilterTranslator; | ||
import java.io.IOException; | ||
import java.util.Iterator; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.ArrayList; | ||
import java.io.*; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.lang.Object; | ||
|
||
|
||
import com.evolveum.polygon.rest.AbstractRestConnector; | ||
/** | ||
* @author ethan@unc.edu | ||
* | ||
*/ | ||
@ConnectorClass(displayNameKey = "connector.federation.manager.display", configurationClass = FederationManagerConfiguration.class) | ||
public class FederationManagerConnector extends AbstractRestConnector<FederationManagerConfiguration> implements TestOp, SchemaOp, PoolableConnector, SearchOp<FederationManagerFilter> { | ||
|
||
private static final Log LOG = Log.getLog(FederationManagerConnector.class); | ||
private static final String ATTR_ID = "id"; //__UID__ | ||
private static final String ATTR_ORGANIZATION_ID = "organization_id"; | ||
public static final String ATTR_MAIL = "email"; | ||
public static final String ATTR_FAX_NUMBER = "faxnumber"; | ||
public static final String ATTR_MOBILE_NUMBER = "mobilenumber"; | ||
public static final String ATTR_PHONE_NUMBER = "phonenumber"; | ||
//public static final String ATTR_ROLES = "roles"; | ||
public static final String ATTR_FIRST_NAME = "firstname"; | ||
public static final String ATTR_LAST_NAME = "lastname"; | ||
public static final String ATTR_MIDDLE_NAME = "middlename"; | ||
public static final String ATTR_INFORMAL_NAME = "informalname"; | ||
public static final String ATTR_WEBSITE = "website"; | ||
public static final String CONTENT_TYPE = "application/json"; | ||
|
||
|
||
private FederationManagerConfiguration configuration; | ||
|
||
@Override | ||
public void init(Configuration configuration) { | ||
LOG.info(">>> Initializing connector"); | ||
|
||
if (!(configuration instanceof FederationManagerConfiguration)) { | ||
throw new ConfigurationException("Configuration is not instance of " + FederationManagerConfiguration.class.getName()); | ||
} | ||
|
||
FederationManagerConfiguration wordpressConfig = (FederationManagerConfiguration) configuration; | ||
wordpressConfig.validate(); | ||
this.configuration = wordpressConfig; | ||
//super.init(configuration); | ||
getConfiguration(); | ||
LOG.info(">>> Connector initialization finished"); | ||
} | ||
@Override | ||
public void dispose() { | ||
configuration = null; | ||
//handler = null; | ||
} | ||
@Override | ||
public void test() { | ||
|
||
} | ||
|
||
@Override | ||
public void checkAlive() { | ||
test(); | ||
} | ||
|
||
@Override | ||
public Schema schema() { | ||
SchemaBuilder schemaBuilder = new SchemaBuilder(FederationManagerConnector.class); | ||
//Begin Account Objectclass | ||
Set<AttributeInfo> accountAttributes = new HashSet<AttributeInfo>(); | ||
AttributeInfoBuilder id = new AttributeInfoBuilder(); | ||
id.setName("ATTR_ID"); | ||
id.setCreateable(true); | ||
id.setUpdateable(true); | ||
id.setReadable(true); | ||
id.setRequired(true); | ||
id.setMultiValued(false); | ||
accountAttributes.add(id.build()); | ||
AttributeInfoBuilder email = new AttributeInfoBuilder(); | ||
email.setName("ATTR_EMAIL"); | ||
email.setCreateable(true); | ||
email.setUpdateable(true); | ||
email.setReadable(true); | ||
email.setRequired(false); | ||
email.setMultiValued(true); | ||
accountAttributes.add(email.build()); | ||
AttributeInfoBuilder faxnumber = new AttributeInfoBuilder(); | ||
faxnumber.setName("ATTR_FAX_NUMBER"); | ||
faxnumber.setCreateable(true); | ||
faxnumber.setUpdateable(true); | ||
faxnumber.setReadable(true); | ||
faxnumber.setRequired(false); | ||
faxnumber.setMultiValued(false); | ||
accountAttributes.add(faxnumber.build()); | ||
AttributeInfoBuilder firstname = new AttributeInfoBuilder(); | ||
firstname.setName("ATTR_FIRST_NAME"); | ||
firstname.setCreateable(true); | ||
firstname.setUpdateable(true); | ||
firstname.setReadable(true); | ||
firstname.setRequired(false); | ||
firstname.setMultiValued(false); | ||
accountAttributes.add(firstname.build()); | ||
AttributeInfoBuilder informalname = new AttributeInfoBuilder(); | ||
informalname.setName("ATTR_INFORMAL_NAME"); | ||
informalname.setCreateable(true); | ||
informalname.setUpdateable(true); | ||
informalname.setReadable(true); | ||
informalname.setRequired(false); | ||
informalname.setMultiValued(false); | ||
accountAttributes.add(informalname.build()); | ||
AttributeInfoBuilder lastname = new AttributeInfoBuilder(); | ||
lastname.setName("ATTR_LAST_NAME"); | ||
lastname.setCreateable(true); | ||
lastname.setUpdateable(true); | ||
lastname.setReadable(true); | ||
lastname.setRequired(false); | ||
lastname.setMultiValued(false); | ||
accountAttributes.add(lastname.build()); | ||
AttributeInfoBuilder middlename = new AttributeInfoBuilder(); | ||
middlename.setName("ATTR_MIDDLE_NAME"); | ||
middlename.setCreateable(true); | ||
middlename.setUpdateable(true); | ||
middlename.setReadable(true); | ||
middlename.setRequired(false); | ||
middlename.setMultiValued(false); | ||
accountAttributes.add(middlename.build()); | ||
AttributeInfoBuilder mobilenumber = new AttributeInfoBuilder(); | ||
mobilenumber.setName("ATTR_MOBILE_NAME"); | ||
mobilenumber.setCreateable(true); | ||
mobilenumber.setUpdateable(true); | ||
mobilenumber.setReadable(true); | ||
mobilenumber.setRequired(false); | ||
mobilenumber.setMultiValued(false); | ||
accountAttributes.add(mobilenumber.build()); | ||
AttributeInfoBuilder organization_id = new AttributeInfoBuilder(); | ||
organization_id.setName("ATTR_ORGANIZATION_ID"); | ||
organization_id.setCreateable(true); | ||
organization_id.setUpdateable(true); | ||
organization_id.setReadable(true); | ||
organization_id.setRequired(false); | ||
organization_id.setMultiValued(false); | ||
accountAttributes.add(organization_id.build()); | ||
AttributeInfoBuilder phonenumber = new AttributeInfoBuilder(); | ||
phonenumber.setName("ATTR_PHONE_NUMBER"); | ||
phonenumber.setCreateable(true); | ||
phonenumber.setUpdateable(true); | ||
phonenumber.setReadable(true); | ||
phonenumber.setRequired(false); | ||
phonenumber.setMultiValued(false); | ||
accountAttributes.add(phonenumber.build()); | ||
AttributeInfoBuilder website = new AttributeInfoBuilder(); | ||
website.setName("ATTR_WEBSITE"); | ||
website.setCreateable(true); | ||
website.setUpdateable(true); | ||
website.setReadable(true); | ||
website.setRequired(false); | ||
website.setMultiValued(false); | ||
accountAttributes.add(website.build()); | ||
accountAttributes.add(OperationalAttributeInfos.ENABLE); | ||
schemaBuilder.defineObjectClass(ObjectClass.ACCOUNT.getDisplayNameKey(),accountAttributes); | ||
//Finish Account Objectclass, add others before return if needed | ||
LOG.info(">>> schema finished"); | ||
return schemaBuilder.build(); | ||
|
||
|
||
|
||
} | ||
|
||
public FilterTranslator<FederationManagerFilter> createFilterTranslator(ObjectClass oc, OperationOptions oo) { | ||
LOG.info("inside createFilterTranslator"); | ||
return new FederationManagerFilterTranslator(); | ||
} | ||
|
||
@Override | ||
public void executeQuery(ObjectClass oc, FederationManagerFilter filter, ResultsHandler handler, OperationOptions oo) { | ||
if ( oc.is(ObjectClass.ACCOUNT_NAME)) { | ||
if (filter != null && filter.byUid != null) { | ||
//not sure if this use case exists yet | ||
} | ||
|
||
else if (filter != null && filter.byName != null) { | ||
//not sure if this use case exists yet | ||
} | ||
|
||
else if (filter != null && filter.byEmailAddress != null) { | ||
//not sure if this use case exists yet | ||
} | ||
|
||
else { | ||
//wide open search | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
|
||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...er/src/main/java/edu/unc/polygon/connector/federationManager/FederationManagerFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package edu.unc.polygon.connector.federationManager; | ||
|
||
/** | ||
* | ||
*/ | ||
public class FederationManagerFilter { | ||
public String byName; | ||
public String byUid; | ||
public String byEmailAddress; | ||
|
||
@Override | ||
public String toString() { | ||
return "FederationManagerFilter{" + | ||
"byName='" + byName + '\'' + | ||
", byUid=" + byUid + | ||
", byEmailAddress='" + byEmailAddress + '\'' + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.