Java源码示例:org.sonatype.plexus.components.cipher.PlexusCipherException

示例1
SpringBootSecDispatcher() {
	File file = new File(MavenSettingsReader.this.homeDir, SECURITY_XML);
	this._configurationFile = file.getAbsolutePath();
	try {
		this._cipher = new DefaultPlexusCipher();
	}
	catch (PlexusCipherException e) {
		throw new IllegalStateException(e);
	}
}
 
示例2
public SecDispatcherImpl() {
    try {
        this._cipher = new DefaultPlexusCipher();
    } catch (PlexusCipherException e) {
        throw new IllegalStateException("Failed to init Security Dispatcher", e);
    }
}
 
示例3
private String getMaster(SettingsSecurity sec)
        throws SecDispatcherException {
    String master = sec.getMaster();

    if (master == null)
        throw new SecDispatcherException("master password is not set");

    try {
        return _cipher.decryptDecorated(master, SYSTEM_PROPERTY_SEC_LOCATION);
    } catch (PlexusCipherException e) {
        throw new SecDispatcherException(e);
    }
}
 
示例4
SpringCloudContractSecDispatcher() {
	File file = new File(MavenSettings.this.homeDir, SECURITY_XML);
	this._configurationFile = file.getAbsolutePath();
	try {
		this._cipher = new DefaultPlexusCipher();
	}
	catch (PlexusCipherException e) {
		throw new IllegalStateException(e);
	}
}
 
示例5
SpringBootSecDispatcher() {
	File file = new File(MavenSettingsReader.this.homeDir, SECURITY_XML);
	this._configurationFile = file.getAbsolutePath();
	try {
		this._cipher = new DefaultPlexusCipher();
	}
	catch (PlexusCipherException e) {
		throw new IllegalStateException(e);
	}
}
 
示例6
public String decrypt(String str)
        throws SecDispatcherException {
    if (!isEncryptedString(str))
        return str;

    String bare = null;

    try {
        bare = _cipher.unDecorate(str);
    } catch (PlexusCipherException e1) {
        throw new SecDispatcherException(e1);
    }

    try {
        Map attr = stripAttributes(bare);

        String res = null;

        SettingsSecurity sec = getSec();

        if (attr == null || attr.get("type") == null) {
            String master = getMaster(sec);

            res = _cipher.decrypt(bare, master);
        } else {
            String type = (String) attr.get(TYPE_ATTR);

            if (_decryptors == null)
                throw new SecDispatcherException(
                        "plexus container did not supply any required dispatchers - cannot lookup " + type);

            Map conf = SecUtil.getConfig(sec, type);

            PasswordDecryptor dispatcher = (PasswordDecryptor) _decryptors.get(type);

            if (dispatcher == null)
                throw new SecDispatcherException("no dispatcher for hint " + type);

            String pass = strip(bare);

            return dispatcher.decrypt(pass, attr, conf);
        }
        return res;
    } catch (Exception e) {
        throw new SecDispatcherException(e);
    }
}
 
示例7
@Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext context) throws ParameterResolutionException {
    try {

        // get descriptor

        Class<? extends AbstractHelmMojo> mojoType = (Class<AbstractHelmMojo>) parameterContext.getParameter().getType();
        MojoDescriptor descriptor = mojoDescriptors.get(mojoType);
        assertNotNull(descriptor, "Plugin descriptor for " + mojoType.getSimpleName() + " not found, run 'maven-plugin-plugin:descriptor'.");

        // create mojo with default values

        AbstractHelmMojo mojo = spy(mojoType);
        for (Parameter parameter : descriptor.getParameters()) {
            if (parameter.getDefaultValue() == null || !parameter.isEditable() || parameter.getType().equals("boolean")) {
                continue;
            }
            getField(mojoType, parameter.getName()).set(mojo, resolve(context, parameter.getDefaultValue()));
        }

        // read mojo values from annotations

        MojoProperty[] mojoProperties = ArrayUtils.addAll(
                context.getRequiredTestClass().getAnnotationsByType(MojoProperty.class),
                context.getRequiredTestMethod().getAnnotationsByType(MojoProperty.class));
        for (MojoProperty mojoProperty : mojoProperties) {
            getField(mojoType, mojoProperty.name()).set(mojo, resolve(context, mojoProperty.value()));
        }

        // settings

        getField(mojoType, "settings").set(mojo, new Settings());
        
        // plexus SecDispatcher

        SecDispatcher secDispatcher = spy(DefaultSecDispatcher.class);
        FieldSetter.setField(secDispatcher, DefaultSecDispatcher.class.getDeclaredField("_cipher"), new DefaultPlexusCipher());
        getField(mojoType, "securityDispatcher").set(mojo, secDispatcher);

        // validate that every parameter is set

        for (Parameter paramter : descriptor.getParameters()) {
            if (paramter.isRequired()) {
                assertNotNull(
                        getField(mojoType, paramter.getName()).get(mojo),
                        "Parameter '" + paramter.getName() + "' not set for mojo '" + mojoType.getSimpleName() + "'.");
            }
        }

        return mojo;
    } catch (ReflectiveOperationException | PlexusCipherException e) {
        throw new ParameterResolutionException("Failed to setup mockito.", e);
    }
}