All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wildfly.security.credential.store.CredentialStorePermission Maven / Gradle / Ivy

There is a newer version: 2.4.1.Final
Show newest version
/*
 * JBoss, Home of Professional Open Source
 * Copyright 2015 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * 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.wildfly.security.credential.store;

import org.wildfly.common.Assert;
import org.wildfly.security.permission.AbstractNameSetOnlyPermission;
import org.wildfly.security.util.StringEnumeration;
import org.wildfly.security.util.StringMapping;

/**
 * Credential Store API specific permission. It can have following target names:
 * 
    *
  • {@code loadCredentialStore}
  • *
  • {@code retrieveCredential}
  • *
  • {@code modifyCredentialStore}
  • *
* @author Peter Skopek. */ public class CredentialStorePermission extends AbstractNameSetOnlyPermission { private static final long serialVersionUID = 6248622485149435793L; private static final StringEnumeration names = StringEnumeration.of( "loadCredentialStore", "retrieveCredential", "modifyCredentialStore" ); private static final StringMapping mapping = new StringMapping<>(names, CredentialStorePermission::new); /** * Load credential store permission. */ public static final CredentialStorePermission LOAD_CREDENTIAL_STORE = mapping.getItemById(0); /** * Retrieve credential (password) permission (from credential store). */ public static final CredentialStorePermission RETRIEVE_CREDENTIAL = mapping.getItemById(1); /** * Store or delete credential (password) permission (from credential store). */ public static final CredentialStorePermission MODIFY_CREDENTIAL_STORE = mapping.getItemById(2); private static final CredentialStorePermission allPermission = new CredentialStorePermission("*"); /** * Creates new {@code CredentialStorePermission} * @param name of new {@code CredentialStorePermission} */ public CredentialStorePermission(final String name) { super(name, names); } /** * Creates new {@code CredentialStorePermission} * @param name of new {@code CredentialStorePermission} * @param actions have to be {@code null} */ public CredentialStorePermission(final String name, final String actions) { this(name); requireEmptyActions(actions); } public CredentialStorePermission withName(final String name) { return forName(name); } /** * Get the permission with the given name. * * @param name the name (must not be {@code null}) * @return the permission (not {@code null}) * @throws IllegalArgumentException if the name is not valid */ public static CredentialStorePermission forName(final String name) { Assert.checkNotNullParam("name", name); return name.equals("*") ? allPermission : mapping.getItemByString(name); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy