karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggrzy...@apache.org
Subject [2/6] karaf git commit: [KARAF-5008] Initial "maven/core" module and first maven:summary command
Date Wed, 21 Jun 2017 13:32:25 GMT
[KARAF-5008] Initial "maven/core" module and first maven:summary command

[KARAF-5008] maven:summary - update and checksum policy information

[KARAF-5008] Additional maven:summary details and settings-security.xml handling

[KARAF-5008] maven:summary for repositories, defaultRepositories and proxies

[KARAF-5008] maven:http-proxy command to list proxies + optional password decryption

[KARAF-5008] org.apache.karaf.maven.SettingsTest#encryptMavenPassword


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/750fd144
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/750fd144
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/750fd144

Branch: refs/heads/master-maven-commands
Commit: 750fd144a1e4c30a743e736af516114b13acd224
Parents: 60e25fa
Author: Grzegorz Grzybek <gr.grzybek@gmail.com>
Authored: Mon Mar 13 15:42:53 2017 +0100
Committer: Grzegorz Grzybek <gr.grzybek@gmail.com>
Committed: Wed Jun 21 15:31:52 2017 +0200

----------------------------------------------------------------------
 maven/core/pom.xml                              | 129 +++++
 .../karaf/maven/command/HttpProxyCommand.java   |  84 +++
 .../command/MavenConfigurationSupport.java      | 578 +++++++++++++++++++
 .../maven/command/RepositoryAddCommand.java     |  35 ++
 .../command/RepositoryEditCommandSupport.java   |  35 ++
 .../maven/command/RepositoryListCommand.java    | 127 ++++
 .../maven/command/RepositoryRemoveCommand.java  |  31 +
 .../karaf/maven/command/SummaryCommand.java     | 239 ++++++++
 .../karaf/maven/core/MavenRepositoryURL.java    | 386 +++++++++++++
 .../src/main/resources/OSGI-INF/bundle.info     |  36 ++
 .../org/apache/karaf/maven/SettingsTest.java    |  62 ++
 .../src/test/resources/reference-settings.xml   |  82 +++
 maven/pom.xml                                   |  40 ++
 pom.xml                                         |  11 +
 14 files changed, 1875 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/pom.xml
----------------------------------------------------------------------
diff --git a/maven/core/pom.xml b/maven/core/pom.xml
new file mode 100644
index 0000000..db2f2a7
--- /dev/null
+++ b/maven/core/pom.xml
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf</groupId>
+        <artifactId>karaf</artifactId>
+        <version>4.2.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.karaf.maven</groupId>
+    <artifactId>org.apache.karaf.maven.core</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Karaf :: Maven :: Core</name>
+    <description>This bundle provides services and commands for Maven diagnostics.</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-settings</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-settings-builder</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-embedder</artifactId>
+            <version>3.0.3</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>${project.basedir}/src/main/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>${project.basedir}/src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*.info</include>
+                </includes>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            org.apache.karaf.maven
+                        </Export-Package>
+                        <Import-Package>
+                            !org.apache.maven*,
+                            !org.codehaus.plexus*,
+                            !org.sonatype.aether*,
+                            !org.sonatype.guice*,
+                            *,
+                        </Import-Package>
+                        <Private-Package>
+                            org.apache.karaf.maven.command,
+                            org.apache.karaf.maven.core,
+                            org.apache.maven.settings.*;-split-package:=merge-first,
+                            org.apache.maven.execution;-split-package:=merge-first,
+                            org.apache.maven.model;-split-package:=merge-first,
+                            org.codehaus.plexus.component.annotations,
+                            org.sonatype.plexus.components.sec.dispatcher*,
+                            org.sonatype.plexus.components.cipher,
+                            org.codehaus.plexus.interpolation,
+                            org.codehaus.plexus.logging,
+                            org.codehaus.plexus.util,
+                            org.codehaus.plexus.util.xml,
+                            org.codehaus.plexus.util.xml.pull,
+                            org.codehaus.plexus.interpolation.os,
+                        </Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/main/java/org/apache/karaf/maven/command/HttpProxyCommand.java
----------------------------------------------------------------------
diff --git a/maven/core/src/main/java/org/apache/karaf/maven/command/HttpProxyCommand.java b/maven/core/src/main/java/org/apache/karaf/maven/command/HttpProxyCommand.java
new file mode 100644
index 0000000..6f8b794
--- /dev/null
+++ b/maven/core/src/main/java/org/apache/karaf/maven/command/HttpProxyCommand.java
@@ -0,0 +1,84 @@
+/*
+ * 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.apache.karaf.maven.command;
+
+import java.util.Dictionary;
+
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.Row;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.apache.maven.settings.Proxy;
+
+@Command(scope = "maven", name = "http-proxy", description = "Manage HTTP proxy configuration for Maven remote repositories")
+@Service
+public class HttpProxyCommand extends MavenConfigurationSupport {
+
+    @Option(name = "--add", description = "Adds HTTP proxy configuration to Maven settings", required = false, multiValued = false)
+    boolean add;
+
+    @Option(name = "--remove", description = "Removes HTTP proxy configuration from Maven settings", required = false, multiValued = false)
+    boolean remove;
+
+    @Override
+    public void doAction(String prefix, Dictionary<String, Object> config) throws Exception {
+        if (add && remove) {
+            System.err.println("Please specify only one of --add and --remove");
+            return;
+        }
+
+        if (add) {
+            // add
+        }
+
+        if (remove) {
+            // remove
+        }
+
+        // list (also after --add or --remove)
+        System.out.println();
+        if (mavenSettings != null && mavenSettings.getProxies() != null && mavenSettings.getProxies().size() > 0) {
+            ShellTable table = new ShellTable();
+            table.column("ID");
+            table.column("Host");
+            table.column("Port");
+            table.column("Username");
+            if (showPasswords) {
+                table.column("Password");
+            }
+            for (Proxy proxy : mavenSettings.getProxies()) {
+                Row row = table.addRow();
+                row.addContent(proxy.getId(), proxy.getHost(), proxy.getPort());
+                row.addContent(proxy.getUsername() != null ? proxy.getUsername() : "");
+                if (showPasswords) {
+                    addPasswordInfo(row, proxyPasswords, proxy.getId(), proxy.getPassword());
+                }
+            }
+            table.print(System.out);
+        } else {
+            System.out.print("No HTTP proxies configured");
+            if (settings != null && settings.value != null) {
+                System.out.print(" in " + settings.value);
+            }
+            System.out.println();
+        }
+
+        System.out.println();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/main/java/org/apache/karaf/maven/command/MavenConfigurationSupport.java
----------------------------------------------------------------------
diff --git a/maven/core/src/main/java/org/apache/karaf/maven/command/MavenConfigurationSupport.java b/maven/core/src/main/java/org/apache/karaf/maven/command/MavenConfigurationSupport.java
new file mode 100644
index 0000000..4c3416a
--- /dev/null
+++ b/maven/core/src/main/java/org/apache/karaf/maven/command/MavenConfigurationSupport.java
@@ -0,0 +1,578 @@
+/*
+ * 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.apache.karaf.maven.command;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.karaf.maven.core.MavenRepositoryURL;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.support.table.Row;
+import org.apache.maven.settings.Profile;
+import org.apache.maven.settings.Proxy;
+import org.apache.maven.settings.Repository;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.building.DefaultSettingsBuilder;
+import org.apache.maven.settings.building.DefaultSettingsBuilderFactory;
+import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
+import org.apache.maven.settings.building.SettingsBuildingException;
+import org.apache.maven.settings.building.SettingsBuildingRequest;
+import org.apache.maven.settings.building.SettingsBuildingResult;
+import org.apache.maven.settings.building.SettingsProblem;
+import org.apache.maven.settings.crypto.DefaultSettingsDecrypter;
+import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
+import org.apache.maven.settings.crypto.SettingsDecryptionResult;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
+import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher;
+import org.sonatype.plexus.components.sec.dispatcher.SecUtil;
+import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity;
+
+/**
+ * <p>Base class for <code>maven:</code> commands.</p>
+ * <p>Important: even if it duplicates some code from pax-url-aether, this should be treated as verification code of
+ * how pax-url-aether should interact with <code>org.ops4j.pax.url.mvn</code> PID configuration.</p>
+ */
+public abstract class MavenConfigurationSupport implements Action {
+
+    public static Logger LOG = LoggerFactory.getLogger(MavenConfigurationSupport.class);
+    protected static final String PID = "org.ops4j.pax.url.mvn";
+
+    protected static final String PATTERN_PID_PROPERTY = "Explicit %s PID configuration (%s)";
+
+    protected static final String PROPERTY_LOCAL_REPOSITORY = "localRepository";
+    protected static final String PROPERTY_DEFAULT_REPOSITORIES = "defaultRepositories";
+    protected static final String PROPERTY_REPOSITORIES = "repositories";
+    protected static final String PROPERTY_SETTINGS_FILE = "settings";
+    protected static final String PROPERTY_SECURITY_FILE = "security";
+    protected static final String PROPERTY_GLOBAL_UPDATE_POLICY = "globalUpdatePolicy";
+    protected static final String PROPERTY_GLOBAL_CHECKSUM_POLICY = "globalChecksumPolicy";
+    protected static final String PROPERTY_UPDATE_RELEASES = "updateReleases";
+    protected static final String REQUIRE_CONFIG_ADMIN_CONFIG = "requireConfigAdminConfig";
+    protected static final String PROPERTY_USE_FALLBACK_REPOSITORIES = "useFallbackRepositories";
+    protected static final String PROPERTY_OFFLINE = "offline";
+    protected static final String PROPERTY_CERTIFICATE_CHECK = "certificateCheck";
+
+    // TODO timeout options {
+    protected static final String PROPERTY_TIMEOUT = "timeout";
+    protected static final String PROPERTY_SOCKET_SO_TIMEOUT = "socket.readTimeout";
+    protected static final String PROPERTY_SOCKET_SO_KEEPALIVE = "socket.keepAlive";
+    protected static final String PROPERTY_SOCKET_SO_LINGER = "socket.linger";
+    protected static final String PROPERTY_SOCKET_SO_REUSEADDRESS = "socket.reuseAddress";
+    protected static final String PROPERTY_SOCKET_TCP_NODELAY = "socket.tcpNoDelay";
+    protected static final String PROPERTY_SOCKET_CONNECTION_TIMEOUT = "socket.connectionTimeout";
+    protected static final String PROPERTY_CONNECTION_BUFFER_SIZE = "connection.bufferSize";
+    protected static final String PROPERTY_CONNECTION_RETRY_COUNT = "connection.retryCount";
+    // }
+
+    protected SourceAnd<File> localRepository;
+    protected SourceAnd<File> settings;
+    protected Settings mavenSettings;
+    protected SourceAnd<File> securitySettings;
+    protected SettingsSecurity mavenSecuritySettings;
+
+    protected Map<String, Server> servers = new HashMap<>();
+    protected Map<String, String> serverPasswords = new HashMap<>();
+    protected Map<String, String> proxyPasswords = new HashMap<>();
+
+    protected List<String> warnings = new LinkedList<>();
+
+    private static final String masterMasterPassword = DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION;
+    protected String masterPassword;
+    protected DefaultPlexusCipher cipher;
+
+    @Reference
+    protected ConfigurationAdmin cm;
+
+    @Reference
+    protected BundleContext context;
+
+    @Reference
+    protected Session session;
+
+    @Option(name = "-x", aliases = { "--show-passwords" }, description = "Do not hide passwords related to Maven encryption", required = false, multiValued = false)
+    boolean showPasswords;
+
+    @Override
+    final public Object execute() throws Exception {
+        Configuration c = cm.getConfiguration(PID);
+
+        if (c != null && c.getProperties() != null) {
+            try {
+                cipher = new DefaultPlexusCipher();
+                securitySettings = securitySettings((String) c.getProperties().get(PID + "." + PROPERTY_SECURITY_FILE));
+                if (securitySettings != null && securitySettings.value != null) {
+                    mavenSecuritySettings = readSecuritySettings(securitySettings.value);
+                }
+
+                settings = settings((String) c.getProperties().get(PID + "." + PROPERTY_SETTINGS_FILE));
+                if (settings != null && settings.value != null) {
+                    mavenSettings = readSettings(settings.value);
+                }
+
+                localRepository = localRepository((String) c.getProperties().get(PID + "." + PROPERTY_LOCAL_REPOSITORY));
+
+                if (showPasswords) {
+                    decryptSettings();
+                }
+
+                doAction(PID + ".", c.getProperties());
+            } catch (Exception e) {
+                System.err.println(e.getMessage());
+                LOG.error(e.getMessage(), e);
+            }
+        } else {
+            System.err.printf("Can't access \"%s\" configuration\n", PID);
+        }
+
+        return null;
+    }
+
+    /**
+     * Performs command action on <strong>existing</strong> <code>org.ops4j.pax.url.mvn</code>
+     * PID configuration
+     * @param prefix
+     * @param config
+     */
+    abstract protected void doAction(String prefix, Dictionary<String, Object> config) throws Exception;
+
+    /**
+     * Gets effective location of <code>settings.xml</code> file - according to pax-url-aether rules
+     * @param cmProperty property obtained from Config Admin
+     * @return
+     */
+    protected SourceAnd<File> settings(String cmProperty) {
+        SourceAnd<File> result = new SourceAnd<>();
+        URL locationUrl = null;
+        String probableErrorMessage = null;
+
+        // 1. PID + ".settings"
+        if (cmProperty != null && !"".equals(cmProperty.trim())) {
+            result.source = String.format(PATTERN_PID_PROPERTY, PID, PID + "." + PROPERTY_SETTINGS_FILE);
+            try {
+                locationUrl = new URL(cmProperty);
+                probableErrorMessage = String.format("%s configured in %s.%s is not accessible",
+                        locationUrl, PID, PROPERTY_SETTINGS_FILE);
+            } catch (MalformedURLException e) {
+                File file = new File(cmProperty);
+                if (file.isFile()) {
+                    result.value = file;
+                    return result;
+                }
+            }
+        }
+
+        if (locationUrl == null) {
+            // 2. System.getProperty("user.home") + "/.m2/settings.xml"
+            File file = new File(System.getProperty("user.home") + "/.m2/settings.xml");
+            if (file.isFile()) {
+                result.value = file;
+                result.source = "Implicit ${user.home}/.m2/settings.xml";
+                return result;
+            }
+
+            // 3. System.getProperty("maven.home") + "/conf/settings.xml"
+            file = new File(System.getProperty("maven.home") + "/conf/settings.xml");
+            if (file.isFile()) {
+                result.value = file;
+                result.source = "Implicit ${maven.home}/conf/settings.xml";
+                return result;
+            }
+
+            // 4. System.getenv("M2_HOME") + "/conf/settings.xml"
+            file = new File(System.getenv("M2_HOME") + "/conf/settings.xml");
+            if (file.isFile()) {
+                result.value = file;
+                result.source = "Implicit $M2_HOME/conf/settings.xml";
+                return result;
+            }
+        } else {
+            File file = new File(locationUrl.getPath());
+            result.value = file;
+            if (!file.isFile()) {
+                result.source = probableErrorMessage;
+            }
+            return result;
+        }
+
+        // 5. new org.apache.maven.settings.Settings()
+        result.value = null;
+        result.source = "No implicit settings.xml location is available";
+        return result;
+    }
+
+    /**
+     * Gets effective location of <code>settings-security.xml</code> file - according to pax-url-aether rules
+     * @param cmProperty property obtained from Config Admin
+     * @return
+     */
+    protected SourceAnd<File> securitySettings(String cmProperty) {
+        SourceAnd<File> result = new SourceAnd<>();
+        URL locationUrl = null;
+        String probableErrorMessage = null;
+
+        // 1. PID + ".security"
+        if (cmProperty != null && !"".equals(cmProperty.trim())) {
+            result.source = String.format(PATTERN_PID_PROPERTY, PID, PID + "." + PROPERTY_SECURITY_FILE);
+            try {
+                locationUrl = new URL(cmProperty);
+                probableErrorMessage = String.format("%s configured in %s.%s is not accessible",
+                        locationUrl, PID, PROPERTY_SECURITY_FILE);
+            } catch (MalformedURLException e) {
+                File file = new File(cmProperty);
+                if (file.isFile()) {
+                    result.value = file;
+                    return result;
+                }
+            }
+        }
+
+        // 2. System.getProperty("user.home") + "/.m2/settings-security.xml"
+        if (locationUrl == null) {
+            File file = new File(System.getProperty("user.home") + "/.m2/settings-security.xml");
+            if (file.isFile()) {
+                result.value = file;
+                result.source = "Implicit ${user.home}/.m2/settings-security.xml";
+                return result;
+            }
+        } else {
+            File file = new File(locationUrl.getPath());
+            result.value = file;
+            if (!file.isFile()) {
+                result.source = probableErrorMessage;
+            }
+        }
+
+        result.value = null;
+        result.source = "No implicit settings-security.xml location is available";
+        return result;
+    }
+
+    /**
+     * Gets effective location of <em>local repository</em> - according to pax-url-aether rules
+     * @param cmProperty property obtained from Config Admin
+     * @return
+     */
+    protected SourceAnd<File> localRepository(String cmProperty) {
+        SourceAnd<File> result = new SourceAnd<>();
+        URL locationUrl = null;
+        String probableErrorMessage = null;
+
+        // 1. PID + ".localRepository"
+        if (cmProperty != null && !"".equals(cmProperty.trim())) {
+            result.source = String.format(PATTERN_PID_PROPERTY, PID, PID + "." + PROPERTY_LOCAL_REPOSITORY);
+            try {
+                locationUrl = new URL(cmProperty);
+                probableErrorMessage = String.format("%s configured in %s.%s is not accessible",
+                        locationUrl, PID, PROPERTY_LOCAL_REPOSITORY);
+            } catch (MalformedURLException e) {
+                File file = new File(cmProperty);
+                if (file.isDirectory()) {
+                    result.value = file;
+                    return result;
+                }
+            }
+        }
+
+        // 2. from settings.xml
+        if (locationUrl == null && mavenSettings != null && mavenSettings.getLocalRepository() != null) {
+            result.source = String.format("Explicit <localRepository> in %s", settings.value);
+            try {
+                locationUrl = new URL(mavenSettings.getLocalRepository());
+                probableErrorMessage = String.format("%s configured in %s is not accessible",
+                        mavenSettings.getLocalRepository(), settings.value);
+            } catch (MalformedURLException e) {
+                File file = new File(mavenSettings.getLocalRepository());
+                if (file.isDirectory()) {
+                    result.value = file;
+                    return result;
+                }
+            }
+        }
+
+        // 3. System.getProperty("user.home") + "/.m2/repository";
+        if (locationUrl == null) {
+            File file = new File(System.getProperty("user.home") + "/.m2/repository");
+            result.value = file; // whether it exists or not
+            if (file.isDirectory()) {
+                result.source = "Implicit ${user.home}/.m2/repository";
+            } else {
+                result.source = "Implicit ${user.home}/.m2/repository (not accessible)";
+            }
+            return result;
+        }
+
+        File file = new File(locationUrl.getPath());
+        result.value = file;
+        if (!file.isDirectory()) {
+            result.source = probableErrorMessage;
+        }
+        return result;
+    }
+
+    /**
+     * Reads on demand <code>settings.xml</code> file - without password decryption. Also
+     * collects declared servers by ID.
+     * @param settingsFile
+     */
+    protected synchronized Settings readSettings(File settingsFile) throws SettingsBuildingException {
+        if (!settingsFile.isFile() || !settingsFile.canRead()) {
+            return null;
+        }
+
+        try {
+            DefaultSettingsBuilderFactory factory = new DefaultSettingsBuilderFactory();
+            DefaultSettingsBuilder builder = factory.newInstance();
+            SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
+            request.setUserSettingsFile(settingsFile);
+
+            SettingsBuildingResult result = builder.build(request);
+            if (result.getProblems().size() > 0) {
+                for (SettingsProblem problem : result.getProblems()) {
+                    System.err.println(problem);
+                }
+                return null;
+            } else {
+                Settings settings = result.getEffectiveSettings();
+                if (settings.getServers() != null) {
+                    for (Server server : settings.getServers()) {
+                        servers.put(server.getId(), server);
+                    }
+                }
+                return settings;
+            }
+        } catch (Throwable e) {
+            System.err.println(e.getMessage());
+            LOG.error(e.getMessage(), e);
+            throw e;
+        }
+    }
+
+    /**
+     * Re-reads on demand <code>settings-security.xml</code> file
+     * @param securitySettingsFile
+     */
+    protected synchronized SettingsSecurity readSecuritySettings(File securitySettingsFile) throws Exception {
+        if (!securitySettingsFile.isFile() || !securitySettingsFile.canRead()) {
+            return null;
+        }
+
+        try {
+            return SecUtil.read(securitySettingsFile.getAbsolutePath(), true);
+        } catch (Throwable e) {
+            System.err.println(e.getMessage());
+            LOG.error(e.getMessage(), e);
+            throw e;
+        }
+    }
+
+    /**
+     * <p>Decrypts passwords inside correctly read <code>settings.xml</code>. Also tries to decrypt master password.</p>
+     * <p>Not called implicitly for each action invocation.</p>
+     */
+    private void decryptSettings() throws Exception {
+        if (mavenSecuritySettings != null && mavenSettings != null) {
+            masterPassword = cipher.decryptDecorated(mavenSecuritySettings.getMaster(), masterMasterPassword);
+            DefaultSecDispatcher dispatcher = new DefaultSecDispatcher();
+            DefaultSettingsDecrypter decrypter = new DefaultSettingsDecrypter();
+            try {
+                dispatcher.setConfigurationFile(securitySettings.value.getAbsolutePath());
+                Field f = dispatcher.getClass().getDeclaredField("_cipher");
+                f.setAccessible(true);
+                f.set(dispatcher, cipher);
+
+                f = decrypter.getClass().getDeclaredField("securityDispatcher");
+                f.setAccessible(true);
+                f.set(decrypter, dispatcher);
+
+                DefaultSettingsDecryptionRequest req = new DefaultSettingsDecryptionRequest(mavenSettings);
+                SettingsDecryptionResult res = decrypter.decrypt(req);
+                if (res.getProblems() != null && res.getProblems().size() > 0) {
+                    for (SettingsProblem sp : res.getProblems()) {
+                        System.err.println(sp);
+                    }
+                }
+
+                for (Proxy proxy : res.getProxies()) {
+                    if (!cipher.isEncryptedString(proxy.getPassword())) {
+                        proxyPasswords.put(proxy.getId(), proxy.getPassword());
+                    }
+                }
+                for (Server server : res.getServers()) {
+                    if (!cipher.isEncryptedString(server.getPassword())) {
+                        serverPasswords.put(server.getId(), server.getPassword());
+                    }
+                }
+            } catch (Throwable t) {
+                LOG.warn("Can't decrypt " + securitySettings.value, t);
+            }
+        }
+    }
+
+    /**
+     * Returns list of configured remote (<code>remote=true</code>) or default (<code>remote=false</code>)
+     * repositories.
+     * @param remote
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    protected MavenRepositoryURL[] repositories(Dictionary<String, Object> config, boolean remote) throws Exception {
+        String property = remote ? PID + "." + PROPERTY_REPOSITORIES : PID + "." + PROPERTY_DEFAULT_REPOSITORIES;
+        String[] repositories = listOfValues((String) config.get(property));
+
+        if (remote) {
+            if (repositories.length == 0 || repositories.length > 0 && repositories[0].charAt(0) == '+') {
+                if (repositories.length > 0) {
+                    repositories[0] = repositories[0].substring(1);
+                }
+
+                List<String> newRepositories = new LinkedList<>();
+                newRepositories.addAll(Arrays.asList(repositories));
+
+                // append all repositories from all active profiles from available settings.xml
+                if (mavenSettings != null) {
+                    // see org.ops4j.pax.url.mvn.internal.config.MavenConfigurationImpl.getRepositories()
+                    Set<String> activeProfiles = new LinkedHashSet<>(mavenSettings.getActiveProfiles());
+                    Map<String, Profile> profiles = (Map<String, Profile>)mavenSettings.getProfilesAsMap();
+                    profiles.values().stream()
+                            .filter((profile) -> profile.getActivation() != null && profile.getActivation().isActiveByDefault())
+                            .map(Profile::getId)
+                            .forEach(activeProfiles::add);
+
+                    for (String activeProfile : activeProfiles) {
+                        Profile profile = profiles.get(activeProfile);
+                        if (profile == null) {
+                            continue;
+                        }
+                        for (Repository repo : profile.getRepositories()) {
+                            StringBuilder builder = new StringBuilder();
+                            builder.append(repo.getUrl());
+                            builder.append("@id=").append(repo.getId());
+                            builder.append("@_from=").append(MavenRepositoryURL.FROM.SETTINGS);
+
+                            if (repo.getReleases() != null) {
+                                if (!repo.getReleases().isEnabled()) {
+                                    builder.append("@noreleases");
+                                }
+                                addPolicy(builder, repo.getReleases().getUpdatePolicy(), "releasesUpdate");
+                                // not used in pax-url-aether
+                                //addPolicy(builder, repo.getReleases().getChecksumPolicy(), "releasesChecksum");
+                            }
+                            if (repo.getSnapshots() != null) {
+                                if (repo.getSnapshots().isEnabled()) {
+                                    builder.append("@snapshots");
+                                }
+                                addPolicy(builder, repo.getSnapshots().getUpdatePolicy(), "snapshotsUpdate");
+                                // not used in pax-url-aether
+                                //addPolicy(builder, repo.getSnapshots().getChecksumPolicy(), "snapshotsChecksum");
+                            }
+                            newRepositories.add(builder.toString());
+                        }
+                    }
+                }
+
+                repositories = newRepositories.toArray(new String[newRepositories.size()]);
+            }
+        }
+
+        List<MavenRepositoryURL> result = new LinkedList<>();
+        for (String repo : repositories) {
+            result.add(new MavenRepositoryURL(repo));
+        }
+        return result.toArray(new MavenRepositoryURL[result.size()]);
+    }
+
+    private void addPolicy(StringBuilder builder, String policy, String option) {
+        if (policy != null && !policy.isEmpty()) {
+            builder.append("@");
+            builder.append(option);
+            builder.append("=");
+            builder.append(policy);
+        }
+    }
+
+    /**
+     * Splits comma separated list of values into String array
+     * @param list
+     * @return
+     */
+    protected String[] listOfValues(String list) {
+        if (list == null) {
+            return new String[0];
+        }
+
+        String[] values = list.split("\\s*,\\s*");
+        return Arrays.stream(values)
+                .filter((value) -> (value != null && !"".equals(value.trim())))
+                .toArray(String[]::new);
+    }
+
+    /**
+     * Adds information used by proxy/server
+     * @param row {@link org.apache.karaf.shell.support.table.ShellTable}'s row to add information to
+     * @param id2Password mapping of ids (servers/proxies to decrypted passwords)
+     * @param id ID of proxy or server from <code>settings.xml</code>
+     * @param password password to use if decryption failed
+     */
+    protected void addPasswordInfo(Row row, Map<String, String> id2Password, String id, String password) {
+        if (id2Password.containsKey(id)) {
+            row.addContent(id2Password.get(id));
+        } else {
+            if (cipher.isEncryptedString(password)) {
+                row.addContent(password + " (can't decrypt)");
+            } else {
+                row.addContent(password == null ? "" : password);
+            }
+        }
+    }
+
+    protected static class SourceAnd<T> {
+        String source;
+        T value;
+
+        public SourceAnd() {
+        }
+
+        public SourceAnd(String source, T value) {
+            this.source = source;
+            this.value = value;
+        }
+
+        public String val() {
+            return value == null ? "" : value.toString();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryAddCommand.java
----------------------------------------------------------------------
diff --git a/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryAddCommand.java b/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryAddCommand.java
new file mode 100644
index 0000000..13bcbdb
--- /dev/null
+++ b/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryAddCommand.java
@@ -0,0 +1,35 @@
+/*
+ * 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.apache.karaf.maven.command;
+
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+@Command(scope = "maven", name = "repository-add", description = "Adds Maven repository")
+@Service
+public class RepositoryAddCommand extends RepositoryEditCommandSupport {
+
+    @Option(name = "-x", aliases = { "--show-passwords" }, description = "Do not hide passwords related to Maven encryption", required = false, multiValued = false)
+    boolean showPasswords;
+
+    @Override
+    protected void edit() {
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryEditCommandSupport.java
----------------------------------------------------------------------
diff --git a/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryEditCommandSupport.java b/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryEditCommandSupport.java
new file mode 100644
index 0000000..0179b02
--- /dev/null
+++ b/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryEditCommandSupport.java
@@ -0,0 +1,35 @@
+/*
+ * 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.apache.karaf.maven.command;
+
+import java.util.Dictionary;
+
+import org.apache.karaf.maven.core.MavenRepositoryURL;
+import org.apache.karaf.shell.api.action.Option;
+
+public abstract class RepositoryEditCommandSupport extends MavenConfigurationSupport {
+
+    @Override
+    public void doAction(String prefix, Dictionary<String, Object> config) throws Exception {
+        edit();
+
+        session.execute("maven:repository-list");
+    }
+
+    protected abstract void edit();
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryListCommand.java
----------------------------------------------------------------------
diff --git a/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryListCommand.java b/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryListCommand.java
new file mode 100644
index 0000000..90c7c26
--- /dev/null
+++ b/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryListCommand.java
@@ -0,0 +1,127 @@
+/*
+ * 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.apache.karaf.maven.command;
+
+import java.util.Dictionary;
+
+import org.apache.karaf.maven.core.MavenRepositoryURL;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.Row;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.apache.maven.settings.Server;
+
+@Command(scope = "maven", name = "repository-list", description = "Maven repository summary.")
+@Service
+public class RepositoryListCommand extends MavenConfigurationSupport {
+
+    @Option(name = "-v", aliases = { "--verbose" }, description = "Show additional information (policies, source)", required = false, multiValued = false)
+    boolean verbose;
+
+    @Override
+    public void doAction(String prefix, Dictionary<String, Object> config) throws Exception {
+        ShellTable table = new ShellTable();
+        table.column("ID");
+        table.column("URL");
+        if (verbose) {
+            table.column("Releases");
+            table.column("Snapshots");
+            table.column("Defined in");
+        }
+        if (showPasswords) {
+            table.column("Username");
+            table.column("Password");
+        }
+
+        System.out.println();
+        System.out.println("== Remote repositories");
+        MavenRepositoryURL[] repositories = repositories(config, true);
+        for (MavenRepositoryURL repoURL : repositories) {
+            Row row = table.addRow();
+            row.addContent(repoURL.getId(), repoURL.getURL());
+            if (verbose) {
+                row.addContent(repositoryKindInfo(repoURL, false),
+                        repositoryKindInfo(repoURL, true),
+                        repoURL.getFrom());
+            }
+            if (showPasswords) {
+                if (servers.containsKey(repoURL.getId())) {
+                    Server server = servers.get(repoURL.getId());
+                    row.addContent(server.getUsername() == null ? "" : server.getUsername());
+                    addPasswordInfo(row, serverPasswords, repoURL.getId(), server.getPassword());
+                } else {
+                    row.addContent("", "");
+                }
+            }
+        }
+
+        table.print(System.out);
+
+        table = new ShellTable();
+        table.column("ID");
+        table.column("URL");
+        if (verbose) {
+            table.column("Releases");
+            table.column("Snapshots");
+        }
+
+        System.out.println();
+        System.out.println("== Default repositories");
+        repositories = repositories(config, false);
+        for (MavenRepositoryURL repoURL : repositories) {
+            Row row = table.addRow();
+            row.addContent(repoURL.getId(),
+                    repoURL.getURL());
+            if (verbose) {
+                row.addContent(repositoryKindInfo(repoURL, false),
+                        repositoryKindInfo(repoURL, true),
+                        repoURL.getFrom());
+            }
+        }
+
+        table.print(System.out);
+        System.out.println();
+    }
+
+    /**
+     * Information about release/snapshot handing for give repository URL
+     * @param repoURL
+     * @param snapshots
+     * @return
+     */
+    private Object repositoryKindInfo(MavenRepositoryURL repoURL, boolean snapshots) {
+        if (snapshots) {
+            if (repoURL.isSnapshotsEnabled()) {
+                String snapshotsUpdatePolicy = repoURL.getSnapshotsUpdatePolicy();
+                return String.format("yes (%s)",
+                        snapshotsUpdatePolicy == null || "".equals(snapshotsUpdatePolicy.trim()) ? "daily" : snapshotsUpdatePolicy
+                );
+            }
+        } else {
+            if (repoURL.isReleasesEnabled()) {
+                String releasesUpdatePolicy = repoURL.getReleasesUpdatePolicy();
+                return String.format("yes (%s)",
+                        releasesUpdatePolicy == null || "".equals(releasesUpdatePolicy.trim()) ? "daily" : releasesUpdatePolicy
+                );
+            }
+        }
+
+        return "no";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryRemoveCommand.java
----------------------------------------------------------------------
diff --git a/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryRemoveCommand.java b/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryRemoveCommand.java
new file mode 100644
index 0000000..46f82c8
--- /dev/null
+++ b/maven/core/src/main/java/org/apache/karaf/maven/command/RepositoryRemoveCommand.java
@@ -0,0 +1,31 @@
+/*
+ * 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.apache.karaf.maven.command;
+
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+@Command(scope = "maven", name = "repository-remove", description = "Removes Maven repository")
+@Service
+public class RepositoryRemoveCommand extends RepositoryEditCommandSupport {
+
+    @Override
+    protected void edit() {
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/main/java/org/apache/karaf/maven/command/SummaryCommand.java
----------------------------------------------------------------------
diff --git a/maven/core/src/main/java/org/apache/karaf/maven/command/SummaryCommand.java b/maven/core/src/main/java/org/apache/karaf/maven/command/SummaryCommand.java
new file mode 100644
index 0000000..1678239
--- /dev/null
+++ b/maven/core/src/main/java/org/apache/karaf/maven/command/SummaryCommand.java
@@ -0,0 +1,239 @@
+/*
+ * 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.apache.karaf.maven.command;
+
+import java.util.Dictionary;
+
+import org.apache.karaf.maven.core.MavenRepositoryURL;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.Row;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.apache.maven.settings.Proxy;
+
+@Command(scope = "maven", name = "summary", description = "Maven configuration summary.")
+@Service
+public class SummaryCommand extends MavenConfigurationSupport {
+
+    @Option(name = "-p", aliases = { "--property-ids" }, description = "Use PID property identifiers instead of their names", required = false, multiValued = false)
+    boolean propertyIds;
+
+    @Option(name = "-s", aliases = { "--source" }, description = "Adds information about where the value is configured", required = false, multiValued = false)
+    boolean source;
+
+    @Option(name = "-d", aliases = { "--description" }, description = "Adds description of Maven configuration options", required = false, multiValued = false)
+    boolean description;
+
+    @Override
+    protected void doAction(String prefix, Dictionary<String, Object> config) throws Exception {
+        ShellTable table = new ShellTable();
+        table.column("Option");
+        table.column("Value");
+        if (source) {
+            table.column("Source");
+        }
+        if (description) {
+            table.column("Description");
+        }
+
+        addRow(table, propertyIds ? PROPERTY_LOCAL_REPOSITORY : "Local repository", localRepository,
+                "Maven repository to store artifacts resolved in *remote repositories*");
+
+        addRow(table, propertyIds ? PROPERTY_SETTINGS_FILE : "Settings file", settings,
+                "Settings file that may contain configuration of additional repositories, http proxies and mirrors");
+
+        addRow(table, propertyIds ? PROPERTY_SECURITY_FILE : "Security settings file", securitySettings,
+                "Settings file that contain (or relocates to) master Maven password");
+
+        if (showPasswords) {
+            addRow(table, propertyIds ? "<master>" : "Master password", new SourceAnd<String>(securitySettings.source, masterPassword),
+                    "Master password used to decrypt proxy and server passwords");
+        }
+
+        // for default update/checksum policies specified at repository URI level, see
+        // org.ops4j.pax.url.mvn.internal.AetherBasedResolver.addRepo()
+
+        // see org.eclipse.aether.internal.impl.DefaultUpdatePolicyAnalyzer#isUpdatedRequired()
+        SourceAnd<String> updatePolicy = updatePolicy((String) config.get(prefix + PROPERTY_GLOBAL_UPDATE_POLICY));
+        addRow(table, propertyIds ? PROPERTY_GLOBAL_UPDATE_POLICY : "Global update policy", updatePolicy,
+                "Overrides update policy specified at repository level (if specified)");
+
+        // see org.eclipse.aether.internal.impl.DefaultChecksumPolicyProvider#newChecksumPolicy()
+        SourceAnd<String> checksumPolicy = checksumPolicy((String) config.get(prefix + PROPERTY_GLOBAL_CHECKSUM_POLICY));
+        addRow(table, propertyIds ? PROPERTY_GLOBAL_CHECKSUM_POLICY : "Global checksum policy", checksumPolicy,
+                "Checksum policy for all repositories");
+
+        String updateReleasesProperty = (String) config.get(prefix + PROPERTY_UPDATE_RELEASES);
+        boolean updateReleases = false;
+        String sourceInfo = String.format(PATTERN_PID_PROPERTY, PID, prefix + PROPERTY_UPDATE_RELEASES);
+        if (updateReleasesProperty == null) {
+            sourceInfo = "Default \"false\"";
+        } else {
+            updateReleases = "true".equals(updateReleasesProperty);
+        }
+        addRow(table, propertyIds ? PROPERTY_UPDATE_RELEASES : "Update releases", new SourceAnd<Boolean>(sourceInfo, updateReleases),
+                "Whether to download non-SNAPSHOT artifacts according to update policy");
+
+        // see org.ops4j.pax.url.mvn.internal.config.MavenConfigurationImpl.isValid()
+        // ANY non null value (even "false"!) means that we require configadmin
+        String requireConfigAdminProperty = context.getProperty(prefix + REQUIRE_CONFIG_ADMIN_CONFIG);
+        boolean requireConfigAdmin = requireConfigAdminProperty != null;
+        sourceInfo = "Default \"false\"";
+        if (requireConfigAdmin) {
+            sourceInfo = "BundleContext property (" + prefix + REQUIRE_CONFIG_ADMIN_CONFIG + ")";
+        }
+        addRow(table, propertyIds ? REQUIRE_CONFIG_ADMIN_CONFIG : "Require Config Admin", new SourceAnd<Boolean>(sourceInfo, requireConfigAdmin),
+                "Whether MavenResolver service is registered ONLY with proper " + PID + " PID configuration");
+
+        // see org.ops4j.pax.url.mvn.internal.config.MavenConfigurationImpl.buildSettings()
+        String useFallbackRepositoriesProperty = (String) config.get(prefix + PROPERTY_USE_FALLBACK_REPOSITORIES);
+        boolean useFallbackRepositories = Boolean.parseBoolean(useFallbackRepositoriesProperty);
+        sourceInfo = "Default \"false\"";
+        if (useFallbackRepositoriesProperty != null) {
+            sourceInfo = String.format(PATTERN_PID_PROPERTY, PID, prefix + PROPERTY_USE_FALLBACK_REPOSITORIES);
+        }
+        addRow(table, propertyIds ? PROPERTY_USE_FALLBACK_REPOSITORIES : "Use fallback repository", new SourceAnd<Boolean>(sourceInfo, useFallbackRepositories),
+                "Whether Maven Central is used as implicit, additional remote repository");
+
+        // see org.ops4j.pax.url.mvn.internal.config.MavenConfigurationImpl.enableProxy()
+        // "proxySupport" and "proxies" are not used in "new" MavenResolver
+
+        // see org.eclipse.aether.internal.impl.DefaultOfflineController#checkOffline()
+        String offlineProperty = (String) config.get(prefix + PROPERTY_OFFLINE);
+        boolean offline = Boolean.parseBoolean(offlineProperty);
+        sourceInfo = "Default \"false\"";
+        if (offlineProperty != null) {
+            sourceInfo = String.format(PATTERN_PID_PROPERTY, PID, prefix + PROPERTY_OFFLINE);
+        }
+        addRow(table, propertyIds ? PROPERTY_OFFLINE : "Offline mode", new SourceAnd<Boolean>(sourceInfo, offline),
+                "Disables access to external remote repositories (file:// based ones are still used)");
+
+        // see org.ops4j.pax.url.mvn.internal.HttpClients.createConnManager()
+        String certificateCheckProperty = (String) config.get(prefix + PROPERTY_CERTIFICATE_CHECK);
+        boolean certificateCheck = Boolean.parseBoolean(certificateCheckProperty);
+        sourceInfo = "Default \"false\"";
+        if (certificateCheckProperty != null) {
+            sourceInfo = String.format(PATTERN_PID_PROPERTY, PID, prefix + PROPERTY_CERTIFICATE_CHECK);
+        }
+        addRow(table, propertyIds ? PROPERTY_CERTIFICATE_CHECK : "SSL/TLS certificate check", new SourceAnd<Boolean>(sourceInfo, certificateCheck),
+                "Turns on server certificate validation for HTTPS remote repositories");
+
+        // repositories (short list)
+        MavenRepositoryURL[] remoteRepositories = repositories(config, true);
+        boolean first = true;
+        for (MavenRepositoryURL url : remoteRepositories) {
+            addRow(table, first ? (propertyIds ? PROPERTY_REPOSITORIES : "Remote repositories") : "", new SourceAnd<String>(url.getFrom().getSource(), url.getURL().toString()),
+                first ? "Remote repositories where artifacts are being resolved if not found locally" : "");
+            first = false;
+        }
+
+        // default repositories (short list)
+        MavenRepositoryURL[] defaultRepositories = repositories(config, false);
+        first = true;
+        for (MavenRepositoryURL url : defaultRepositories) {
+            addRow(table, first ? (propertyIds ? PROPERTY_DEFAULT_REPOSITORIES : "Default repositories") : "", new SourceAnd<String>(url.getFrom().getSource(), url.getURL().toString()),
+                    first ? "Repositories where artifacts are looked up before trying remote resolution" : "");
+            first = false;
+        }
+
+        // proxies (short list)
+        if (mavenSettings != null && mavenSettings.getProxies() != null) {
+            first = true;
+            for (Proxy proxy : mavenSettings.getProxies()) {
+                String value = String.format("%s:%s", proxy.getHost(), proxy.getPort());
+                addRow(table, first ? (propertyIds ? "<proxies>" : "HTTP proxies") : "", new SourceAnd<String>(MavenRepositoryURL.FROM.SETTINGS.getSource(), value),
+                        first ? "Maven HTTP proxies" : "");
+                first = false;
+            }
+        }
+
+        System.out.println();
+        table.print(System.out);
+        System.out.println();
+    }
+
+    /**
+     * Helper to add row to {@link ShellTable}
+     * @param table
+     * @param label
+     * @param value
+     * @param descriptionText
+     */
+    private <T> void addRow(ShellTable table, String label, SourceAnd<T> value, String descriptionText) {
+        Row row = table.addRow();
+        row.addContent(label, value.val());
+        if (source) {
+            row.addContent(value.source);
+        }
+        if (description) {
+            row.addContent(descriptionText);
+        }
+    }
+
+    private SourceAnd<String> updatePolicy(String cmProperty) {
+        SourceAnd<String> result = new SourceAnd<>();
+        result.value = cmProperty;
+
+        if (cmProperty == null || "".equals(cmProperty.trim())) {
+            result.value = "";
+            result.source = "Implicit \"never\", but doesn't override repository-specific value";
+            return result;
+        }
+
+        result.source = String.format(PATTERN_PID_PROPERTY, PID, PID + "." + PROPERTY_GLOBAL_UPDATE_POLICY);
+        if ("always".equals(cmProperty) || "never".equals(cmProperty) || "daily".equals(cmProperty)) {
+            // ok
+        } else if (cmProperty.startsWith("interval")) {
+            int minutes = 1440;
+            try {
+                String n = cmProperty.substring("interval".length() + 1);
+                minutes = Integer.parseInt(n);
+            } catch (Exception e) {
+                result.value = "interval:1440";
+                result.source = "Implicit \"interval:1440\" (error parsing \"" + cmProperty + "\")";
+            }
+        } else {
+            result.value = "never";
+            result.source = "Implicit \"never\" (unknown value \"" + cmProperty + "\")";
+        }
+
+        return result;
+    }
+
+    private SourceAnd<String> checksumPolicy(String cmProperty) {
+        SourceAnd<String> result = new SourceAnd<>();
+        result.value = cmProperty;
+
+        if (cmProperty == null || "".equals(cmProperty.trim())) {
+            result.value = "warn";
+            result.source = "Default \"warn\"";
+            return result;
+        }
+
+        result.source = String.format(PATTERN_PID_PROPERTY, PID, PID + "." + PROPERTY_GLOBAL_CHECKSUM_POLICY);
+        if ("ignore".equals(cmProperty) || "warn".equals(cmProperty) || "fail".equals(cmProperty)) {
+            // ok
+        } else {
+            result.value = "warn";
+            result.source = "Implicit \"warn\" (unknown value \"" + cmProperty + "\")";
+        }
+
+        return result;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/main/java/org/apache/karaf/maven/core/MavenRepositoryURL.java
----------------------------------------------------------------------
diff --git a/maven/core/src/main/java/org/apache/karaf/maven/core/MavenRepositoryURL.java b/maven/core/src/main/java/org/apache/karaf/maven/core/MavenRepositoryURL.java
new file mode 100644
index 0000000..630976b
--- /dev/null
+++ b/maven/core/src/main/java/org/apache/karaf/maven/core/MavenRepositoryURL.java
@@ -0,0 +1,386 @@
+/*
+ * Copyright 2008 Alin Dreghiciu.
+ *
+ * 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.karaf.maven.core;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.ops4j.pax.url.mvn.ServiceConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An URL of Maven repository that knows if it contains SNAPSHOT versions and/or releases.
+ *
+ * @author Alin Dreghiciu
+ * @author Guillaume Nodet
+ * @since 0.2.1, February 07, 2008
+ *
+ * @see org.ops4j.pax.url.mvn.internal.config.MavenRepositoryURL
+ */
+public class MavenRepositoryURL
+{
+    /*
+     * String OPTION_ALLOW_SNAPSHOTS = "snapshots";
+     * String OPTION_DISALLOW_RELEASES = "noreleases";
+     * String OPTION_MULTI = "multi";
+     * String OPTION_ID = "id";
+     * String OPTION_UPDATE = "update";
+     * String OPTION_RELEASES_UPDATE = "releasesUpdate";
+     * String OPTION_SNAPSHOTS_UPDATE = "snapshotsUpdate";
+     * String OPTION_CHECKSUM = "checksum";
+     * String OPTION_RELEASES_CHECKSUM = "releasesChecksum";
+     * String OPTION_SNAPSHOTS_CHECKSUM = "snapshotsChecksum";
+     */
+
+    private static final Logger LOG = LoggerFactory.getLogger( MavenRepositoryURL.class );
+
+    /**
+     * Repository Id.
+     */
+    private final String m_id;
+    /**
+     * Repository URL.
+     */
+    private final URL m_repositoryURL;
+    /**
+     * Repository file (only if URL is a file URL).
+     */
+    private final File m_file;
+    /**
+     * True if the repository contains snapshots.
+     */
+    private final boolean m_snapshotsEnabled;
+    /**
+     * True if the repository contains releases.
+     */
+    private final boolean m_releasesEnabled;
+    /**
+     * Repository update policy
+     */
+    private final String m_releasesUpdatePolicy;
+    /**
+     * Repository update policy
+     */
+    private final String m_snapshotsUpdatePolicy;
+    /**
+     * Repository checksum policy
+     */
+    private final String m_releasesChecksumPolicy;
+    /**
+     * Repository checksum policy
+     */
+    private final String m_snapshotsChecksumPolicy;
+
+    private final boolean m_multi;
+    /**
+     * Where the repository was defined (PID or settings.xml)
+     */
+    private final FROM m_from;
+
+    /**
+     * Creates a maven repository URL bases on a string spec. The path can be marked with @snapshots and/or @noreleases
+     * (not case sensitive).
+     *
+     * @param repositorySpec url spec of repository
+     *
+     * @throws MalformedURLException if spec contains a malformed maven repository url
+     */
+    public MavenRepositoryURL( final String repositorySpec )
+        throws MalformedURLException
+    {
+        final String[] segments = repositorySpec.split( ServiceConstants.SEPARATOR_OPTIONS );
+        final StringBuilder urlBuilder = new StringBuilder();
+        boolean snapshotEnabled = false;
+        boolean releasesEnabled = true;
+        boolean multi = false;
+
+        String name = null;
+        String update = null;
+        String updateReleases = null;
+        String updateSnapshots = null;
+        String checksum = null;
+        String checksumReleases = null;
+        String checksumSnapshots = null;
+        FROM from = null;
+
+        for( int i = 0; i < segments.length; i++ )
+        {
+            String segment = segments[i].trim();
+            if( segment.equalsIgnoreCase( ServiceConstants.OPTION_ALLOW_SNAPSHOTS ) )
+            {
+                snapshotEnabled = true;
+            }
+            else if( segment.equalsIgnoreCase( ServiceConstants.OPTION_DISALLOW_RELEASES ) )
+            {
+                releasesEnabled = false;
+            }
+            else if( segment.equalsIgnoreCase( ServiceConstants.OPTION_MULTI ) )
+            {
+                multi = true;
+            }
+            else if( segment.startsWith( ServiceConstants.OPTION_ID + "=" ) )
+            {
+                try {
+                    name = segments[ i ].split( "=" )[1].trim();
+                } catch (Exception e) {
+                    LOG.warn( "Problem with segment " + segments[i] + " in " + repositorySpec );
+                }
+            }
+            else if( segment.startsWith( ServiceConstants.OPTION_RELEASES_UPDATE + "=" ) )
+            {
+                try {
+                    updateReleases = segments[ i ].split( "=" )[1].trim();
+                } catch (Exception e) {
+                    LOG.warn( "Problem with segment " + segments[i] + " in " + repositorySpec );
+                }
+            }
+            else if( segment.startsWith( ServiceConstants.OPTION_SNAPSHOTS_UPDATE + "=" ) )
+            {
+                try {
+                    updateSnapshots = segments[ i ].split( "=" )[1].trim();
+                } catch (Exception e) {
+                    LOG.warn( "Problem with segment " + segments[i] + " in " + repositorySpec );
+                }
+            }
+            else if( segment.startsWith( ServiceConstants.OPTION_UPDATE + "=" ) )
+            {
+                try {
+                    update = segments[ i ].split( "=" )[1].trim();
+                } catch (Exception e) {
+                    LOG.warn( "Problem with segment " + segments[i] + " in " + repositorySpec );
+                }
+            }
+            else if( segment.startsWith( ServiceConstants.OPTION_RELEASES_CHECKSUM + "=" ) )
+            {
+                try {
+                    checksumReleases = segments[ i ].split( "=" )[1].trim();
+                } catch (Exception e) {
+                    LOG.warn( "Problem with segment " + segments[i] + " in " + repositorySpec );
+                }
+            }
+            else if( segment.startsWith( ServiceConstants.OPTION_SNAPSHOTS_CHECKSUM + "=" ) )
+            {
+                try {
+                    checksumSnapshots = segments[ i ].split( "=" )[1].trim();
+                } catch (Exception e) {
+                    LOG.warn( "Problem with segment " + segments[i] + " in " + repositorySpec );
+                }
+            }
+            else if( segment.startsWith( ServiceConstants.OPTION_CHECKSUM + "=" ) )
+            {
+                try {
+                    checksum = segments[ i ].split( "=" )[1].trim();
+                } catch (Exception e) {
+                    LOG.warn( "Problem with segment " + segments[i] + " in " + repositorySpec );
+                }
+            }
+            else if( segment.startsWith( "_from=" ) )
+            {
+                try {
+                    from = FROM.valueOf( segments[ i ].split( "=" )[1].trim() );
+                } catch (Exception ignored) {
+                }
+            }
+            else
+            {
+                if( i > 0 )
+                {
+                    urlBuilder.append( ServiceConstants.SEPARATOR_OPTIONS );
+                }
+                urlBuilder.append( segments[ i ] );
+            }
+        }
+        String spec = buildSpec( urlBuilder );
+        m_repositoryURL = new URL( spec );
+        m_snapshotsEnabled = snapshotEnabled;
+        m_releasesEnabled = releasesEnabled;
+        m_multi = multi;
+        if (name == null) {
+            String warn = "Repository spec " + spec + " does not contain an identifier. This is deprecated & discouraged & just evil.";
+            LOG.warn( warn );
+            name = "repo_" + spec.hashCode();
+        }
+        m_id = name;
+        m_releasesUpdatePolicy = updateReleases != null ? updateReleases : update;
+        m_snapshotsUpdatePolicy = updateSnapshots != null ? updateSnapshots : update;
+        m_releasesChecksumPolicy = checksumReleases != null ? checksumReleases : checksum;
+        m_snapshotsChecksumPolicy = checksumSnapshots != null ? checksumSnapshots : checksum;
+
+        m_from = from != null ? from : FROM.PID;
+
+        if( m_repositoryURL.getProtocol().equals( "file" ) )
+        {
+            try
+            {
+                // You must transform to URI to decode the path (manage a path with a space or non
+                // us character)
+                // like D:/documents%20and%20Settings/SESA170017/.m2/repository
+                // the path can be store in path part or in scheme specific part (if is relatif
+                // path)
+                // the anti-slash character is not a valid character for uri.
+                spec = spec.replaceAll( "\\\\", "/" );
+                spec = spec.replaceAll( " ", "%20" );
+                URI uri = new URI( spec );
+                String path = uri.getPath();
+                if( path == null )
+                    path = uri.getSchemeSpecificPart();
+                m_file = new File( path );
+
+            }
+            catch ( URISyntaxException e )
+            {
+                throw new MalformedURLException( e.getMessage() );
+            }
+        }
+        else
+        {
+            m_file = null;
+        }
+    }
+
+    private String buildSpec( StringBuilder urlBuilder )
+    {
+        String spec = urlBuilder.toString().trim();
+        if( !spec.endsWith( "\\" ) && !spec.endsWith( "/" ) )
+        {
+            spec = spec + "/";
+        }
+        return spec;
+    }
+
+    /**
+     * Getter.
+     *
+     * @return repository id
+     */
+    public String getId()
+    {
+        return m_id;
+    }
+
+    /**
+     * Getter.
+     *
+     * @return repository URL
+     */
+    public URL getURL()
+    {
+        return m_repositoryURL;
+    }
+
+    /**
+     * Getter.
+     *
+     * @return repository file
+     */
+    public File getFile()
+    {
+        return m_file;
+    }
+
+    /**
+     * Getter.
+     *
+     * @return true if the repository contains releases
+     */
+    public boolean isReleasesEnabled()
+    {
+        return m_releasesEnabled;
+    }
+
+    /**
+     * Getter.
+     *
+     * @return true if the repository contains snapshots
+     */
+    public boolean isSnapshotsEnabled()
+    {
+        return m_snapshotsEnabled;
+    }
+
+    public String getReleasesUpdatePolicy() {
+        return m_releasesUpdatePolicy;
+    }
+
+    public String getSnapshotsUpdatePolicy() {
+        return m_snapshotsUpdatePolicy;
+    }
+
+    public String getReleasesChecksumPolicy() {
+        return m_releasesChecksumPolicy;
+    }
+
+    public String getSnapshotsChecksumPolicy() {
+        return m_snapshotsChecksumPolicy;
+    }
+
+    public FROM getFrom() {
+        return m_from;
+    }
+
+    /**
+     * Getter.
+     *
+     * @return true if the repository is a parent path of repos
+     */
+    public boolean isMulti()
+    {
+        return m_multi;
+    }
+
+    /**
+     * Getter.
+     *
+     * @return if the repository is a file based repository.
+     */
+    public boolean isFileRepository()
+    {
+        return m_file != null;
+    }
+
+    @Override
+    public String toString()
+    {
+        return new StringBuilder()
+            .append( m_repositoryURL.toString() )
+            .append( ",releases=" ).append( m_releasesEnabled )
+            .append( ",snapshots=" ).append( m_snapshotsEnabled )
+            .toString();
+    }
+
+    public static enum FROM {
+        PID("PID configuration"),
+        SETTINGS("Maven XML settings"),
+        FALLBACK("Fallback repository");
+
+        private String source;
+
+        FROM(String source) {
+            this.source = source;
+        }
+
+        public String getSource() {
+            return source;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/main/resources/OSGI-INF/bundle.info
----------------------------------------------------------------------
diff --git a/maven/core/src/main/resources/OSGI-INF/bundle.info b/maven/core/src/main/resources/OSGI-INF/bundle.info
new file mode 100644
index 0000000..509e13b
--- /dev/null
+++ b/maven/core/src/main/resources/OSGI-INF/bundle.info
@@ -0,0 +1,36 @@
+#
+#
+#    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.
+#
+#
+h1. Synopsis
+
+	${project.name}
+
+	${project.description}
+
+	Maven URL:
+		[mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+	This bundle is the core implementation of Maven diagnostics support and exposes commands
+	to change and examine Maven configuration managed by pax-url-aether bundle and org.ops4j.pax.url.mvn PID.
+
+h1. Commands
+
+	The bundle contains the following commands:
+\${command-list|maven|indent=8,list,cyan}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/test/java/org/apache/karaf/maven/SettingsTest.java
----------------------------------------------------------------------
diff --git a/maven/core/src/test/java/org/apache/karaf/maven/SettingsTest.java b/maven/core/src/test/java/org/apache/karaf/maven/SettingsTest.java
new file mode 100644
index 0000000..b0d9110
--- /dev/null
+++ b/maven/core/src/test/java/org/apache/karaf/maven/SettingsTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.apache.karaf.maven;
+
+import java.io.IOException;
+
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.settings.io.DefaultSettingsWriter;
+import org.junit.Test;
+import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
+import org.sonatype.plexus.components.cipher.PBECipher;
+
+public class SettingsTest {
+
+    @Test
+    public void readAndWriteSettings() throws IOException {
+        Settings settings = new Settings();
+        Server s = new Server();
+        s.setId("id");
+        settings.getServers().add(s);
+
+        new DefaultSettingsWriter().write(System.out, null, settings);
+    }
+
+    @Test
+    public void encryptMavenPassword() throws Exception {
+        // non-master password ('mvn -ep admin')
+        DefaultPlexusCipher plexusCipher = new DefaultPlexusCipher();
+        System.out.println(plexusCipher.encrypt("admin", "admin"));
+
+        // master password (`mvn -emp admin`)
+        PBECipher cipher = new PBECipher();
+        System.out.println(cipher.encrypt64("admin","settings.security"));
+    }
+
+    @Test
+    public void decryptMavenPassword() throws Exception {
+        // non-master password ('mvn -ep admin')
+        DefaultPlexusCipher plexusCipher = new DefaultPlexusCipher();
+        System.out.println(plexusCipher.decrypt("{EhjazkVpkMoHjAgaUKX+UxeXn9lsJGHst2uFKmhNZ8U=}", "admin"));
+
+        // master password (`mvn -emp admin`)
+        PBECipher cipher = new PBECipher();
+        System.out.println(cipher.decrypt64("oWE12FbirwYHNit93TAMA+OC/GJge2r9FuzI8kOuHlA=","settings.security"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/core/src/test/resources/reference-settings.xml
----------------------------------------------------------------------
diff --git a/maven/core/src/test/resources/reference-settings.xml b/maven/core/src/test/resources/reference-settings.xml
new file mode 100644
index 0000000..25b58fb
--- /dev/null
+++ b/maven/core/src/test/resources/reference-settings.xml
@@ -0,0 +1,82 @@
+<?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.
+-->
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+
+    <localRepository>file:///</localRepository>
+
+    <proxies>
+        <proxy>
+            <id>id1</id>
+            <host>localhost</host>
+            <port>3128</port>
+            <protocol>http</protocol>
+            <username>username</username>
+            <password>password</password>
+        </proxy>
+    </proxies>
+
+    <servers>
+        <server>
+            <id>id</id>
+            <username>username</username>
+            <password>password</password>
+        </server>
+    </servers>
+
+    <profiles>
+        <profile>
+            <id>profile1</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <repositories>
+                <repository>
+                    <id>id1</id>
+                    <url>http://localhost/maven-repository/releases</url>
+                    <releases>
+                        <enabled>true</enabled>
+                        <updatePolicy>never</updatePolicy>
+                        <checksumPolicy>warn</checksumPolicy>
+                    </releases>
+                    <snapshots>
+                        <enabled>false</enabled>
+                    </snapshots>
+                </repository>
+                <repository>
+                    <id>id2</id>
+                    <url>http://localhost/maven-repository/snapshots</url>
+                    <releases>
+                        <enabled>false</enabled>
+                    </releases>
+                    <snapshots>
+                        <enabled>true</enabled>
+                        <updatePolicy>always</updatePolicy>
+                        <checksumPolicy>warn</checksumPolicy>
+                    </snapshots>
+                </repository>
+            </repositories>
+        </profile>
+    </profiles>
+
+    <activeProfiles>
+        <activeProfile>profile1</activeProfile>
+    </activeProfiles>
+
+</settings>

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/maven/pom.xml
----------------------------------------------------------------------
diff --git a/maven/pom.xml b/maven/pom.xml
new file mode 100644
index 0000000..95a3983
--- /dev/null
+++ b/maven/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf</groupId>
+        <artifactId>karaf</artifactId>
+        <version>4.2.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.karaf.maven</groupId>
+    <artifactId>maven-parent</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache Karaf :: Maven</name>
+
+    <modules>
+        <module>core</module>
+    </modules>
+
+</project>

http://git-wip-us.apache.org/repos/asf/karaf/blob/750fd144/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a7367d2..2767cb1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,6 +65,7 @@
         <module>jdbc</module>
         <module>jms</module>
         <module>jpa</module>
+        <module>maven</module>
         <module>services</module>
         <module>subsystem</module>
         <module>profile</module>
@@ -1077,6 +1078,16 @@
                 <version>${maven.version}</version>
             </dependency>
             <dependency>
+                <groupId>org.apache.maven</groupId>
+                <artifactId>maven-settings</artifactId>
+                <version>${maven.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.maven</groupId>
+                <artifactId>maven-settings-builder</artifactId>
+                <version>${maven.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>org.apache.maven.shared</groupId>
                 <artifactId>maven-dependency-tree</artifactId>
                 <version>2.2</version>


Mime
View raw message