summaryrefslogtreecommitdiffstats
path: root/authentication
diff options
context:
space:
mode:
authorpikusa <pikusa@man.poznan.pl>2013-04-03 13:18:17 (GMT)
committer pikusa <pikusa@man.poznan.pl>2013-04-03 13:18:17 (GMT)
commit2f2a3a129c91de540e66c3bfbe30b0df1942cd4b (patch)
tree2d313cdf0068af368d4de6067d676be16f6a6464 /authentication
parentff8aa232b071a9b54dff833714a870fd0aec0b30 (diff)
downloadnovi-public-2f2a3a129c91de540e66c3bfbe30b0df1942cd4b.zip
novi-public-2f2a3a129c91de540e66c3bfbe30b0df1942cd4b.tar.gz
novi-public-2f2a3a129c91de540e66c3bfbe30b0df1942cd4b.tar.bz2
project commit and dir tree change
Diffstat (limited to 'authentication')
-rw-r--r--authentication/pom.xml62
-rw-r--r--authentication/src/main/java/eu/novi/authentication/Core.java282
-rw-r--r--authentication/src/main/java/eu/novi/authentication/IgnoreSSLCertTrustManager.java67
-rw-r--r--authentication/src/main/java/eu/novi/authentication/InterfaceForPS.java11
-rw-r--r--authentication/src/main/java/eu/novi/authentication/MyTypeFactory.java56
-rw-r--r--authentication/src/main/resources/OSGI-INF/blueprint/config.xml19
-rw-r--r--authentication/src/test/java/eu/novi/authentication/CoreTest.java111
7 files changed, 608 insertions, 0 deletions
diff --git a/authentication/pom.xml b/authentication/pom.xml
new file mode 100644
index 0000000..6e81209
--- /dev/null
+++ b/authentication/pom.xml
@@ -0,0 +1,62 @@
+<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>
+ <groupId>eu.novi</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../parent/</relativePath>
+ </parent>
+ <packaging>bundle</packaging>
+ <artifactId>authentication</artifactId>
+ <name>authentication OSGI bundle</name>
+
+ <properties>
+ <import.packages>*</import.packages>
+ <private.packages>!*</private.packages>
+ <symbolic.name>${pom.groupId}.${pom.artifactId}</symbolic.name>
+ <embed-dep>*;scope=provided;inline=true;type=!pom</embed-dep>
+ <unpack-bundle>false</unpack-bundle>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>eu.novi</groupId>
+ <artifactId>xmlrpc-client-osgi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>eu.novi</groupId>
+ <artifactId>information-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>eu.novi</groupId>
+ <artifactId>feedback</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <unpackBundle>${unpack.bundle}</unpackBundle>
+ <instructions>
+ <Bundle-Name>authentication OSGI Bundle</Bundle-Name>
+ <Bundle-Description>This bundle exposes the required functions for
+ testbed specific operations</Bundle-Description>
+ <Export-Package>eu.novi.authentication.*</Export-Package>
+ <Import-Package>${import.packages}</Import-Package>
+ <Private-Package>${private.packages}</Private-Package>
+ <Embed-Dependency>${embed-dep}</Embed-Dependency>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/authentication/src/main/java/eu/novi/authentication/Core.java b/authentication/src/main/java/eu/novi/authentication/Core.java
new file mode 100644
index 0000000..a4b014d
--- /dev/null
+++ b/authentication/src/main/java/eu/novi/authentication/Core.java
@@ -0,0 +1,282 @@
+package eu.novi.authentication;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import eu.novi.im.core.Platform;
+import eu.novi.im.core.impl.PlatformImpl;
+import eu.novi.im.policy.impl.NOVIUserImpl;
+import eu.novi.im.policy.impl.RoleImpl;
+
+import org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.client.XmlRpcClient;
+import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
+public class Core implements InterfaceForPS{
+ private static final transient Logger log = LoggerFactory.getLogger(Core.class);
+ private RoleImpl plPI=new RoleImpl("PlanetLabPI");
+ private RoleImpl plUser=new RoleImpl("PlanetLabUser");
+
+ public NOVIUserImpl getAuth(String username, String password) throws Exception {
+ Core core = new Core();
+ core.install();
+ NOVIUserImpl theUser= core.call2(username,password);
+ log.info("The User "+username + "returned the NOVIUser object with the session key "+ theUser.getHasSessionKey());
+ System.out.println("Finished.");
+ return theUser;
+ }
+
+
+ public void install() throws Exception {
+ // Create a trust manager that does not validate certificate chains
+ System.setProperty("jsse.enableSNIExtension","false");
+ //System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
+ TrustManager[] trustAllCerts = new TrustManager[] {
+ new X509TrustManager() {
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+
+ public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
+ // Trust always
+ }
+
+ public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
+ // Trust always
+ }
+
+ }
+ };
+
+ // Install the all-trusting trust manager
+ SSLContext sc = SSLContext.getInstance("SSL");
+ // Create empty HostnameVerifier
+ HostnameVerifier hv = new HostnameVerifier() {
+ public boolean verify(String arg0, SSLSession arg1) {
+ return true;
+ }
+ };
+
+ sc.init(null, trustAllCerts, new java.security.SecureRandom());
+ HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
+ HttpsURLConnection.setDefaultHostnameVerifier(hv);
+ }
+
+ public NOVIUserImpl call2(String username, String password) throws MalformedURLException
+ {
+ log.info("Received the auth call for user: "+ username );
+ NOVIUserImpl theUser= new NOVIUserImpl(username);
+ Set<String> hasRoleInPlatform=new HashSet<String>();
+ XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
+ config.setServerURL(new URL("https://myplc.fp7-novi.eu/PLCAPI/"));
+ config.isEnabledForExtensions();
+ config.setEnabledForExtensions(true);
+ config.setEnabledForExceptions(false);
+ XmlRpcClient client = new XmlRpcClient();
+ client.setConfig(config);
+ client.setTypeFactory(new MyTypeFactory(client));
+ Map m = new HashMap();
+ m.put("AuthMethod", "password");
+ m.put("Username", username);
+ m.put("AuthString", password);
+ String n = username;
+ Object[] params = new Object[]{m};
+ Object[] params2 = new Object[]{m,n};
+ Object response;
+ try {
+ // if(userFeedback != null)
+ // userFeedback.instantInfo(userFeedback.getCurrentSessionID(), "Policy Manager AA", "Checking the Authentication Status of user "+username +".","http://www.fp7-novi.eu");
+
+
+ response= client.execute(config, "AuthCheck", params);
+ System.out.println(response.toString());
+ log.info(response.toString());
+ Object Session = client.execute(config,"GetSession",params);
+ System.out.println(Session.toString());
+ log.info(Session.toString());
+ theUser.setHasSessionKey(Session.toString());
+ Platform hasUserPlatform = new PlatformImpl("PlanetLab");
+ theUser.setHasUserPlatform(hasUserPlatform);
+ Object[] person= (Object[]) client.execute(config,"GetPersons",params2);
+ Map p = (Map) person[0];
+ System.out.println(p.get("first_name"));
+ log.info((String) p.get("first_name"));
+ System.out.println(p.get("last_name"));
+ try {
+ Object[] keys= (Object[]) p.get("key_ids");
+ System.out.println(keys[0]);
+ //I am going to add the first key of the user in the list of public keys.
+ Object[] params3 = new Object[]{m,keys};
+ Set<String> publicKeys = new HashSet<String>();
+ Object[] pubkeys =(Object[]) client.execute(config,"GetKeys",params3);
+ Map pkey= (Map) pubkeys[0];
+ String theKey=(String) pkey.get("key");
+ System.out.println(theKey);
+ log.info(theKey);
+ publicKeys.add(theKey);
+ theUser.setPublicKeys(publicKeys);
+ //OK about the public Key
+ theUser.setFirstName((String )p.get("first_name"));
+ theUser.setLastName((String )p.get("last_name"));
+ Object[] roles = (Object[]) p.get("roles");
+
+ for (Object object : roles) {
+ System.out.println(object.toString());
+ hasRoleInPlatform.add(object.toString());
+ }
+ if (hasRoleInPlatform.contains("user"))
+ {
+ theUser.setHasNoviRole(plUser);
+ log.info("The User "+username + " has Role planetlabUser");
+ log.info("The role is stored in the NOVIUser object");
+ if (theUser.getHasNoviRole() != null)
+ {
+ log.info("Print what we stored about the User"+theUser.getHasNoviRole().toString());
+ }
+ else {
+ log.info("Just stored it and still NULL!!!! Error error");
+ }
+
+ }
+ if (hasRoleInPlatform.contains("pi"))
+ {
+ theUser.setHasNoviRole(plPI);
+ log.info("The User "+username + " has Role planetlabPI");
+
+ }
+ theUser.setHasRoleInPlatform(hasRoleInPlatform);
+
+ //if(userFeedback != null)
+ // userFeedback.instantInfo(userFeedback.getCurrentSessionID(), "Policy Manager AA", "The User "+username+ " is authenticated.","http://www.fp7-novi.eu");
+ log.info("The User "+username + " is authenticated .");
+
+ } catch (Exception en)
+ {
+ log.info("No public key! Please upload througt myplc!!");
+ //if(userFeedback != null)
+ // userFeedback.instantInfo(userFeedback.getCurrentSessionID(), "Policy Manager AA", "The User "+username+ " does not have a public key.","http://www.fp7-novi.eu");
+ return theUser;
+ }
+ Object[] sites= (Object[]) p.get("site_ids");
+ System.out.println(sites[0]);
+ theUser.setBelongsToDomain(sites[0].toString());
+
+
+ } catch (XmlRpcException e) {
+ if (e.getMessage().equals(": AuthCheck: Failed to authenticate call: PasswordAuth: Password verification failed"))
+ {
+ System.out.println("Not authenticated");
+ log.info("The User "+username + " is not authenticated .");
+ // if(userFeedback != null)
+ // userFeedback.instantInfo(userFeedback.getCurrentSessionID(), "Policy Manager AA", "The User "+username+ " is NOT authenticated.","http://www.fp7-novi.eu");
+ }
+ else if (e.getMessage().equals(": AuthCheck: Failed to authenticate call: PasswordAuth: No such account"))
+ {
+ System.out.println("Not existing User");
+ log.info("The User "+username + " does not exists.");
+ // if(userFeedback != null)
+ // userFeedback.instantInfo(userFeedback.getCurrentSessionID(), "Policy Manager AA", "The User "+username + " does NOT exist.","http://www.fp7-novi.eu");
+ }
+ else {
+ log.info("e.printStackTrace();");
+ System.out.println("Exception here "+e.getMessage());
+ e.printStackTrace();
+ log.info(e.getMessage());
+ }
+ }
+ return theUser;
+ }
+ public int call3(String sessionkey, String sliceName, int newexpirationTime) throws MalformedURLException
+ {
+ log.info("Received the call for update the expiration time of slice: "+ sliceName +" with new expiration time "+ newexpirationTime );
+ // String theSessionKey=user.getHasSessionKey();
+ log.info("The session key of the User is:" + sessionkey);
+ XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
+ config.setServerURL(new URL("https://myplc.fp7-novi.eu/PLCAPI/"));
+ config.isEnabledForExtensions();
+ config.setEnabledForExtensions(true);
+ config.setEnabledForExceptions(false);
+ XmlRpcClient client = new XmlRpcClient();
+ client.setConfig(config);
+ client.setTypeFactory(new MyTypeFactory(client));
+ Map m = new HashMap();
+ m.put("AuthMethod", "session");
+ m.put("session", sessionkey);
+ Map up = new HashMap();
+ up.put("expires", newexpirationTime);
+ Object[] params2 = new Object[]{m,sliceName,up};
+ Object re;
+ try {
+ re= client.execute(config,"UpdateSlice",params2);
+ log.info("result ="+re.toString());
+ } catch (XmlRpcException e) {
+
+ log.info("e.printStackTrace();");
+ System.out.println("Exception here "+e.getMessage());
+ e.printStackTrace();
+ log.info(e.getMessage());
+ }
+ return 0;
+
+}
+
+
+ public int updateExpirationTime(NOVIUserImpl user, String slice_id, Date date) throws Exception {
+ log.info("Update Slice expiration time");
+ String usersession="";
+ if (user !=null)
+ {
+ if (user.getHasSessionKey()!=null)
+ {
+ usersession= user.getHasSessionKey();
+ }
+ else
+ {
+ log.info("No session key");
+ return 1;
+ }
+ }
+ else
+ {
+ log.info("User is null");
+ return 2;
+ }
+ if (date!= null)
+ {
+ log.info("The date is "+ date.getDate() +"/"+date.getMonth()+"/"+1900+date.getYear());
+ }
+ else
+ {
+ log.info("No date provided");
+ return 3;
+ }
+ if (slice_id==null)
+ {
+ log.info("No slice provided");
+ return 4;
+ }
+ log.info("Update Slice request for "+slice_id + "for "+ date.getTime());
+ String pl_slice_id=slice_id.replaceFirst("http://fp7-novi.eu/im.owl#", "novi_");
+ log.info("Novi slice is :"+pl_slice_id);
+ Core core = new Core();
+ core.install();
+ int dateInformat=(int) (date.getTime()/1000);
+ System.out.println(dateInformat);
+ int success= core.call3(usersession, pl_slice_id, dateInformat);
+ return 0;
+ }
+}
diff --git a/authentication/src/main/java/eu/novi/authentication/IgnoreSSLCertTrustManager.java b/authentication/src/main/java/eu/novi/authentication/IgnoreSSLCertTrustManager.java
new file mode 100644
index 0000000..eac4f92
--- /dev/null
+++ b/authentication/src/main/java/eu/novi/authentication/IgnoreSSLCertTrustManager.java
@@ -0,0 +1,67 @@
+/**
+ *
+ * Copyright (c) 2012, NOVI Consortium, European FP7 NOVI Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the NOVI Consortium nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NOVI CONSORTIUM BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contact: Yiannos Kryftis <ykryftis@netmode.ece.ntua.gr>
+ */
+package eu.novi.authentication;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.ssl.X509TrustManager;
+
+public class IgnoreSSLCertTrustManager implements X509TrustManager {
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] arg0, String arg1)
+ throws CertificateException {
+ // TODO Auto-generated method stub
+
+ }
+ public boolean isClientTrusted()
+ {
+ return true;
+ }
+
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] arg0, String arg1)
+ throws CertificateException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+}
diff --git a/authentication/src/main/java/eu/novi/authentication/InterfaceForPS.java b/authentication/src/main/java/eu/novi/authentication/InterfaceForPS.java
new file mode 100644
index 0000000..16c228e
--- /dev/null
+++ b/authentication/src/main/java/eu/novi/authentication/InterfaceForPS.java
@@ -0,0 +1,11 @@
+package eu.novi.authentication;
+
+import java.util.Date;
+
+import eu.novi.im.policy.impl.NOVIUserImpl;
+
+ public interface InterfaceForPS {
+ public NOVIUserImpl getAuth(String username, String password) throws Exception;
+ public int updateExpirationTime(NOVIUserImpl user, String slice_id, Date date) throws Exception;
+
+}
diff --git a/authentication/src/main/java/eu/novi/authentication/MyTypeFactory.java b/authentication/src/main/java/eu/novi/authentication/MyTypeFactory.java
new file mode 100644
index 0000000..d83f676
--- /dev/null
+++ b/authentication/src/main/java/eu/novi/authentication/MyTypeFactory.java
@@ -0,0 +1,56 @@
+/**
+ *
+ * Copyright (c) 2012, NOVI Consortium, European FP7 NOVI Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the NOVI Consortium nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL NOVI CONSORTIUM BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contact: Yiannos Kryftis <ykryftis@netmode.ece.ntua.gr>
+ */
+package eu.novi.authentication;
+import org.apache.ws.commons.util.NamespaceContextImpl;
+import org.apache.xmlrpc.common.TypeFactoryImpl;
+import org.apache.xmlrpc.common.XmlRpcController;
+import org.apache.xmlrpc.common.XmlRpcStreamConfig;
+import org.apache.xmlrpc.parser.NullParser;
+import org.apache.xmlrpc.parser.TypeParser;
+import org.apache.xmlrpc.serializer.NullSerializer;
+
+public class MyTypeFactory extends TypeFactoryImpl {
+
+ public MyTypeFactory(XmlRpcController pController) {
+ super(pController);
+ }
+
+ @Override
+ public TypeParser getParser(XmlRpcStreamConfig pConfig,
+ NamespaceContextImpl pContext, String pURI, String pLocalName) {
+
+ if ("".equals(pURI) && NullSerializer.NIL_TAG.equals(pLocalName)) {
+ return new NullParser();
+ } else {
+ return super.getParser(pConfig, pContext, pURI, pLocalName);
+ }
+ }
+} \ No newline at end of file
diff --git a/authentication/src/main/resources/OSGI-INF/blueprint/config.xml b/authentication/src/main/resources/OSGI-INF/blueprint/config.xml
new file mode 100644
index 0000000..28361c9
--- /dev/null
+++ b/authentication/src/main/resources/OSGI-INF/blueprint/config.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<!-- Author: Yiannos Kryftis [ykryftis@netmode.ece.ntua.gr] -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
+
+ <!-- <cm:property-placeholder persistent-id="eu.novi.auth"/>-->
+ <bean id="authorizeman" class="eu.novi.authentication.Core" >
+ </bean>
+
+ <service ref="authorizeman" interface="eu.novi.authentication.InterfaceForPS" >
+ <service-properties>
+ <entry key="service.exported.interfaces" value="*" />
+ </service-properties>
+ </service>
+
+
+</blueprint>
diff --git a/authentication/src/test/java/eu/novi/authentication/CoreTest.java b/authentication/src/test/java/eu/novi/authentication/CoreTest.java
new file mode 100644
index 0000000..b71cc81
--- /dev/null
+++ b/authentication/src/test/java/eu/novi/authentication/CoreTest.java
@@ -0,0 +1,111 @@
+package eu.novi.authentication;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.MalformedURLException;
+import java.util.Date;
+import java.util.Set;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import eu.novi.im.policy.NOVIUser;
+import eu.novi.im.policy.impl.NOVIUserImpl;
+
+
+public class CoreTest {
+
+@Ignore
+@Test
+public void testUpdate() throws MalformedURLException
+{
+ Core cor=new Core();
+ String sliceName = "novi_slice_699986568";
+ String sessionk = "IMDciUUdS+oh+3Gsflo4tR9qiPBARJA3Hr+mBubflXo=";
+ int newexpirationTime = 1362057869;
+ System.out.println(cor.call3(sessionk, sliceName, newexpirationTime));
+}
+
+@Test
+@Ignore
+public void TestOnAuth0() throws Exception
+{
+ Core bauth= new Core();
+ //assertEquals(0,bauth.getAuth("ykryftis@netmode.ece.ntua.gr","netmodenovi"));
+ //NOVIUser theUser=bauth.getAuth("ykryftis@netmode.ece.ntua.gr","netmodenovi");
+ NOVIUser theUser=bauth.getAuth("chrisap@noc.ntua.gr","novi1");
+
+ System.out.println(theUser.getHasSessionKey());
+ System.out.println(theUser.toString());
+ System.out.println("OK about Authentication without public key");
+}
+
+
+@Test
+@Ignore
+public void TestOnAuth() throws Exception
+{
+ Core core=new Core();
+ NOVIUser theUser=core.getAuth("ykryftis@netmode.ece.ntua.gr","netmodenovi");
+ System.out.println(theUser.getHasSessionKey());
+ System.out.println(theUser.toString());
+ Set<String> theRoles = theUser.getHasRoleInPlatform();
+ for (Object object : theRoles) {
+ System.out.println(object.toString());
+ }
+ System.out.println(theUser.getHasUserPlatform());
+ assertEquals("http://fp7-novi.eu/im.owl#PlanetLab",theUser.getHasUserPlatform().toString());
+ for (Object object : theUser.getPublicKeys()) {
+ System.out.println(object.toString());
+ // assertEquals("ssh-rsa root@snf-965",object.toString());
+ }
+ System.out.println(theUser.getBelogsToDomain());
+ System.out.println("theUser.getHasNoviRole()"+ theUser.getHasNoviRole());
+ System.out.println("OK about Authentication");
+}
+
+@Test
+@Ignore
+public void TestOnAuth2() throws Exception
+{
+ Core bauth= new Core();
+ //assertEquals(0,bauth.getAuth("ykryftis@netmode.ece.ntua.gr","netmodenovi"));
+ NOVIUser theUser=bauth.getAuth("ykryftis@netmode.ece.ntua.gr","netmoden");
+ if (theUser.getHasSessionKey() == null)
+ {
+ System.out.println("OK SessionKey is null");
+ }
+ System.out.println("OK about NOT Authentication");
+}
+
+@Test
+@Ignore
+public void TestOnAuth3() throws Exception
+{
+ Core bauth= new Core();
+ //assertEquals(0,bauth.getAuth("ykryftis@netmode.ece.ntua.gr","netmodenovi"));
+ NOVIUser theUser=bauth.getAuth("notexisting@nothing.eu","password");
+ if (theUser.getHasSessionKey() == null)
+ {
+ System.out.println("OK SessionKey is null");
+ }
+ System.out.println("OK about NOT Existing User");
+}
+
+@Test
+@Ignore
+public void UpdateSliceExpTest() throws Exception
+{
+ Core ex=new Core();
+ Date date=new Date();
+ date.setMonth(3);
+ date.setDate(5);
+ date.setYear(113);
+ //date.setTime(1362057870);
+ System.out.println(date.toString());
+ NOVIUserImpl user=new NOVIUserImpl("ykryftis@netmode.ece.ntua.gr");
+ user.setHasSessionKey("DaR7A9fn/8kSOV474Xd+JNCyBAo9Viea9MueJXa1cO0=");
+ String slice_id="http://fp7-novi.eu/im.owl#slice_699986568";
+ ex.updateExpirationTime(user, slice_id, date);
+}
+}